Skip to content
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 unions in functools.partial #17284

Merged
merged 1 commit into from
May 25, 2024

Conversation

hauntsaninja
Copy link
Collaborator

Co-authored-by: cdce8p

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]

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.

Looks good! I like how it is now part of extract_callable_type and thus potentially other code can benefit from it too, not just the functools plugin 👍🏻

@JelleZijlstra JelleZijlstra merged commit 3ddc009 into python:master May 25, 2024
18 checks passed
@cdce8p
Copy link
Collaborator

cdce8p commented May 25, 2024

@hauntsaninja Looking at the primer result, that seems to suggest another issue.

class A:
    def __init__(self, val: int) -> None: ...

cls: type[A]
reveal_type(functools.partial(cls, 2))  # error: "type[A]" not callable  [misc]

@hauntsaninja hauntsaninja deleted the partial-union branch May 25, 2024 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants