(🎁) conformance: check for variance on constrained type variables#2016
Closed
KotlinIsland wants to merge 2 commits intopython:mainfrom
Closed
(🎁) conformance: check for variance on constrained type variables#2016KotlinIsland wants to merge 2 commits intopython:mainfrom
KotlinIsland wants to merge 2 commits intopython:mainfrom
Conversation
8bcb4d9 to
cdb0d02
Compare
erictraut
reviewed
May 28, 2025
Collaborator
erictraut
left a comment
There was a problem hiding this comment.
I don't think this proposed test is correct. I also can't find where it's specified in the typing spec.
| # reveal_type(concat(m, a)) | ||
| # reveal_type(concat(a, m)) | ||
|
|
||
| BadConstraint3 = TypeVar("BadConstraint3", str, int, covariant=True) # E: constraints can't have variance |
Collaborator
There was a problem hiding this comment.
I can't find where in the typing spec this is specified. I'm also not sure why it would be the case that value-constrained type variables can't be covariant.
In any case, all conformance tests should derive from the spec itself. You'll see that in most of the tests, the exact text of the spec is quoted to motivate each of the tests.
Member
|
Note that variance is meaningful on constrained type variables if one constraint is assignable to the other. (Given a |
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
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.
i can't update the results on my machine, sorry!