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

Improvements to RUF015 #7848

Merged
merged 16 commits into from
Oct 8, 2023
Merged

Improvements to RUF015 #7848

merged 16 commits into from
Oct 8, 2023

Conversation

hoxbro
Copy link
Contributor

@hoxbro hoxbro commented Oct 7, 2023

Summary

Resolves #7618.

The list of builtin iterator is not exhaustive.

Test Plan

cargo test

a = [1, 2]

examples = [
    enumerate(a),
    filter(lambda x: x, a),
    map(int, a),
    reversed(a),
    zip(a),
    iter(a),
]

for example in examples:
    print(next(example))

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Copy link
Member

@charliermarsh charliermarsh 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, made a few small changes!

false
};
IterationTarget {
range: value.range(),
Copy link
Member

Choose a reason for hiding this comment

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

I think we can just use the range of the value here. (The previous logic would have failed if there was, e.g., space between the bracket and the star.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not think of that...

I was inspired by the logic done for the Expr::ListComp above.

@charliermarsh charliermarsh added the bug Something isn't working label Oct 8, 2023
@charliermarsh charliermarsh enabled auto-merge (squash) October 8, 2023 14:20
@charliermarsh charliermarsh merged commit 2ba5677 into astral-sh:main Oct 8, 2023
@hoxbro hoxbro deleted the improve_ruf015 branch October 8, 2023 14:51
konstin pushed a commit that referenced this pull request Oct 11, 2023
## Summary

Resolves #7618. 

The list of builtin iterator is not exhaustive.

## Test Plan

`cargo test`

``` python
a = [1, 2]

examples = [
    enumerate(a),
    filter(lambda x: x, a),
    map(int, a),
    reversed(a),
    zip(a),
    iter(a),
]

for example in examples:
    print(next(example))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improvements to RUF15
2 participants