Skip to content

Commit a563040

Browse files
committed
Set envvar early
1 parent 436227c commit a563040

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypy/config_parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ def parse_config_file(
316316
file_read, mypy_updates, mypy_report_dirs, module_updates = ret
317317

318318
options.config_file = file_read
319-
os.environ["MYPY_CONFIG_FILE_DIR"] = os.path.dirname(os.path.abspath(file_read))
320319

321320
for k, v in mypy_updates.items():
322321
setattr(options, k, v)
@@ -366,6 +365,11 @@ def _parse_and_extend_config_file(
366365
return None
367366
visited.add(abs_file_read)
368367

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
371+
os.environ["MYPY_CONFIG_FILE_DIR"] = os.path.dirname(abs_file_read)
372+
369373
mypy_updates: dict[str, object] = {}
370374
mypy_report_dirs: dict[str, str] = {}
371375
module_updates: dict[str, dict[str, object]] = {}

0 commit comments

Comments
 (0)