-
Notifications
You must be signed in to change notification settings - Fork 23
Add a check for methods that hardcode their return type, but shouldn't #174
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
The number of typeshed hits is pretty small, because I've been using an early prototype of this check to fix typeshed problems prior to filing this PR:
|
I think this is more-or-less there now. |
Thanks for putting this together, I'll take a look soon. Are the remaining typeshed hits false positives? |
There are several There are two hits in The Python 2 hits just need a backport of the changes I've already made in the Python 3 stdlib, if we decide to go ahead with this. |
Maybe we can disable the check in classes that are Protocols? That seems like it would fix the Iterator case, and it's also generally good for Protocols to be less precise about the return type. |
|
Looks to me like >>> class Foo(reversed): ...
...
>>> type(iter(Foo([1, 2, 3])))
<class 'list_reverseiterator'>
>>> class Foo(zip): ...
...
>>> type(iter(Foo([1, 2], [3, 4])))
<class '__main__.Foo'> |
I was wrong: the three false positives in |
Nice, excluding abstractmethods got rid of the |
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.
We can merge once the typeshed check is green.
typeshed backport PR here: python/typeshed#7128 |
(python/typeshed#7123 will also be required in order to make the CI go green.) |
Hooray! |
An attempt at implementing #168 (closes #168).
Marking this as a draft for now, as I don't think the error message is very good, and I'm not sure how to improve it. I would also be curious to hear what others think of the overall idea before I put any more work in, as well.