You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mypy crashes when importing types_aiobotocore_s3 #16498
/opt/virtualenvs/cmd-N7MVwD3X-py3.11/lib/python3.11/site-packages/types_aiobotocore_s3/type_defs.pyi:565: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.7.0
Traceback (most recent call last):
File "mypy/semanal.py", line 6525, in accept
File "mypy/nodes.py", line 1308, in accept
File "mypy/semanal.py", line 2855, in visit_assignment_stmt
File "mypy/semanal.py", line 3152, in analyze_typeddict_assign
File "mypy/semanal_typeddict.py", line 359, in check_typeddict
File "mypy/semanal_typeddict.py", line 460, in parse_typeddict_args
File "mypy/messages.py", line 1745, in unimported_type_becomes_any
File "mypy/messages.py", line 2714, in format_type
File "mypy/messages.py", line 2731, in format_type_bare
File "mypy/messages.py", line 2486, in format_type_inner
File "mypy/types.py", line 3074, in get_proper_type
TypeError: mypy.types.ProperType object expected; got mypy.types.RequiredType
/opt/virtualenvs/cmd-N7MVwD3X-py3.11/lib/python3.11/site-packages/types_aiobotocore_s3/type_defs.pyi:565: : note: use --pdb to drop into pdb
I'm running into same issue with Python 3.11.6 and mypy 1.4.1 in a real project, but I was able to reproduce the issue using the instructions above with Python 3.12.0 and mypy 1.7.0. Note that --disallow-any-unimported must be enabled; it works if it's disabled.
% mypy --show-traceback --disallow-any-unimported /tmp/type_defs.pyi
/tmp/type_defs.pyi:2: error: Cannot find implementation or library stub for module named "thismoduledoesntexist" [import-not-found]
/tmp/type_defs.pyi:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
/tmp/type_defs.pyi:4: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.7.0
Traceback (most recent call last):
File "mypy/semanal.py", line 6525, in accept
File "mypy/nodes.py", line 1308, in accept
File "mypy/semanal.py", line 2855, in visit_assignment_stmt
File "mypy/semanal.py", line 3152, in analyze_typeddict_assign
File "mypy/semanal_typeddict.py", line 359, in check_typeddict
File "mypy/semanal_typeddict.py", line 460, in parse_typeddict_args
File "mypy/messages.py", line 1745, in unimported_type_becomes_any
File "mypy/messages.py", line 2714, in format_type
File "mypy/messages.py", line 2731, in format_type_bare
File "mypy/messages.py", line 2486, in format_type_inner
File "mypy/types.py", line 3074, in get_proper_type
TypeError: mypy.types.ProperType object expected; got mypy.types.RequiredType
/tmp/type_defs.pyi:4: : note: use --pdb to drop into pdb
The problem seems to be a NotRequired containing an unimported type inside an old-stype TypedDict (class-style TypedDicts are fine).
Oh, I can reproduce with compiled mypy, but not uncompiled mypy (I was using uncompiled mypy). Because it's one of those runtime checks inserted by mypyc that's failing. Fun.
FWIW, here's how to get it to repro with uncompiled mypy: apply this diff to master:
diff --git a/mypy/types.py b/mypy/types.py
index e7738bd7d..3eabce15d 100644
--- a/mypy/types.py+++ b/mypy/types.py@@ -3076,8 +3076,9 @@ def get_proper_type(typ: Type | None) -> ProperType | None:
typ = typ.type_guard
while isinstance(typ, TypeAliasType):
typ = typ._expand_once()
+ assert isinstance(typ, ProperType), type(typ)
# TODO: store the name of original type alias on this type, so we can show it in errors.
- return cast(ProperType, typ)+ return typ
changed the title [-]Mypy 1.7.0 crashes when importing `types_aiobotocore_s3`[/-][+]Mypy crashes when importing `types_aiobotocore_s3`[/+]on Nov 16, 2023
Activity
AlexWaygood commentedon Nov 15, 2023
Hmm, I can't reproduce locally on py311 or py312
miikka commentedon Nov 15, 2023
I'm running into same issue with Python 3.11.6 and mypy 1.4.1 in a real project, but I was able to reproduce the issue using the instructions above with Python 3.12.0 and mypy 1.7.0. Note that
--disallow-any-unimportedmust be enabled; it works if it's disabled.JelleZijlstra commentedon Nov 15, 2023
Reproduces for me in a clean venv.
I reduced it to a single file:
The problem seems to be a NotRequired containing an unimported type inside an old-stype TypedDict (class-style TypedDicts are fine).
JelleZijlstra commentedon Nov 15, 2023
Also reproduces as far back as mypy 1.4.1 (as @miikka wrote). I haven't tried to see how far back it reproduces, but it's not a recent regression.
AlexWaygood commentedon Nov 15, 2023
Oh, I can reproduce with compiled mypy, but not uncompiled mypy (I was using uncompiled mypy). Because it's one of those runtime checks inserted by mypyc that's failing. Fun.
AlexWaygood commentedon Nov 15, 2023
FWIW, here's how to get it to repro with uncompiled mypy: apply this diff to
master:[-]Mypy 1.7.0 crashes when importing `types_aiobotocore_s3`[/-][+]Mypy crashes when importing `types_aiobotocore_s3`[/+]Fix crash on unimported Any in TypedDict (#16510)