-
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] Minor simplifications and improvements to constraint narrowing logic #15270
Merged
+52
−45
Conversation
This file contains 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
AlexWaygood
requested review from
carljm,
MichaReiser and
sharkdp
as code owners
January 5, 2025 15:21
AlexWaygood
force-pushed
the
alex/future-proof-disjointness
branch
from
January 5, 2025 15:24
a89c77b
to
79e5743
Compare
AlexWaygood
force-pushed
the
alex/simplify-constraint-fn
branch
from
January 5, 2025 15:24
91d135c
to
eb01dfa
Compare
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
FURB171 | 4 | 0 | 0 | 0 | 4 |
carljm
approved these changes
Jan 5, 2025
AlexWaygood
commented
Jan 5, 2025
Comment on lines
+86
to
+93
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub enum KnownConstraintFunction { | ||
/// `builtins.isinstance` | ||
IsInstance, | ||
/// `builtins.issubclass` | ||
IsSubclass, | ||
} | ||
|
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 moved this enum here from types.rs
so that all the narrowing logic remained encapsulated in narrow.rs
AlexWaygood
force-pushed
the
alex/simplify-constraint-fn
branch
from
January 5, 2025 19:48
4362821
to
305174f
Compare
AlexWaygood
force-pushed
the
alex/simplify-constraint-fn
branch
from
January 5, 2025 21:46
305174f
to
f0f82f0
Compare
AlexWaygood
changed the base branch from
alex/future-proof-disjointness
to
main
January 5, 2025 21:46
AlexWaygood
changed the title
[red-knot] Minor simplification to constraint narrowing logic
[red-knot] Minor simplifications and improvements to constraint narrowing logic
Jan 5, 2025
dcreager
added a commit
that referenced
this pull request
Jan 6, 2025
* main: (60 commits) [`ruff`] Dataclass enums (`RUF049`) (#15299) Better error message when `--config` is given a table key and a non-inline-table value (#15266) Update pre-commit dependencies (#15289) Don't fix in ecosystem check (#15267) Update Rust crate itertools to 0.14.0 (#15287) Remove accidental empty block at the bottom of `split-static-string (SIM905)` doc (#15290) Update Rust crate clearscreen to v4 (#15288) Update Rust crate insta to v1.42.0 (#15286) Update NPM Development dependencies (#15285) Update dependency uuid to v11.0.4 (#15284) Update dependency ruff to v0.8.6 (#15283) Update Rust crate syn to v2.0.95 (#15282) Update Rust crate matchit to v0.8.6 (#15281) Update Rust crate bstr to v1.11.3 (#15280) [red-knot] Future-proof `Type::is_disjoint_from()` (#15262) [red-knot] Improve `Type::is_disjoint_from()` for `KnownInstanceType`s (#15261) [red-knot] Minor simplifications and improvements to constraint narrowing logic (#15270) Allow assigning ellipsis literal as parameter default value (#14982) [red-knot] fix control flow for assignment expressions in elif tests (#15274) [`refurb`] Mark fix as unsafe when the right-hand side is a string (`FURB171`) (#15273) ...
dcreager
added a commit
that referenced
this pull request
Jan 6, 2025
* main: (29 commits) [`ruff`] Dataclass enums (`RUF049`) (#15299) Better error message when `--config` is given a table key and a non-inline-table value (#15266) Update pre-commit dependencies (#15289) Don't fix in ecosystem check (#15267) Update Rust crate itertools to 0.14.0 (#15287) Remove accidental empty block at the bottom of `split-static-string (SIM905)` doc (#15290) Update Rust crate clearscreen to v4 (#15288) Update Rust crate insta to v1.42.0 (#15286) Update NPM Development dependencies (#15285) Update dependency uuid to v11.0.4 (#15284) Update dependency ruff to v0.8.6 (#15283) Update Rust crate syn to v2.0.95 (#15282) Update Rust crate matchit to v0.8.6 (#15281) Update Rust crate bstr to v1.11.3 (#15280) [red-knot] Future-proof `Type::is_disjoint_from()` (#15262) [red-knot] Improve `Type::is_disjoint_from()` for `KnownInstanceType`s (#15261) [red-knot] Minor simplifications and improvements to constraint narrowing logic (#15270) Allow assigning ellipsis literal as parameter default value (#14982) [red-knot] fix control flow for assignment expressions in elif tests (#15274) [`refurb`] Mark fix as unsafe when the right-hand side is a string (`FURB171`) (#15273) ...
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
On its own this is a pretty minor refactor, but it makes some other improvements I'm working on easier to implement. It nonetheless seems worth doing on its own, however, and reduces the size of the diff on the other branch I have locally, so I'm submitting it as its own PR.
Test Plan
No new tests added; this is a pure refactor, which shouldn't change any functionality.