-
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
Improvements to RUF15 #7618
Labels
rule
Implementing or modifying a lint rule
Comments
I'd like to support the former but would probably skip the latter -- or, at least, that could be a separate rule that converts |
With the latter my point was not to do a conversion of Can you assign me this? |
Merged
charliermarsh
pushed a commit
that referenced
this issue
Oct 8, 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)) ```
konstin
pushed a commit
that referenced
this issue
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
I have two (small) suggestions for improving unnecessary-iterable-allocation-for-first-element (RUF015)
Don't add
iter
to built-in functions that are already iterableAn example of this could be
list(zip([0]))[0]
, which right now is converted tonext(iter(zip([10])))
, and my suggestion would make it not additer
so it would benext(zip([10]))
Handle an unpacked list
This could be something like this
[*x][0]
, which should be handled likelist(x)[0]
and converts tonext(iter(x))
. I don't think this is used much in the wild, so it could be overkill to add it.I have a first already started implementing this here. Though, as this is the first time I have written any Rust, it could likely be improved upon 😅
The text was updated successfully, but these errors were encountered: