Skip to content

Commit 67a5303

Browse files
committed
Build relative filename rather than changing directory
1 parent b3df3ef commit 67a5303

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

mypy/config_parser.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -378,20 +378,19 @@ def _parse_and_extend_config_file(
378378

379379
extend = parser["mypy"].pop("extend", None)
380380
if extend:
381-
cwd = os.getcwd()
382-
try:
383-
# process extend relative to the directory where we found current config
384-
os.chdir(os.path.dirname(abs_file_read))
385-
parse_ret = _parse_and_extend_config_file(
386-
options=options,
387-
set_strict_flags=set_strict_flags,
388-
filename=os.path.abspath(expand_path(extend)),
389-
stdout=stdout,
390-
stderr=stderr,
391-
visited=visited,
392-
)
393-
finally:
394-
os.chdir(cwd)
381+
parse_ret = _parse_and_extend_config_file(
382+
options=options,
383+
set_strict_flags=set_strict_flags,
384+
# refer to extend relative to directory where we found current config
385+
filename=os.path.relpath(
386+
os.path.normpath(
387+
os.path.join(os.path.dirname(abs_file_read), expand_path(extend))
388+
)
389+
),
390+
stdout=stdout,
391+
stderr=stderr,
392+
visited=visited,
393+
)
395394

396395
if parse_ret is None:
397396
print(f"{extend} is not a valid path to extend from {abs_file_read}", file=stderr)

0 commit comments

Comments
 (0)