pyright not warning about mismatch Generator with yield from? #11476
Unanswered
Mikaël Capelle (Holt59)
asked this question in
Q&A
Replies: 1 comment 1 reply
|
AFAIK, that's correct. def fn(n: int):
yield from range(n)
x = fn(4)
print(type(x))That prints this: |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The following code does not generate an error from
pyright:My understanding is that the actual return type of
fnwould beIterator[int](reveal_type(iter(range(6)))showsIterator[int]) which mismatches the declared return type. This generates error at runtime if anyone tries to send something to the generator.I am wondering if this is by design or an overlook? If by design, what is the reasoning?
Thanks,
All reactions