Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

No description provided.

@hauntsaninja hauntsaninja requested a review from cdce8p May 25, 2024 05:09
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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]

Copy link
Collaborator

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hauntsaninja 👍🏻

Comment on lines -306 to +311
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"
Copy link
Collaborator

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!

@cdce8p cdce8p added the upnext label May 25, 2024
@hauntsaninja hauntsaninja merged commit 9315d62 into python:master May 25, 2024
@hauntsaninja hauntsaninja deleted the functools-partial branch May 26, 2024 00:45
@tamird
Copy link
Contributor

tamird commented May 29, 2024

This is great, thanks @hauntsaninja! Looks like there's still a bug in the presence of a Callable[[Type[T]], T]; see #17297 for a repro case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants