-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contextmanager decorators require Generators #2773
Conversation
the sample from the issue now fails with:
I wasn't sure what to put for the other generic parameters for Also wasn't sure how else to test this so hopefully CI points me in the right direction if I've messed it up 😆 |
hmmm, CI is failing -- looks like |
Will this allow: @contextmanager
def func() -> Iterator[int]:
yield 1 # explicit If not, then there is no way this can be merged. There are thousands existing annotations like this, and we can't make them all fail because of a false negative in rare corner case. |
it will not, my original issue is because of a particularly nasty bug enabled by a developer's misunderstanding of how |
Actually there is basic support for warnings in mypy. But currently warnings still give return code 1. There is some (slowly moving) ongoing work on how to treat errors/warnings more systematically. |
I agree with @ilevkivskyi that we can't afford to break all existing annotations that use Another way forward could be to add special-casing in mypy that detects when a generator function has |
This seems like a good idea to me |
I have marked this as deferred for now. While I think that in general typeshed should have exact types, but backwards compatibility is an issue. Until that is solved/worked around we can't merge this. |
Resolves #2772