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

Fix singledispatch register signature #13578

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