This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author JelleZijlstra
Recipients JelleZijlstra, gvanrossum, kj, serhiy.storchaka
Date 2022-04-08.05:07:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1649394435.24.0.500089036679.issue46981@roundup.psfhosted.org>
In-reply-to
Content
I tried out 3.11 on my pyanalyze type checker and got some failures because of this change, because my previous trick for distinguishing between Tuple and Tuple[()] failed.

3.10:

>>> from typing import get_args, Tuple
>>> get_args(Tuple[()])
((),)
>>> get_args(Tuple)
()


3.11:

>>> from typing import get_args, Tuple
>>> get_args(Tuple[()])
()
>>> get_args(Tuple)
()

However, the new behavior is more consistent: get_args(tuple[()]) always returned (). It's also easy enough to work around (just check `... is Tuple`).

I'll put a note in the What's New for 3.11 about this change.
History
Date User Action Args
2022-04-08 05:07:15JelleZijlstrasetrecipients: + JelleZijlstra, gvanrossum, serhiy.storchaka, kj
2022-04-08 05:07:15JelleZijlstrasetmessageid: <1649394435.24.0.500089036679.issue46981@roundup.psfhosted.org>
2022-04-08 05:07:15JelleZijlstralinkissue46981 messages
2022-04-08 05:07:15JelleZijlstracreate