Skip to content

Commit 9de7d65

Browse files
get the strict flags another way, to make all the tests pass
1 parent f9e20e6 commit 9de7d65

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

docs/source/html_builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ def write_doc(self, docname: str, doctree: document) -> None:
2626

2727
def _add_strict_list(self) -> None:
2828
p = Path(self.outdir).parent.parent / "source" / "strict_list.rst"
29+
strict_flags: list[str] = []
30+
process_options(["-c", "pass"], list_to_fill_with_strict_flags=strict_flags)
2931
strict_part = ", ".join(
30-
f":option:`{s} <mypy {s}>`" for s in process_options(["-c", "pass"])[2]
32+
f":option:`{s} <mypy {s}>`" for s in strict_flags
3133
)
3234
if (
3335
not strict_part

mypy/main.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,18 @@ def process_options(
471471
fscache: FileSystemCache | None = None,
472472
program: str = "mypy",
473473
header: str = HEADER,
474-
) -> tuple[list[BuildSource], Options, list[str]]:
474+
list_to_fill_with_strict_flags: list[str] | None = None
475+
) -> tuple[list[BuildSource], Options]:
475476
"""Parse command line arguments.
476477
477478
If a FileSystemCache is passed in, and package_root options are given,
478479
call fscache.set_package_root() to set the cache's package root.
479480
480-
Returns a tuple of: a list of source file, an Options collected from flags, and the computed list of strict flags.
481+
Returns a tuple of: a list of source files, an Options collected from flags.
482+
483+
If list_to_fill_with_strict_flags is provided and not none,
484+
then that list will be extended with the computed list of flags that --strict enables
485+
(as a sort of secret return option).
481486
"""
482487
stdout = stdout or sys.stdout
483488
stderr = stderr or sys.stderr
@@ -1515,7 +1520,9 @@ def set_strict_flags() -> None:
15151520
# exceptions of different types.
15161521
except InvalidSourceList as e2:
15171522
fail(str(e2), stderr, options)
1518-
return targets, options, strict_flag_names
1523+
if list_to_fill_with_strict_flags is not None:
1524+
list_to_fill_with_strict_flags.extend(strict_flag_names)
1525+
return targets, options
15191526

15201527

15211528
def process_package_roots(

0 commit comments

Comments
 (0)