-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Classes with __call__ defined should be a subtype of Callable #797
Comments
Moved to 0.5 since this comes up pretty frequently. |
I'm going to start looking into this one. |
WIP at https://github.com/margaret/mypy/tree/user_defined_callable (thanks @rwbarton for helping)
Does not work and returns |
Have you tried putting a I believe On Fri, Jun 3, 2016 at 7:33 PM, Margaret Sy [email protected]
--Guido van Rossum (python.org/~guido) |
Moving to an earlier milestone since the partial issue is kind of important. |
A related issue is the join of |
@ilevkivskyi Are you still working on this? If not it's better to un-assign. |
Protocols #3132 will fix this, no additional work here will be needed when they are merged. |
According to the documentation, the auth parameter should be an AuthBase subclass[1]. In practice, the actual requirement seems to just be a Callable[[Request], Request], and AuthBase implements that with the __call__ method. However, mypy isn't currently smart enough to infer that __call__ implies Callable[2]. In the interim (and perhaps also to add clearer errors), explicitly support AuthBase. Additionally, this adds typing of AuthBase.__call__, to match the Callable[[Request], Request] declaration used elsewhere. [1] http://docs.python-requests.org/en/master/user/advanced/#custom-authentication [2] python/mypy#797
According to the documentation, the auth parameter should be an AuthBase subclass[1]. In practice, the actual requirement seems to just be a Callable[[Request], Request], and AuthBase implements that with the __call__ method. However, mypy isn't currently smart enough to infer that __call__ implies Callable[2]. In the interim (and perhaps also to add clearer errors), explicitly support AuthBase. Additionally, this adds typing of AuthBase.__call__, to match the Callable[[Request], Request] declaration used elsewhere. [1] http://docs.python-requests.org/en/master/user/advanced/#custom-authentication [2] python/mypy#797
This is now fixed by #3132 |
…bject (#1504) * requests: allow strings in Session.verify Per the documentation[1] (and actual usage), the verify parameter can be a string or a bool. [1] http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification * requests: explicitly support AuthBase for Session.auth According to the documentation, the auth parameter should be an AuthBase subclass[1]. In practice, the actual requirement seems to just be a Callable[[Request], Request], and AuthBase implements that with the __call__ method. However, mypy isn't currently smart enough to infer that __call__ implies Callable[2]. In the interim (and perhaps also to add clearer errors), explicitly support AuthBase. Additionally, this adds typing of AuthBase.__call__, to match the Callable[[Request], Request] declaration used elsewhere. [1] http://docs.python-requests.org/en/master/user/advanced/#custom-authentication [2] python/mypy#797
This code snippet doesn't type check because Mypy doesn't treat Add5() as a Callable[[int], int]
The text was updated successfully, but these errors were encountered: