Skip to content

Support unions in functools.partial - #17284

Merged
JelleZijlstra merged 1 commit into
python:masterfrom
hauntsaninja:partial-union
May 25, 2024
Merged

JelleZijlstra merged 1 commit into
python:masterfrom
hauntsaninja:partial-union

Conversation

@hauntsaninja

Copy link
Copy Markdown
Collaborator

Co-authored-by: cdce8p

@github-actions

Copy link
Copy Markdown
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]

@cdce8p cdce8p left a comment

Copy link
Copy Markdown
Collaborator

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
@cdce8p

cdce8p commented May 25, 2024

Copy link
Copy Markdown
Collaborator

@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

3 participants