[red-knot] More comprehensive is_assignable_to tests#15353
Merged
Conversation
This changeset migrates all existing `is_assignable_to` tests to a Markdown-based test. It also increases our test coverage in a hopefully meaningful way. At least I found (and fixed) one bug while doing so.
sharkdp
commented
Jan 8, 2025
sharkdp
commented
Jan 8, 2025
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Outdated
Show resolved
Hide resolved
Contributor
|
sharkdp
commented
Jan 8, 2025
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
AlexWaygood
reviewed
Jan 8, 2025
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
AlexWaygood
approved these changes
Jan 8, 2025
Member
AlexWaygood
left a comment
There was a problem hiding this comment.
Some suggested commentary. But I don't mind if you want to leave it to a followup! (And I'm happy to do the followup.) Feel free to merge!
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
| static_assert(is_assignable_to(type[Unknown], Meta)) | ||
| ``` | ||
|
|
||
| ## Tuple types |
Member
There was a problem hiding this comment.
we don't have any gradual tuples in this seciton, and I wonder if we should (e.g. tuple[Any, Literal[2]] should be assignable to tuple[int, int] but not to tuple[int, str]). Doesn't need to be done in this PR, though
Contributor
Author
There was a problem hiding this comment.
I did that now, and also added tests with gradual types in the union and intersection types sections.
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Show resolved
Hide resolved
cd753c6 to
71aab38
Compare
AlexWaygood
reviewed
Jan 8, 2025
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Outdated
Show resolved
Hide resolved
71aab38 to
ffaecb8
Compare
This was referenced Jan 10, 2025
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.
Summary
This changeset migrates all existing
is_assignable_totests to a Markdown-based test. It also increases our test coverage in a hopefully meaningful way (not claiming to be complete in any sense). But at least I found and fixed one bug while doing so.Test Plan
Ran property tests to make sure the new test succeeds after fixing it.