-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: support narrowing for bool(E) #14668
Conversation
|
crates/red_knot_python_semantic/resources/mdtest/narrow/conditionals/boolean.md
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/narrow/conditionals/boolean.md
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/narrow/conditionals/boolean.md
Outdated
Show resolved
Hide resolved
Just a note for future: this issue was assigned to me, and not marked "help wanted", because I created it specifically as a ramp-up task for someone joining the Astral team this week :) It's totally fine that you took it on (thanks for the contribution!), but in future it's best to check if an issue is assigned to someone before starting work on it, and if so, comment on the issue to check if you can take it over without duplicating someone's work-in-progress. |
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.
Looks good, thank you! I think we can make the match
statement a bit clearer / more parallel here.
crates/red_knot_python_semantic/resources/mdtest/narrow/bool-call.md
Outdated
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.
Looks great, thank you! Merging.
* main: [`ruff`] Extend unnecessary-regular-expression to non-literal strings (`RUF055`) (#14679) Minor followups to RUF052 (#14755) [red-knot] Property tests (#14178) [red-knot] `is_subtype_of` fix for `KnownInstance` types (#14750) Improve docs for flake8-use-pathlib rules (#14741) [`ruff`] Implemented `used-dummy-variable` (`RUF052`) (#14611) [red-knot] Simplify tuples containing `Never` (#14744) Possible fix for flaky file watching test (#14543) [`flake8-import-conventions`] Improve syntax check for aliases supplied in configuration for `unconventional-import-alias (ICN001)` (#14745) [red-knot] Deeper understanding of `LiteralString` (#14649) red-knot: support narrowing for bool(E) (#14668) [`refurb`] Handle non-finite decimals in `verbose-decimal-constructor (FURB157)` (#14596) [red-knot] Re-enable linter corpus tests (#14736)
Resolves #14547 by delegating narrowing to
E
forbool(E)
whereE
is some expression.This change does not include other builtin class constructors which should also work in this position, like
int(..)
orfloat(..)
, as the original issue does not mention these. It should be easy enough to add checks for these as well if we want to.I don't see a lot of markdown tests for malformed input, maybe there's a better place for the no args and too many args cases to go?
I did see after the fact that it looks like this task was intended for a new hire.. my apologies. I got here from #13694, which is marked help-wanted.