Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remind me where PEP 646 forbids this? Assuming
Unpack[Ts]===*Ts, it seems this is forbidding the following:What is wrong with
Xthat isn't wrong withB?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rewrite it as
B[int, *Ts2], so we could unambiguously refer to variables.AFAIK PEP 646 does not cover such case. It does not specify the result.
But what can be the result of substitution
B[int, *Ts2]?Tis substituted withint,T2should be substituted with the last item of*Ts2, and*Tshould be substituted with all but the last items of*Ts2. But we cannot express this, becauseTs2is a variable. If we substitute*Ts2with an empty sequence of types (X[()]), there would not be a value forT2.I think that it is better to make it an error:
You should write
to make it having some sense.
There is a workaround of this problem. It may even make the code more clear. You can see, that
ashould be a tuple containing at least 1 item.T2inBwill be substituted with the type of the last item, and*TsinBwill be substituted with the rest of types.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrahtz what do you think of this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the prod, Jelle. I agree with Serhiy - looks like this is one of the cases we should forbid at runtime.