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-43224: Fix Tuple[()].__args__ by mrahtz · Pull Request #31845 · python/cpython

Conversation

@mrahtz

@mrahtz mrahtz commented Mar 13, 2022 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Here's a fun inconsistency:

>>> Tuple[()].__args__
((),)
>>> tuple[()].__args__
()

Even though there's an explicit test for the former behaviour, I don't think it's right:

  • Argument 1: If foo.__args__ is (bar,), that says that foo is being parameterised by bar. When we do Tuple[()], it's really just to get around the fact that Tuple[] is invalid syntax - what we're really meaning to say is that we're not parameterising it with anything. Tuple[()].__args__ should therefore be empty.
  • Argument 2: Everything in Tuple[...].__args__ should be a type. () is not a type.

This matters for PEP 646, where we were expecting that a TypeVarTuple with no arguments would expand to nothing rather than (). If we were to change things so it was consistent with the current behaviour of Tuple[()], we'd have

T = TypeVar('T')
Ts = TypeVarTuple('Ts')
class C(Generic[T, *Ts]): pass
Alias = C[int, *Ts]
Alias[()]  # C[int, ()]

which definitely isn't what we want.

@ilevkivskyi who added the test for the former behaviour, according to the git blame. Is there something I'm missing here?

https://bugs.python.org/issue43224

Sorry, something went wrong.

Uh oh!

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

All reactions
@mrahtz
Fix Tuple[()].__args__
04b2394
@mrahtz
mrahtz requested review from Fidget-Spinner, JelleZijlstra and gvanrossum as code owners March 13, 2022 13:12
@bedevere-bot bedevere-bot added the awaiting review label Mar 13, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 13, 2022
@AlexWaygood

AlexWaygood commented Mar 13, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Looks like this conflicts with (and accomplishes the same thing as?) #31836

All reactions

Sorry, something went wrong.

Uh oh!

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

@mrahtz

mrahtz commented Mar 13, 2022

Copy link
Copy Markdown
Contributor Author

Oops, good catch! Closing.

AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@mrahtz mrahtz closed this Mar 13, 2022
@mrahtz
mrahtz deleted the fix-tuple-args branch April 5, 2022 18:41
@mrahtz mrahtz mannequin mentioned this pull request Apr 11, 2022
Add support for PEP 646 #87390
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner
@JelleZijlstra JelleZijlstra Awaiting requested review from JelleZijlstra JelleZijlstra is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

awaiting review

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.

4 participants

@mrahtz @AlexWaygood @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.