Traceback
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.20.1
Traceback (most recent call last):
File "mypy/semanal.py", line 7665, in accept
File "mypy/nodes.py", line 1651, in accept
File "mypy/semanal.py", line 1842, in visit_class_def
File "mypy/semanal.py", line 1996, in analyze_class
File "mypy/semanal.py", line 7311, in defer
AssertionError: Must not defer during final iteration
note: use --pdb to drop into pdb
To Reproduce
from typing import Protocol
class Trait[T: Pattern = Pattern](Protocol):
def method(self, other: T) -> bool:
"""Partial order on generality."""
raise NotImplementedError()
class Pattern1(Trait):
def method(self, other: Pattern) -> bool:
return False
class Pattern2(Trait):
def method(self, other: Pattern) -> bool:
return False
type Pattern = Pattern1 | Pattern2
This simplified version does not crash:
from typing import Protocol
class Trait[T](Protocol):
def method(self, other: T) -> bool:
"""Partial order on generality."""
raise NotImplementedError()
class Pattern1(Trait["Pattern"]):
def method(self, other: Pattern) -> bool:
return False
class Pattern2(Trait["Pattern"]):
def method(self, other: Pattern) -> bool:
return False
type Pattern = Pattern1 | Pattern2
Your Environment
- Mypy version used: mypy 1.20.1 (compiled: yes)
- Mypy command-line flags: --show-traceback
- Mypy configuration options from
mypy.ini (and other config files):
[mypy]
warn_unreachable = true
disallow_subclassing_any = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
warn_unused_ignores = true
warn_unused_configs = true
strict_equality = true
exclude_gitignore = true
warn_redundant_casts = true
python_version = 3.14
- Python version used: 3.14
- Operating system and version: Linux
Related Issues
This may be a duplicate but is a different way to reproduce the issue.
Traceback
To Reproduce
This simplified version does not crash:
Your Environment
mypy.ini(and other config files):Related Issues
This may be a duplicate but is a different way to reproduce the issue.