Describe the Bug
Pyrefly reports bad-override when a concrete class overrides a method whose signature uses a module-level TypeVar. The error message shows identical types on both sides of the "not assignable" claim, making this a self-contradictory false positive.
Minimal reproduction:
from typing import TypeVar
from typing_extensions import override
T = TypeVar("T", bound=int)
class Base:
def method(self, x: T | None = None) -> T: ...
class Derived(Base):
@override
def method(self, x: T | None = None) -> T:
raise NotImplementedError
pyrefly check repro.py --preset default
Output:
ERROR Class member `Derived.method` overrides parent class `Base` in an inconsistent manner [bad-override]
`Derived.method` has type `[T: int](self: Derived, x: T | None = None) -> T`, which is not assignable to
`[T: int](self: Derived, x: T | None = None) -> T`, the type of `Base.method`
Expected: No error. The types on both sides of "not assignable" are character-for-character identical.
Notes:
- Reproduces under
--preset default, --preset legacy, and --preset strict.
- Does not reproduce under
--preset basic, where override validation is disabled entirely.
mypy reports no errors on the same code.
Describe the Bug
Pyrefly reports
bad-overridewhen a concrete class overrides a method whose signature uses a module-levelTypeVar. The error message shows identical types on both sides of the "not assignable" claim, making this a self-contradictory false positive.Minimal reproduction:
Output:
Expected: No error. The types on both sides of "not assignable" are character-for-character identical.
Notes:
--preset default,--preset legacy, and--preset strict.--preset basic, where override validation is disabled entirely.mypyreports no errors on the same code.