-
-
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
Remove all __nonzero__
methods
#8443
Conversation
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Typeshed no longer supports Python 2 (even if a third-party library supports Python 2, our stubs for that library don't), so I'm fully in support of this! I don't think we need to wait for the next mypy release. One thing we should do, however, is add |
I'm not sure we should do this. You can still create a |
Yes, but in all cases these methods are just copies of |
I think @JelleZijlstra has a good point, actually; I've changed my mind. Most of the We shouldn't necessarily remove all |
But they don't in the cases of this PR 🙂
|
Sure -- maybe we should go ahead with this PR, then (after the runtime PRs have been merged), but not go ahead with the stubtest change? 🙂 |
I can barely think of any reasonable case where So, in my opinion ignoring legacy is a good thing. But, I am open for other opinions (especially with real-life use-cases). |
That's how they're meant to be used, for sure, but third-party libraries define their own dunder methods relatively frequently anyway -- e.g. |
I still don't see a reason for removing |
Agreed, let's wait a bit 👍 |
I agree with @JelleZijlstra. Let's do whatever the stubbed library does. I'm absolutely in favor of removing |
We'd rather not make these changes until the various runtime libraries have cut releases which have the |
I think that it is almost time (maybe after new mypy release) to remove
__nonzero__
methods fromtypeshed
.Why?
__nonzero__
support from mypy in Remove python2 magic methods support mypy#13277I've also removed all
__nonzero__
methods from these libs:__nonzero__
method psycopg/psycopg2#1484__nonzero__
methods python-babel/babel#896__nonzero__
methods Pylons/waitress#384__nonzero__
method frommodels.Response
psf/requests#6207__nonzero__
methods sqlalchemy/sqlalchemy#8308Some libs, however, support both python2 and python3 (like
python-dateutil
).