Skip to content

Fix singledispatch register signature #13578

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

Merged
merged 4 commits into from
Mar 4, 2025

Conversation

flying-sheep
Copy link
Contributor

@flying-sheep flying-sheep commented Mar 4, 2025

Fixes #13560

Available since Python 3.11 according to the docs.

It also supports _UnionGenericAlias values (i.e. values resulting from typing Union[X, Y]), but idk if it’s possible to express that.

Copy link
Contributor

github-actions bot commented Mar 4, 2025

Diff from mypy_primer, showing the effect of this PR on open source code:

ibis (https://github.com/ibis-project/ibis)
- ibis/backends/polars/compiler.py:745: note:     def register(self, cls: type[Any], func: None = ...) -> Callable[[Callable[..., Any]], Callable[..., Any]]
+ ibis/backends/polars/compiler.py:745: note:     def register(self, cls: type[Any] | UnionType, func: None = ...) -> Callable[[Callable[..., Any]], Callable[..., Any]]
- ibis/backends/polars/compiler.py:745: note:     def register(self, cls: type[Any], func: Callable[..., Any]) -> Callable[..., Any]
+ ibis/backends/polars/compiler.py:745: note:     def register(self, cls: type[Any] | UnionType, func: Callable[..., Any]) -> Callable[..., Any]

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks!

@srittau srittau merged commit 714c99b into python:main Mar 4, 2025
55 checks passed
mmingyu pushed a commit to mmingyu/typeshed that referenced this pull request May 16, 2025
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.

singledispatch(method).register should accept UnionType
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy