-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Mypy doesn't ensure self types are reasonable #2374
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
Comments
Based on the above issue, this seems like a good idea... :) |
This looks like a dupe of #16, but I'll leave this open since there's a PR that references this. One thought from the discussion at #16: It may be reasonable to have a first argument (at least one not spelled as
#16 has more discussion. |
Hm. Having fixed a bunch of issues the latest master found in both of our
internal repos and typeshed, I would say that the fear of the pattern
(functions without 'self' in classes) is exaggerated. The only thing we
found was an interface (IMetadataProvider) in pkg_resources.py, which was
meant for documentation only.
|
IMO, ideally we would only allow use of such a function from within the class' scope. We would report an error for functions that are used from the outside (as suggested by Jukka), and also for functions that are unused from the inside. However, personally I would vote for requiring an explicit hint for such functions, keeping the policy and implementation simpler. |
What would such an explicit hint look like?
|
I was thinking about |
Static methods can't be called without a class.
|
For example, this typechecks cleanly:
Related to #2193.
The text was updated successfully, but these errors were encountered: