-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Labels
genericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementation
Milestone
Description
Summary
Repro:
from contextlib import contextmanager
from collections.abc import Generator
class Base:
pass
class Derived(Base):
pass
def factory[T: Base](cls: type[T]) -> T:
return cls()
d = factory(Derived)
@contextmanager
def yielder[T: Base](cls: type[T]) -> Generator[T]:
yield cls()
with yielder(Derived) as d: # error [invalid-argument-type] "Argument is incorrect: Expected `type[T@yielder]`, found `<class 'Derived'>`!
print(d)Calling yielder(Derived) should infer T as Derived (since Derived is a subclass of Base), matching the behavior of the regular function factory(Derived).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
genericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementation