-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[red-knot] More comprehensive is_assignable_to
tests
#15353
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.
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
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.
Fantastic!
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
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.
Love it, thank you!!
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.
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 |
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.
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
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 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
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_assignable_to.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
71aab38
to
ffaecb8
Compare
Summary
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 (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.