-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Support type objects in functools.partial #17292
Conversation
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: websockets (https://github.com/aaugustin/websockets)
- src/websockets/legacy/server.py:1048: error: "type[WebSocketServerProtocol]" not callable [misc]
- src/websockets/legacy/client.py:496: error: "type[WebSocketClientProtocol]" not callable [misc]
isort (https://github.com/pycqa/isort)
- isort/exceptions.py:13: error: "Type[ISortError]" not callable [misc]
|
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 @hauntsaninja 👍🏻
p = functools.partial(t, 1) # E: "Type[A]" not callable | ||
p = functools.partial(t, 1) | ||
reveal_type(p) # N: Revealed type is "functools.partial[__main__.A]" | ||
|
||
p("a") # OK | ||
p(1) # False negative | ||
p(z=1) # False negative | ||
p(1) # E: Argument 1 to "A" has incompatible type "int"; expected "str" | ||
p(z=1) # E: Unexpected keyword argument "z" for "A" |
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.
Awesome that these are now fixed!
This is great, thanks @hauntsaninja! Looks like there's still a bug in the presence of a |
No description provided.