Skip to content

bpo-34498: Warn against using deprecated typing aliases with @singledispatch - #29508

Closed
AlexWaygood wants to merge 2 commits into
python:mainfrom
AlexWaygood:functools-docs-typing-module
Closed

bpo-34498: Warn against using deprecated typing aliases with @singledispatch#29508
AlexWaygood wants to merge 2 commits into
python:mainfrom
AlexWaygood:functools-docs-typing-module

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Nov 9, 2021

Copy link
Copy Markdown
Member

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.
Comment thread Doc/library/functools.rst
Comment thread Doc/library/functools.rst Outdated
@akulakov

akulakov commented Dec 4, 2021

Copy link
Copy Markdown
Contributor

Other than 2 minor comments, looks good to me.

@AlexWaygood

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

@akulakov akulakov left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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

@AlexWaygood

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