classification
Title: typing module: empty tuple syntax is undocumented
Type: enhancement Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: anowlcalledjosh, docs@python, gvanrossum, levkivskyi, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-08-11 00:36 by anowlcalledjosh, last changed 2019-08-13 19:26 by miss-islington. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 15208 merged anowlcalledjosh, 2019-08-11 12:22
PR 15261 merged miss-islington, 2019-08-13 19:05
PR 15262 merged anowlcalledjosh, 2019-08-13 19:20
Messages (9)
msg349366 - (view) Author: Josh Holland (anowlcalledjosh) * Date: 2019-08-11 00:36
The empty tuple syntax in type annotations, `Tuple[()]`, is not obvious from the examples given in the documentation (I naively expected `Tuple[]` to work); it has been documented in PEP 484[1] and in mypy[2], but not in the documentation for the typing module.

[1]: https://www.python.org/dev/peps/pep-0484/#the-typing-module
[2]: https://github.com/python/mypy/pull/4313
msg349374 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2019-08-11 03:54
That’s correct. Mind making a PR?
msg349388 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-11 13:00
What is better, Tuple[()] or Literal[()]?
msg349389 - (view) Author: Josh Holland (anowlcalledjosh) * Date: 2019-08-11 13:50
PEP 586 doesn't currently allow Literal to contain tuples, so Tuple[()] is the only option.
msg349402 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2019-08-11 17:53
> What is better, Tuple[()] or Literal[()]?

In this context, Tuple[()] is better, as the discussion is about how to write the type of various tuples. Tuple[()] is just the edge case of the type of the empty tuple.

Josh, please sign the CLA and adjust the wording per my request in the PR.
msg349606 - (view) Author: miss-islington (miss-islington) Date: 2019-08-13 19:05
New changeset 8a784af750fa82c8355903309e5089eb2b60c16b by Miss Islington (bot) (Josh Holland) in branch 'master':
bpo-37814: Document the empty tuple type annotation syntax (GH-15208)
https://github.com/python/cpython/commit/8a784af750fa82c8355903309e5089eb2b60c16b
msg349607 - (view) Author: miss-islington (miss-islington) Date: 2019-08-13 19:12
New changeset 6ad902a08814909b4d52c4000d5a10ce58516dac by Miss Islington (bot) in branch '3.8':
bpo-37814: Document the empty tuple type annotation syntax (GH-15208)
https://github.com/python/cpython/commit/6ad902a08814909b4d52c4000d5a10ce58516dac
msg349609 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2019-08-13 19:16
Thanks Josh! The automated backport to 3.7 didn't work, that's okay, so I'll close this now. (Though if you want to experiment with the cherry-picker tool go ahead.)
msg349610 - (view) Author: miss-islington (miss-islington) Date: 2019-08-13 19:26
New changeset 37fd9f73e2fa439554977cfba427bf94c1fedb6b by Miss Islington (bot) (Josh Holland) in branch '3.7':
[3.7] bpo-37814: Document the empty tuple type annotation syntax (GH-15208) (GH-15262)
https://github.com/python/cpython/commit/37fd9f73e2fa439554977cfba427bf94c1fedb6b
History
Date User Action Args
2019-08-13 19:26:19miss-islingtonsetmessages: + msg349610
2019-08-13 19:20:24anowlcalledjoshsetpull_requests: + pull_request14981
2019-08-13 19:16:02gvanrossumsetstatus: open -> closed
resolution: fixed
messages: + msg349609

stage: patch review -> resolved
2019-08-13 19:12:58miss-islingtonsetmessages: + msg349607
2019-08-13 19:05:56miss-islingtonsetpull_requests: + pull_request14980
2019-08-13 19:05:16miss-islingtonsetnosy: + miss-islington
messages: + msg349606
2019-08-11 17:53:40gvanrossumsetmessages: + msg349402
2019-08-11 13:50:39anowlcalledjoshsetmessages: + msg349389
2019-08-11 13:00:24serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg349388
2019-08-11 12:22:10anowlcalledjoshsetkeywords: + patch
stage: patch review
pull_requests: + pull_request14937
2019-08-11 03:54:04gvanrossumsetmessages: + msg349374
2019-08-11 03:19:23xtreaksetnosy: + gvanrossum, levkivskyi
2019-08-11 00:36:34anowlcalledjoshcreate