FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-46981: Remove typing._TypingEmpty by serhiy-storchaka · Pull Request #31836 · python/cpython · GitHub

/ cpython Public

bpo-46981: Remove typing._TypingEmpty - #31836

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:remove-typing-_TypingEmpty
Mar 17, 2022
Merged

bpo-46981: Remove typing._TypingEmpty#31836
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:remove-typing-_TypingEmpty

Conversation

serhiy-storchaka commented Mar 12, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member
  • get_args(Tuple[()]) returns now () instead of ((),).
  • Tuple[Unpack[Ts]][()] returns now the result equal to Tuple[()].

https://bugs.python.org/issue46981

* get_args(Tuple[()]) returns now () instead of ((),).
* Tuple[Unpack[Ts]][()] returns now the result equal to Tuple[()].

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice simplification! One thing I wonder about is whether this would break 3rd party frameworks that do runtime introspection of annotations? E.g. pydantic. Who can we ask?

JelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks!

I don't think this will affect most runtime type checkers; at most it allows them to remove a special case. I did find a reference to _TypingEmpty in the wild: https://github.com/CedricFR/dataenforce/blob/5dfc5f725d6a69197481061d6e6676fdb221adfd/dataenforce/__init__.py#L88. Seems like an attempt to implement their own version of Generic.

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

All right!

I suppose there’s no consequences for typing_extensions either?

Copy link
Copy Markdown
Member

I suppose there’s no consequences for typing_extensions either?

I just checked and typing-extensions uses _TypingEmpty only in the 3.6 implementation of Protocol.

Fidget-Spinner left a comment
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice simplification! One thing I wonder about is whether this would break 3rd party frameworks that do runtime introspection of annotations? E.g. pydantic. Who can we ask?

Searching pydantic, it seems that get_args is rarely used. However, I will cc Samuel just to be sure. The last time we had a change in get_type_hints re Union, I sought his opinion too. Maybe this will help him figure things out if one of his tests breaks.

@samuelcolvin a summary of the change, for your info please:

typing.get_args(typing.Tuple[()]) now returns () instead of ((),).

Copy link
Copy Markdown
Member

Go ahead and merge once tests pass!

serhiy-storchaka merged commit 15df8f8 into python:main Mar 17, 2022
serhiy-storchaka deleted the remove-typing-_TypingEmpty branch March 17, 2022 07:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL