Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on follow_imports_for_stubs #15407

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
"typing_extensions",
"mypy_extensions",
"_importlib_modulespec",
ilevkivskyi marked this conversation as resolved.
Show resolved Hide resolved
"_typeshed",
"_collections_abc",
"collections",
"collections.abc",
"sys",
"abc",
}
Expand Down Expand Up @@ -2637,7 +2641,7 @@ def find_module_and_diagnose(
result.endswith(".pyi") # Stubs are always normal
and not options.follow_imports_for_stubs # except when they aren't
)
or id in mypy.semanal_main.core_modules # core is always normal
or id in CORE_BUILTIN_MODULES # core is always normal
):
follow_imports = "normal"
if skip_diagnose:
Expand Down
10 changes: 10 additions & 0 deletions test-data/unit/check-flags.test
Original file line number Diff line number Diff line change
Expand Up @@ -2174,3 +2174,13 @@ def f(x: bytes, y: bytearray, z: memoryview) -> None:
x in y
x in z
[builtins fixtures/primitives.pyi]

[case testNoCrashFollowImportsForStubs]
# flags: --config-file tmp/mypy.ini
{**{"x": "y"}}

[file mypy.ini]
\[mypy]
follow_imports = skip
follow_imports_for_stubs = true
[builtins fixtures/dict.pyi]