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 — `Tuple[...]` is allowed since 3.11+ (gh-31021) · Issue #96792 · python/cpython

Tuple[...] is allowed since 3.11+ (gh-31021) #96792

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Tuple[...] is allowed since 3.11+ (gh-31021)#96792
Copy link
Assignees
JelleZijlstrasobolevn
Labels
topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sobolevn
sobolevn
opened on Sep 13, 2022
Issue body actions

Before TypeVarTuple support was megred, this is what happened when Tuple[...] was used:

Python 3.10.0 (default, Nov  1 2021, 10:24:06) [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Tuple
>>> Tuple[...]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sobolev/.pyenv/versions/3.10.0/lib/python3.10/typing.py", line 309, in inner
    return func(*args, **kwds)
  File "/Users/sobolev/.pyenv/versions/3.10.0/lib/python3.10/typing.py", line 1210, in __getitem__
    params = tuple(_type_check(p, msg) for p in params)
  File "/Users/sobolev/.pyenv/versions/3.10.0/lib/python3.10/typing.py", line 1210, in <genexpr>
    params = tuple(_type_check(p, msg) for p in params)
  File "/Users/sobolev/.pyenv/versions/3.10.0/lib/python3.10/typing.py", line 173, in _type_check
    raise TypeError(f"{msg} Got {arg!r:.100}.")
TypeError: Tuple[t0, t1, ...]: each t must be a type. Got Ellipsis.

Since 3.11 it is allowed:

Python 3.12.0a0 (heads/main-dirty:a36235d5c7, Sep 11 2022, 12:23:24) [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Tuple
>>> Tuple[...]
typing.Tuple[...]

What should we do?

  1. Keep this as-is, provide a test that this is allowed (I don't know why anyone would use tuple[...])
  2. Make sure that it is still an error with newer version: fix regression and add a test case

In both case I would like to send a PR :)

Related:

  • Add support for PEP 646 #87390
  • bpo-43224: Implement PEP 646 changes to typing.py #31021

CC @JelleZijlstra and @Fidget-Spinner

Activity

  1. sobolevn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-typing
    on Sep 13, 2022
  2. sobolevn
    self-assigned this
    on Sep 13, 2022
  3. serhiy-storchaka
    assigned
    JelleZijlstra
    on Sep 14, 2022
  4. serhiy-storchaka commented on Sep 14, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Sep 14, 2022
    Member
    More actions

    Stricter check was removed in bpo-46644, so now Tuple accepts virtually arbitrary arguments:

    >>> Tuple[4]
    typing.Tuple[4]

    I do not think that it is right.

    Reacted by Honglei
  5. JelleZijlstra commented on Sep 14, 2022

    @JelleZijlstra
    JelleZijlstra
    on Sep 14, 2022
    Member
    More actions

    Thanks for digging that up. This is an intentional change to make the runtime type system more flexible and less opinionated, so that it is easier to evolve it in the future.

  6. JelleZijlstra
    closed this as not plannedon Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra
  • @sobolevn
    sobolevn

Labels

topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.