Skip to content

Conversation

@mrahtz
Copy link
Contributor

@mrahtzmrahtz commented Mar 13, 2022

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

Copy link
Member

@JelleZijlstraJelleZijlstra left a comment

Choose a reason for hiding this comment

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

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

raiseTypeError("Annotated[...] should be used "
"with at least two arguments (a type and an "
"annotation).")
if_is_unpacked_typevartuple(params[0]):
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

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
Member

Choose a reason for hiding this comment

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

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

@mrahtzmrahtzmannequin mentioned this pull request Apr 11, 2022
@JelleZijlstraJelleZijlstra self-requested a review April 15, 2022 23:11
@JelleZijlstraJelleZijlstra self-assigned this Apr 15, 2022
@JelleZijlstraJelleZijlstra merged commit f2bc12f into python:mainApr 16, 2022
@mrahtzmrahtz deleted the annotated-typevartuple branch May 1, 2022 15:31
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@mrahtz@JelleZijlstra@the-knights-who-say-ni@bedevere-bot