Skip to content

Commit ed41583

Browse files
committed
Set envvar based on visited files
1 parent 49ddf8c commit ed41583

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

mypy/config_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,9 @@ def _parse_and_extend_config_file(
365365
return None
366366
visited.add(abs_file_read)
367367

368-
if not os.environ.get("MYPY_CONFIG_FILE_DIR"):
369-
# set it only if unset to allow for path variable expansions when parsing below,
370-
# so recursive calls for config extend references won't overwrite it
368+
if len(visited) == 1:
369+
# set it only after the first config file is visited to allow for path variable expansions
370+
# when parsing below, so recursive calls for config extend references won't overwrite it
371371
os.environ["MYPY_CONFIG_FILE_DIR"] = os.path.dirname(abs_file_read)
372372

373373
mypy_updates: dict[str, object] = {}

mypy/test/test_config_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def set_strict_flags() -> None:
174174
assert strict_option_set is True
175175
assert options.ignore_missing_imports_per_module is True
176176
assert options.config_file == str(pyproject.name)
177+
assert os.environ["MYPY_CONFIG_FILE_DIR"] == str(pyproject.parent)
177178

178179
assert options.per_module_options["c"] == {
179180
"disable_error_code": [],

0 commit comments

Comments
 (0)