From 2645d29b196e3937f2a0687f46f92b5a2ee55142 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 24 Jul 2025 17:48:39 +0100 Subject: [PATCH] Remove mypy overrides for tests.test_quickstart --- pyproject.toml | 1 - sphinx/cmd/quickstart.py | 3 ++- tests/test_quickstart.py | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 83d8de0d018..10718c21d4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -295,7 +295,6 @@ disallow_untyped_defs = false [[tool.mypy.overrides]] module = [ # tests/ - "tests.test_quickstart", "tests.test_search", # tests/test_builders "tests.test_builders.test_build_latex", diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py index 73cdabfd97b..a11856e497a 100644 --- a/sphinx/cmd/quickstart.py +++ b/sphinx/cmd/quickstart.py @@ -89,7 +89,8 @@ # function to get input from terminal -- overridden by the test suite -def term_input(prompt: str) -> str: +# Arguments are positional-only to match ``input``. +def term_input(prompt: str, /) -> str: if sys.platform == 'win32': # Important: On windows, readline is not enabled by default. In these # environment, escape sequences have been broken. To avoid the diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py index a66b7c58128..3688984d9c2 100644 --- a/tests/test_quickstart.py +++ b/tests/test_quickstart.py @@ -20,7 +20,7 @@ warnfile = StringIO() -def setup_module(): +def setup_module() -> None: disable_colour() @@ -48,7 +48,7 @@ def input_(prompt: str) -> str: real_input: Callable[[str], str] = input -def teardown_module(): +def teardown_module() -> None: qs.term_input = real_input enable_colour() @@ -61,7 +61,7 @@ def test_do_prompt() -> None: 'Q5': 'no', 'Q6': 'foo', } - qs.term_input = mock_input(answers) # type: ignore[assignment] + qs.term_input = mock_input(answers) assert qs.do_prompt('Q1', default='v1') == 'v1' assert qs.do_prompt('Q3', default='v3_default') == 'v3' @@ -79,7 +79,7 @@ def test_do_prompt_inputstrip() -> None: 'Q3': 'N', 'Q4': 'N ', } - qs.term_input = mock_input(answers) # type: ignore[assignment] + qs.term_input = mock_input(answers) assert qs.do_prompt('Q1') == 'Y' assert qs.do_prompt('Q2') == 'Yes' @@ -91,12 +91,12 @@ def test_do_prompt_with_nonascii() -> None: answers = { 'Q1': '\u30c9\u30a4\u30c4', } - qs.term_input = mock_input(answers) # type: ignore[assignment] + qs.term_input = mock_input(answers) result = qs.do_prompt('Q1', default='\u65e5\u672c') assert result == '\u30c9\u30a4\u30c4' -def test_quickstart_defaults(tmp_path): +def test_quickstart_defaults(tmp_path: Path) -> None: answers = { 'Root path': str(tmp_path), 'Project name': 'Sphinx Test', @@ -127,7 +127,7 @@ def test_quickstart_defaults(tmp_path): assert (tmp_path / 'make.bat').is_file() -def test_quickstart_all_answers(tmp_path): +def test_quickstart_all_answers(tmp_path: Path) -> None: answers = { 'Root path': str(tmp_path), 'Separate source and build': 'y', @@ -185,7 +185,7 @@ def test_quickstart_all_answers(tmp_path): assert (tmp_path / 'source' / 'contents.txt').is_file() -def test_generated_files_eol(tmp_path): +def test_generated_files_eol(tmp_path: Path) -> None: answers = { 'Root path': str(tmp_path), 'Project name': 'Sphinx Test', @@ -205,7 +205,7 @@ def assert_eol(filename: Path, eol: str) -> None: assert_eol(tmp_path / 'Makefile', '\n') -def test_quickstart_and_build(tmp_path): +def test_quickstart_and_build(tmp_path: Path) -> None: answers = { 'Root path': str(tmp_path), 'Project name': 'Fullwidth characters: \u30c9\u30a4\u30c4', @@ -224,7 +224,7 @@ def test_quickstart_and_build(tmp_path): assert not warnings -def test_default_filename(tmp_path): +def test_default_filename(tmp_path: Path) -> None: answers = { 'Root path': str(tmp_path), 'Project name': '\u30c9\u30a4\u30c4', # Fullwidth characters only @@ -242,7 +242,7 @@ def test_default_filename(tmp_path): exec(conffile.read_text(encoding='utf8'), ns) # NoQA: S102 -def test_extensions(tmp_path): +def test_extensions(tmp_path: Path) -> None: qs.main([ '-q', '-p', @@ -261,7 +261,7 @@ def test_extensions(tmp_path): assert ns['extensions'] == ['foo', 'bar', 'baz'] -def test_exits_when_existing_confpy(monkeypatch): +def test_exits_when_existing_confpy(monkeypatch: pytest.MonkeyPatch) -> None: # The code detects existing conf.py with path.is_file() # so we mock it as True with pytest's monkeypatch monkeypatch.setattr('os.path.isfile', lambda path: True)