Closed
Description
Crash Report
I upgraded to mypy 1.11 from 1.08, and previously accepted code started causing crashes.
Traceback
$ mypy mypy-repro.py --show-traceback
mypy-repro.py:8: 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.11.0
Traceback (most recent call last):
File "mypy/checker.py", line 591, in accept
File "mypy/nodes.py", line 1351, in accept
File "mypy/checker.py", line 2948, in visit_assignment_stmt
File "mypy/messages.py", line 1768, in unimported_type_becomes_any
File "mypy/messages.py", line 2805, in format_type
File "mypy/messages.py", line 2822, in format_type_bare
File "mypy/messages.py", line 2540, in format_type_inner
File "mypy/types.py", line 3111, in get_proper_type
TypeError: mypy.types.ProperType object expected; got mypy.types.RequiredType
mypy-repro.py:8: : note: use --pdb to drop into pdb
To Reproduce
mypy-repro.py
:
from typing import NotRequired, Required, TypedDict
from bson.objectid import ObjectId # type: ignore
class Data(TypedDict, total=False):
# NOTE: not complete
_id: Required[ObjectId]
appId: str
(Write what you did to reproduce the crash. Full source code is
appreciated. We also very much appreciate it if you try to narrow the
source down to a small stand-alone example.)
Your Environment
In this repro, I'm using pymongo ^3.13,<4
because I cannot currently upgrade any further due to server dependencies, so bson
is untyped.
- Mypy version used: 1.11.0
- Mypy command-line flags:
mpypy mypy-repro.py
- Mypy configuration options from
pyproject.toml
:
...
[tool.mypy]
python_version = "3.12"
# set mypy_path and explicit_package_bases, otherwise mypy gets confused about package names
# due to the use of namespace packages.
mypy_path = "src"
explicit_package_bases = true
enable_incomplete_feature = ["NewGenericSyntax"]
pretty = true
disallow_any_unimported = true
disallow_any_expr = false
disallow_any_explicit = false
disallow_any_generics = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true
implicit_optional = true
strict_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
exclude = ["(dist|docs)/.*/.*\\.py$"]
- Python version used: Python 3.12.2
- Operating system and version: Debian GNU/Linux 12 (bookworm)