Skip to content

Commit 9d03933

Browse files
authored
Fix --custom-typeshed-dir crash caused by #13155 (#13296)
Fixes #13295
1 parent 0d61315 commit 9d03933

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mypy/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ def __init__(
674674
if options.custom_typeshed_dir is not None:
675675
# Check if module lives under custom_typeshed_dir subtree
676676
custom_typeshed_dir = os.path.abspath(options.custom_typeshed_dir)
677+
path = os.path.abspath(path)
677678
if os.path.commonpath((path, custom_typeshed_dir)) == custom_typeshed_dir:
678679
continue
679680

test-data/unit/cmdline.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,3 +1465,16 @@ sys.path = path
14651465
mypy: "typing.py" shadows library module "typing"
14661466
note: A user-defined top-level module with name "typing" is not supported
14671467
== Return code: 2
1468+
1469+
[case testCustomTypeshedDirWithRelativePathDoesNotCrash]
1470+
# cmd: mypy --custom-typeshed-dir dir dir/typing.pyi
1471+
[file dir/stdlib/abc.pyi]
1472+
[file dir/stdlib/builtins.pyi]
1473+
[file dir/stdlib/sys.pyi]
1474+
[file dir/stdlib/types.pyi]
1475+
[file dir/stdlib/typing.pyi]
1476+
[file dir/stdlib/typing_extensions.pyi]
1477+
[file dir/stdlib/VERSIONS]
1478+
[out]
1479+
Failed to find builtin module mypy_extensions, perhaps typeshed is broken?
1480+
== Return code: 2

0 commit comments

Comments
 (0)