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: support narrowing for bool(E) #14668

Merged
merged 7 commits into from
Dec 3, 2024
Merged

Conversation

connorskees
Copy link
Contributor

Resolves #14547 by delegating narrowing to E for bool(E) where E is some expression.

This change does not include other builtin class constructors which should also work in this position, like int(..) or float(..), 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.

Copy link
Contributor

github-actions bot commented Nov 29, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood AlexWaygood added the red-knot Multi-file analysis & type inference label Nov 29, 2024
@carljm
Copy link
Contributor

carljm commented Dec 2, 2024

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.

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.

Looks good, thank you! I think we can make the match statement a bit clearer / more parallel here.

@carljm carljm enabled auto-merge (squash) December 3, 2024 03:03
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.

Looks great, thank you! Merging.

@carljm carljm merged commit 3e702e1 into astral-sh:main Dec 3, 2024
20 checks passed
dcreager added a commit that referenced this pull request Dec 3, 2024
* 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)
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] support narrowing on bool(E)
4 participants