You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incompatible return value type with object in 0.950 #12687
from typing import Generic, TypeVar
T = TypeVar("T")
class Animal(Generic[T]):
pass
class Pooh(Animal[T]):
pass
class Tigger(Animal[T]):
pass
def build_friend(animal_type: str) -> Animal[T]:
friend_map = {constructor.__name__: constructor for constructor in (Pooh, Tigger)}
return friend_map[animal_type]()
# error: Incompatible return value type (got "object", expected "Animal[T]") [return-value]
Expected Behavior
Expected to pass cleanly with no errors.
Actual Behavior
Errors with incompatible return value type
Your Environment
Mypy version used: 0.950
Mypy command-line flags:
Mypy configuration options from mypy.ini (and other config files): strict=True
Activity
hauntsaninja commentedon Dec 30, 2025
This was fixed by #17311