Skip to content

Commit c4ef2e9

Browse files
attempt to enforce str/list[str] condition on modules list
this actually did not matter for the code, I guess. The only reason to change it was because mypy was complaining because mypy doesn't allow redefinition that way (at least with these settings). But instead of beating mypy into doing what I want, I just made the types follow the error message here.
1 parent 8a821c0 commit c4ef2e9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

mypy/config_parser.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,17 +494,20 @@ def destructure_overrides(toml_data: _TomlDictDict) -> _ParserHelper:
494494
"section, but no module to override was specified."
495495
)
496496

497-
if isinstance(override["module"], str):
498-
modules = [override["module"]]
499-
elif isinstance(override["module"], list):
500-
modules = override["module"]
501-
else:
497+
def complain_str_list() -> Never:
502498
raise MypyConfigTOMLValueError(
503499
"toml config file contains a [[tool.mypy.overrides]] "
504500
"section with a module value that is not a string or a list of "
505501
"strings"
506502
)
507503

504+
if isinstance(override["module"], str):
505+
modules = [override["module"]]
506+
elif isinstance(override["module"], list):
507+
modules = [m if isinstance(m, str) else complain_str_list() for m in override["module"]]
508+
else:
509+
complain_str_list()
510+
508511
for module in modules:
509512
module_overrides = override.copy()
510513
del module_overrides["module"]

0 commit comments

Comments
 (0)