Skip to content

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

Closed as not planned
@lycantropos

Description

@lycantropos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions