Skip to content
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] Implement Type::Tuple Comparisons #13712

Merged
merged 7 commits into from
Oct 16, 2024

Conversation

cake-monotone
Copy link
Contributor

Summary

This PR implements comparisons for (tuple, tuple).

It will close #13688 and complete an item in #13618 once merged.

Test Plan

Basic tests are included for (tuple, tuple) comparisons.

Copy link
Contributor

github-actions bot commented Oct 11, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

This is really excellent, thank you!! A few comments.

crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
@carljm carljm added the red-knot Multi-file analysis & type inference label Oct 11, 2024
@cake-monotone cake-monotone marked this pull request as draft October 14, 2024 12:51
@cake-monotone cake-monotone force-pushed the red-knot-tuple-comparision branch from 884362d to 860a8e6 Compare October 14, 2024 14:39
@cake-monotone cake-monotone force-pushed the red-knot-tuple-comparision branch from cbf3c44 to 3dbdae8 Compare October 15, 2024 16:29
@cake-monotone
Copy link
Contributor Author

In addition to the changes mentioned in your review, I have enhanced the inference for in and not In comparisons to make it more powerful.

@cake-monotone cake-monotone marked this pull request as ready for review October 15, 2024 16:41
@cake-monotone cake-monotone requested a review from carljm October 15, 2024 16:42
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks! Some comments below:

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks! This LGTM now, but I'd love a second approval from either @carljm or @dhruvmanila

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

This looks good to me, modulo a few minor comment nits. Thanks for your work here!

I would like better test coverage (fewer todos). For example, right now the "unsupported comparison" case isn't really covered by the tests, because we don't have any rich-comparison operators implemented to return None from infer_binary_type_comparison for unsupported comparisons yet.

But the code here looks correct, so I'm happy to merge it as-is; the effective test coverage here will improve as we flesh out infer_binary_type_comparison.

crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
@carljm carljm enabled auto-merge (squash) October 16, 2024 11:38
@carljm carljm merged commit 2ffc3fa into astral-sh:main Oct 16, 2024
16 checks passed
@cake-monotone cake-monotone deleted the red-knot-tuple-comparision branch October 16, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[red-knot] Compare expression inference - Tuple
4 participants