-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Crash Report
Inside of typing.NamedTuple subclass methods, unpacking assignments with self annotated as typing.Self on the right-hand side causes mypy to fail (internal error).
Traceback
$ mypy --show-traceback foo.py
foo.py:6: 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.9.0
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "mypy\checker.py", line 595, in accept
File "mypy\nodes.py", line 1310, in accept
File "mypy\checker.py", line 2823, in visit_assignment_stmt
File "mypy\checker.py", line 2878, in check_assignment
File "mypy\checker.py", line 3580, in check_assignment_to_multiple_lvalues
File "mypy\checker.py", line 3658, in check_multi_assignment
File "mypy\checker.py", line 3797, in check_multi_assignment_from_tuple
AssertionError:
foo.py:6: : note: use --pdb to drop into pdb
To Reproduce
import typing
class Foo(typing.NamedTuple):
bar: int
def baz(self: typing.Self) -> None:
_ ,= selfmypy-play gist
mypy-play playground
Alternate example showing that this can occur even when self is not directly annotated as typing.Self:
alternate example mypy-play gist
alternate example mypy-play playground
Your Environment
- Mypy version used: 1.9.0
- Mypy command-line flags: --show-traceback
- Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.12.2
- Operating system and version: Microsoft Windows 11 Home