GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-46981: Remove typing._TypingEmpty by serhiy-storchaka · Pull Request #31836 · python/cpython

Conversation

@serhiy-storchaka

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

Uh oh!

There was an error while loading. Please reload this page.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
bpo-46981: Remove typing._TypingEmpty
ff2c8f1
* get_args(Tuple[()]) returns now () instead of ((),).
* Tuple[Unpack[Ts]][()] returns now the result equal to Tuple[()].
@serhiy-storchaka serhiy-storchaka added the type-feature A feature request or enhancement label Mar 12, 2022
@serhiy-storchaka
serhiy-storchaka requested review from Fidget-Spinner, JelleZijlstra and gvanrossum as code owners March 12, 2022 09:37
@bedevere-bot bedevere-bot added the awaiting core review label Mar 12, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 12, 2022
gvanrossum
gvanrossum reviewed Mar 12, 2022
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
JelleZijlstra
JelleZijlstra approved these changes Mar 12, 2022
View reviewed changes

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Mar 12, 2022
gvanrossum
gvanrossum approved these changes Mar 13, 2022
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

All right!

I suppose there’s no consequences for typing_extensions either?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JelleZijlstra

JelleZijlstra commented Mar 13, 2022

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Fidget-Spinner
Fidget-Spinner approved these changes Mar 13, 2022
View reviewed changes

@Fidget-Spinner Fidget-Spinner left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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 ((),).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Misc/NEWS.d/next/Library/2022-03-12-11-30-42.bpo-46981.ltWCxH.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood AlexWaygood mentioned this pull request Mar 13, 2022
bpo-43224: Fix Tuple[()].__args__ #31845
Closed
raghavthind2005
raghavthind2005 approved these changes Mar 14, 2022
View reviewed changes
@serhiy-storchaka @Fidget-Spinner
Update Misc/NEWS.d/next/Library/2022-03-12-11-30-42.bpo-46981.ltWCxH.rst
301d2ed
Co-authored-by: Ken Jin <[email protected]>
@gvanrossum

gvanrossum commented Mar 16, 2022

Copy link
Copy Markdown
Member

Go ahead and merge once tests pass!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
Merge branch 'main' into remove-typing-_TypingEmpty
492bbee
@serhiy-storchaka
serhiy-storchaka merged commit 15df8f8 into python:main Mar 17, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Mar 17, 2022
@serhiy-storchaka
serhiy-storchaka deleted the remove-typing-_TypingEmpty branch March 17, 2022 07:52
@JelleZijlstra JelleZijlstra mentioned this pull request Apr 13, 2022
Add typing to 3.11 What's New #91491
Closed
This was referenced Jun 25, 2022
Empty typing.Tuple #91137
Closed
pickling fails for typing.Tuple[()] #94245
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@gvanrossum gvanrossum gvanrossum approved these changes
@Fidget-Spinner Fidget-Spinner Fidget-Spinner approved these changes
+1 more reviewer
@raghavthind2005 raghavthind2005 raghavthind2005 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@serhiy-storchaka @JelleZijlstra @gvanrossum @Fidget-Spinner @raghavthind2005 @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.