Skip to content

Commit 0317f43

Browse files
committed
More changes
1 parent 7c7a771 commit 0317f43

File tree

4 files changed

+27
-29
lines changed

4 files changed

+27
-29
lines changed

mypy/config_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ def parse_mypy_comments(
639639
stderr = StringIO()
640640
strict_found = False
641641

642-
def set_strict_flags(ignored: Any) -> None:
642+
def set_strict_flags(updates: dict[str, object]) -> None:
643643
nonlocal strict_found
644644
strict_found = True
645645

mypy/stubtest.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -1945,19 +1945,7 @@ def test_stubs(args: _Arguments, use_builtins_fixtures: bool = False) -> int:
19451945
options.pdb = args.pdb
19461946

19471947
if options.config_file:
1948-
strict_flags = ["warn_unused_configs", "warn_unused_ignores"]
1949-
1950-
strict_flag_assignments = [(dest, True) for dest in strict_flags]
1951-
parse_config_file(
1952-
options, strict_flag_assignments, options.config_file, sys.stdout, sys.stderr
1953-
)
1954-
1955-
for dest in strict_flags:
1956-
if getattr(options, dest, False):
1957-
print("note: {} = True [global]".format(dest))
1958-
for glob, updates in options.per_module_options.items():
1959-
if updates.get(dest):
1960-
print("note: {} = True [{}]".format(dest, glob))
1948+
parse_config_file(options, [], options.config_file, sys.stdout, sys.stderr)
19611949

19621950
def error_callback(msg: str) -> typing.NoReturn:
19631951
print(_style("error:", color="red", bold=True), msg)

mypy/test/teststubtest.py

-15
Original file line numberDiff line numberDiff line change
@@ -2643,18 +2643,3 @@ def test_module_and_typeshed(self) -> None:
26432643
assert remove_color_code(output.getvalue()) == (
26442644
"error: cannot pass both --check-typeshed and a list of modules\n"
26452645
)
2646-
2647-
def test_config_file_strict(self) -> None:
2648-
config_file = "[mypy]\nstrict = True\n"
2649-
output = run_stubtest(stub="", runtime="", options=[], config_file=config_file)
2650-
assert output == (
2651-
"note: warn_unused_configs = True [global]\n"
2652-
"note: warn_unused_ignores = True [global]\n"
2653-
"Success: no issues found in 1 module\n"
2654-
)
2655-
config_file = "[mypy-test_module.*]\nstrict = True\n"
2656-
output = run_stubtest(stub="", runtime="", options=[], config_file=config_file)
2657-
assert output == (
2658-
"note: warn_unused_ignores = True [test_module.*]\n"
2659-
"Success: no issues found in 1 module\n"
2660-
)

test-data/unit/check-flags.test

+25
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,31 @@ disallow_subclassing_any = true
21252125
module = 'm'
21262126
disallow_subclassing_any = false
21272127

2128+
[case testStrictPerModule]
2129+
# flags: --config-file tmp/mypy.ini
2130+
2131+
import strictmodule
2132+
import loosemodule
2133+
a = 0 # type: ignore
2134+
2135+
[file strictmodule.py]
2136+
def foo(): # E: Function is missing a return type annotation \
2137+
# N: Use "-> None" if function does not return a value
2138+
1 + "asdf" # E: Unsupported operand types for + ("int" and "str")
2139+
2140+
a = 0 # type: ignore # E: Unused "type: ignore" comment
2141+
2142+
[file loosemodule.py]
2143+
def foo():
2144+
1 + "asdf"
2145+
2146+
a = 0 # type: ignore
2147+
2148+
[file mypy.ini]
2149+
\[mypy]
2150+
strict = False
2151+
\[mypy-strictmodule]
2152+
strict = True
21282153

21292154
[case testNoImplicitOptionalPerModule]
21302155
# flags: --config-file tmp/mypy.ini

0 commit comments

Comments
 (0)