Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrepancy in the output of typing.get_args for empty tuple type annotation (typing.Tuple[()]/tuple[()]) between Python3.10 & Python3.11 #100820

Closed
lycantropos opened this issue Jan 7, 2023 · 2 comments
Labels
topic-typing type-bug An unexpected behavior, bug, or error

Comments

@lycantropos
Copy link

lycantropos commented Jan 7, 2023

Bug report

For Python3.8-Python3.10 we have

from typing import Tuple, get_args

assert get_args(Tuple) == ()
assert get_args(Tuple[()]) == ((),)

For Python3.11 behavior changed

from typing import Tuple, get_args

assert get_args(Tuple) == ()
assert get_args(Tuple[()]) == ()

which is a problem since it returns the same output for different cases: when there's no info about tuple elements and when there's no elements in a tuple.

Your environment

  • CPython versions tested on: Python3.8.16, Python3.9.16, Python3.10.9, Python3.11.1.
  • Operating system and architecture: macOS 13.1 i386, but I expect it to be OS-independent, reproduces in docker for python:3.10.9 (sha256:b4b8149f2ff93c993d9b752dd4298493975e341a6b542a33cdfb86ce52555f36) & python:3.11.1 (sha256:a46b962871434568d186ef17ae7038055e17c670833ca5320fc107435fa146d7) images.
@lycantropos lycantropos added the type-bug An unexpected behavior, bug, or error label Jan 7, 2023
@lycantropos
Copy link
Author

Looks like related to
#91137

@hauntsaninja
Copy link
Contributor

Thanks for reporting, and yes, related to the issue you link to. This is mentioned in 3.11's What's New over here: https://docs.python.org/3/whatsnew/3.11.html#typing

@JelleZijlstra (one of the maintainers of typing.py) ran into the change in behaviour in this comment #91137 (comment) and preferred the new behaviour, so it's highly unlikely that CPython would revert this.

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-typing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants