@@ -301,7 +301,7 @@ def _find_config_file(
301301
302302def parse_config_file (
303303 options : Options ,
304- set_strict_flags : Callable [[], None ],
304+ strict_flag_assignments : Sequence [ tuple [ str , object ] ],
305305 filename : str | None ,
306306 stdout : TextIO | None = None ,
307307 stderr : TextIO | None = None ,
@@ -327,6 +327,9 @@ def parse_config_file(
327327 options .config_file = file_read
328328 os .environ ["MYPY_CONFIG_FILE_DIR" ] = os .path .dirname (os .path .abspath (file_read ))
329329
330+ def set_strict_flags (updates : dict [str , object ]) -> None :
331+ updates .update (strict_flag_assignments )
332+
330333 if "mypy" not in parser :
331334 if filename or os .path .basename (file_read ) not in defaults .SHARED_CONFIG_NAMES :
332335 print (f"{ file_read } : No [mypy] section in config file" , file = stderr )
@@ -340,11 +343,16 @@ def parse_config_file(
340343 setattr (options , k , v )
341344 options .report_dirs .update (report_dirs )
342345
346+ def set_strict_flags_section (updates : dict [str , object ]) -> None :
347+ for dest , value in strict_flag_assignments :
348+ if dest in PER_MODULE_OPTIONS :
349+ updates [dest ] = value
350+
343351 for name , section in parser .items ():
344352 if name .startswith ("mypy-" ):
345353 prefix = get_prefix (file_read , name )
346354 updates , report_dirs = parse_section (
347- prefix , options , set_strict_flags , section , config_types , stderr
355+ prefix , options , set_strict_flags_section , section , config_types , stderr
348356 )
349357 if report_dirs :
350358 print (
@@ -483,7 +491,7 @@ def destructure_overrides(toml_data: dict[str, Any]) -> dict[str, Any]:
483491def parse_section (
484492 prefix : str ,
485493 template : Options ,
486- set_strict_flags : Callable [[], None ],
494+ set_strict_flags : Callable [[dict [ str , object ] ], None ],
487495 section : Mapping [str , Any ],
488496 config_types : dict [str , Any ],
489497 stderr : TextIO = sys .stderr ,
@@ -576,7 +584,7 @@ def parse_section(
576584 continue
577585 if key == "strict" :
578586 if v :
579- set_strict_flags ()
587+ set_strict_flags (results )
580588 continue
581589 results [options_key ] = v
582590
@@ -675,7 +683,7 @@ def parse_mypy_comments(
675683 stderr = StringIO ()
676684 strict_found = False
677685
678- def set_strict_flags () -> None :
686+ def set_strict_flags (updates : dict [ str , object ] ) -> None :
679687 nonlocal strict_found
680688 strict_found = True
681689
0 commit comments