Visitar URL original
bpo-34498: Warn against using deprecated ``typing`` aliases with ``@singledispatch`` by AlexWaygood · Pull Request #29508 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20260115174147/https://github.com/python/cpython/pull/29508
Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Nov 9, 2021 •

Attempting to register a singledispatch implementation on certain aliases
from the typing module will lead to an exception being raised. Since these
aliases are all deprecated, this PR proposes simply adding a note to the
documentation steering users towards PEP 585-style syntax.

https://bugs.python.org/issue34498

…ingledispatch``

Attempting to register a ``singledispatch`` implementation on certain aliases
from the ``typing`` module will lead to an exception being raised. Since these
aliases are all deprecated, this PR proposes simply adding a note to the
documentation steering users towards PEP 585-style syntax.
@akulakov
Copy link
Contributor

akulakov commented Dec 4, 2021

Other than 2 minor comments, looks good to me.

@AlexWaygood
Copy link
Member Author

Other than 2 minor comments, looks good to me.

Thanks for taking a look!

@AlexWaygood AlexWaygood requested a review from akulakov December 4, 2021 11:41
Copy link
Contributor

@akulakov akulakov left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes, LGTM

@AlexWaygood
Copy link
Member Author

Thanks for making the changes, LGTM

It actually seems that this would be a bad change to make -- while registering an implementation to list[int] will not raise an exception, actually attempting to use the function will raise an exception. A bug report was just today filed relating to this: https://bugs.python.org/issue46032 (I wasn't previously aware that it didn't work). So, I shall close this PR for now. Thanks very much for taking the time to review, all the same! 🙂

@akulakov
Copy link
Contributor

Note that the part about using list instead of typing.List is still valid.

@AlexWaygood
Copy link
Member Author

Note that the part about using list instead of typing.List is still valid.

True, but how many people on Python <3.9 use typing.List if they don't need to parameterise the list? I know when I was using 3.8, I always used builtin generics unless I needed to parameterise something.

@akulakov
Copy link
Contributor

Yes, I agree; just wanted to note it for reference for the future if someone refers to this PR.

@AlexWaygood AlexWaygood deleted the functools-docs-typing-module branch December 11, 2021 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants