Closed
Description
Crash Report / Traceback / To Reproduce
I try to use NamedTuple and Generic such as the following code:
# test.py
from typing import (NamedTuple, Generic, TypeVar)
S = TypeVar('S', bound='_S')
class _S:
pass
class A(NamedTuple, Generic[S]):
s: S
In this case mypy raises an internal error:
test.py:9: 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: 0.902
Traceback (most recent call last):
File "mypy/semanal.py", line 4872, in accept
File "mypy/nodes.py", line 687, in accept
File "mypy/semanal.py", line 577, in visit_func_def
File "mypy/semanal.py", line 609, in analyze_func_def
File "mypy/semanal.py", line 4583, in defer
AssertionError: Must not defer during final iteration
test.py:9: : note: use --pdb to drop into pdb
But mypy returns "sucess" with code 0 if I swap class _S
and S
:
# test.py
from typing import (NamedTuple, Generic, TypeVar)
class _S:
pass
S = TypeVar('S', bound='_S')
class A(NamedTuple, Generic[S]):
s: S
Your Environment
- Mypy version used: 0.902
- Mypy command-line flags:
mypy --show-traceback test.py
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.8.0
- Operating system and version: Ubuntu 18.04.5