-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add warnings.catch_warning type hints with Literal. #3464
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This is a nice change, thanks. However, I wonder if there is a better way to fix the issue. This PR changes
Maybe @srittau knows how to keep it a class? Maybe it's possible to |
I agree that keeping it as a class would be preferable. From what I understand overloaded init method that allow to narrow the type of a typevar is something that is currently being worked on in mypy. So we can probably improve these hints soon. |
As pointed out already this fails now: import warnings
class WarningsRecorder(warnings.catch_warnings):
pass
Are there plans to fix / allow this still? |
It looks like we should revert to an implementation that uses a class and overloads |
I've performed modification in #3499 to "eat the cake and have it too". @JelleZijlstra Thanks for tip with |
Fixes #3463