Content-Length: 280344 | pFad | http://github.com/astral-sh/ruff/pull/16764

71 fix incorrect ordering of intersection by mtshiba · Pull Request #16764 · astral-sh/ruff · GitHub
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

fix incorrect ordering of intersection #16764

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mtshiba
Copy link
Contributor

@mtshiba mtshiba commented Mar 15, 2025

Summary

From #16641

As stated in this comment (#16641 (comment)), the current ordering implementation for intersection types is incorrect. So, I will introduce lexicographic ordering for intersection types.

Test Plan

As can be seen here, it appears that the execution time of red_knot_check_file will slow down by about 3% when this change is merged. The slow-down itself is unavoidable given that we have been skipping processes that should have been done, but please let me know if there is a better ordering algorithm or some sort of salsa query technique.

@AlexWaygood AlexWaygood added the red-knot Multi-file analysis & type inference label Mar 15, 2025
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 looks great! It looks like this change means that the negation_reverses_subtype_order property test now passes consistently; could you move it from the flaky submodule in property_tests.rs to the stable submodule?

I verified that it now passes consistently by running QUICKCHECK_TESTS=2000000 cargo test --release -p red_knot_python_semantic -- --ignored types::property_tests::flaky::negation_reverses_subtype_order, which quickly fails on main but not on this PR branch.

Comment on lines +26 to +28
left: &Type<'db>,
right: &Type<'db>,
db: &'db dyn crate::Db,
Copy link
Member

Choose a reason for hiding this comment

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

nit: for all other functions and methods in red-knot, db is always the first argument. We should do that here too, for consistency:

Suggested change
left: &Type<'db>,
right: &Type<'db>,
db: &'db dyn crate::Db,
db: &'db dyn crate::Db,
left: &Type<'db>,
right: &Type<'db>,

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.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/astral-sh/ruff/pull/16764

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy