This crashes mypy:
from typing import Generic, TypeVar
def test() -> None:
T = TypeVar("T", bound="Model")
class Query(Generic[T]):
def filter(self, value: T) -> None:
raise NotImplementedError
class Model:
pass
mypy (both 2.1.0 and current master) crashes on this with:
AssertionError: Must not defer during final iteration
Necessary pieces, from reduction:
- The definitions need to be inside a function.
- The TypeVar needs a forward-ref bound to a later local class: bound="Model".
- The local generic class needs to use that T in a method signature.
Similar issues: #12112, #13678, #18579.
This crashes mypy:
mypy (both 2.1.0 and current master) crashes on this with:
AssertionError: Must not defer during final iteration
Necessary pieces, from reduction:
Similar issues: #12112, #13678, #18579.