-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-join-v-unionUsing join vs. using unionsUsing join vs. using unions
Description
Bug Report
This did not error in previous versions.
To Reproduce
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 - Python version used: 3.10.0
- Operating system and version: Mac OS
nmrtv
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-join-v-unionUsing join vs. using unionsUsing join vs. using unions