From eec577514804e708123dc17240e84f6e43ba1a8f Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sun, 31 Jul 2022 18:07:00 +0100 Subject: [PATCH 1/3] Fix stubtest crash caused by #13155 --- mypy/build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mypy/build.py b/mypy/build.py index 7c3f16704c5a..7fe59b351a6b 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -674,6 +674,7 @@ def __init__( if options.custom_typeshed_dir is not None: # Check if module lives under custom_typeshed_dir subtree custom_typeshed_dir = os.path.abspath(options.custom_typeshed_dir) + path = os.path.abspath(path) if os.path.commonpath((path, custom_typeshed_dir)) == custom_typeshed_dir: continue From 0f8e9f00a62ea31330cde7131faed75fe27d3d4b Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 1 Aug 2022 00:46:49 +0100 Subject: [PATCH 2/3] Add test which fails on master --- test-data/unit/cmdline.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test-data/unit/cmdline.test b/test-data/unit/cmdline.test index ea1e9cba165a..aa2d9d4fe1c2 100644 --- a/test-data/unit/cmdline.test +++ b/test-data/unit/cmdline.test @@ -1465,3 +1465,16 @@ sys.path = path mypy: "typing.py" shadows library module "typing" note: A user-defined top-level module with name "typing" is not supported == Return code: 2 + +[case testCustomTypeshedDirWithRelativePathDoesNotCrash] +# cmd: mypy --custom-typeshed-dir dir dir/typing.pyi +[file dir/stdlib/abc.pyi] +[file dir/stdlib/builtins.pyi] +[file dir/stdlib/sys.pyi] +[file dir/stdlib/types.pyi] +[file dir/stdlib/typing.pyi] +[file dir/stdlib/typing_extensions.pyi] +[file dir/stdlib/VERSIONS] +[out] +Failed to find builtin module mypy_extensions, perhaps typeshed is broken? +== Return code: 2 \ No newline at end of file From 02981aa057b9243137dc2dc531dd48e47af009b8 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 1 Aug 2022 00:50:13 +0100 Subject: [PATCH 3/3] Newline at end of file --- test-data/unit/cmdline.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-data/unit/cmdline.test b/test-data/unit/cmdline.test index aa2d9d4fe1c2..97a9dcaa7410 100644 --- a/test-data/unit/cmdline.test +++ b/test-data/unit/cmdline.test @@ -1477,4 +1477,4 @@ note: A user-defined top-level module with name "typing" is not supported [file dir/stdlib/VERSIONS] [out] Failed to find builtin module mypy_extensions, perhaps typeshed is broken? -== Return code: 2 \ No newline at end of file +== Return code: 2