FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-43224: Add tests for TypeVarTuple substitution in Annotated by mrahtz · Pull Request #31846 · python/cpython · GitHub

/ cpython Public

bpo-43224: Add tests for TypeVarTuple substitution in Annotated - #31846

Merged
JelleZijlstra merged 2 commits into
python:mainfrom
mrahtz:annotated-typevartuple
Apr 16, 2022
Merged

bpo-43224: Add tests for TypeVarTuple substitution in Annotated#31846
JelleZijlstra merged 2 commits into
python:mainfrom
mrahtz:annotated-typevartuple

Conversation

mrahtz commented Mar 13, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

At some point I guess we should add tests for the native tuple too, once #31828 or similar is in.

@JelleZijlstra Does this assuage the concerns you mentioned about Annotated in #31021 (review)?

@@GBeauregard too, since Jelle also mentioned you in that thread - is there anything else we should test for here?

https://bugs.python.org/issue43224

JelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks! The tests are good but it's a bit unfortunate if we can't use Annotated around a TypeVarTuple at all.

Comment thread Lib/typing.py
raise TypeError("Annotated[...] should be used "
"with at least two arguments (a type and an "
"annotation).")
if _is_unpacked_typevartuple(params[0]):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think we need to explicitly disallow this at runtime.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hmm, but then how should we handle situations like this?

A = Annotated[Unpack[Ts], "foo"]
B = A[int, str]

Annotated[int, str, "foo"] wouldn't be valid. We could do some kind of automatic tuple wrapping, Annotated[tuple[int, str], "foo", but that would be inconsistent with how we handle TypeVarTuple substitution elsewhere.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good point, and sorry for not responding to this earlier.

mrahtz mannequin mentioned this pull request Apr 11, 2022
JelleZijlstra self-requested a review April 15, 2022 23:11
JelleZijlstra self-assigned this Apr 15, 2022
JelleZijlstra merged commit f2bc12f into python:main Apr 16, 2022
mrahtz deleted the annotated-typevartuple branch May 1, 2022 15:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL