-
Notifications
You must be signed in to change notification settings - Fork 895
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
Use itertools.pairwise instead of zipping a sequence against itself #3297
Comments
That's neat, would make for a good rule. |
@charliermarsh i can take this if you don't think it's too difficult for a newbie - new to Rust, so may take a bit though! |
@evanrittenhouse - Go for it! We can make it a rule under the |
@charliermarsh I've been working on this but am having a bit of trouble. It seems like there are a few I feel like there's a helper function to find this information - is that the case? Do you have any advice for how to get those values from the different |
@evanrittenhouse - I think we probably want to check that the first arg is You might find it useful to take the snippet you're trying to match against, put it in a file, and run So e.g.:
|
Tonight I discovered
itertools.pairwise
(new in 3.10) and replaced 6 lines like this in a ~10,000 line codebase:I have no idea how easy this would be. But if it is easy it might make a nice rule!
And in addition to being less verbose,
pairwise
is also faster on my machine.Another common idiom for this uses indexes. But my gut tells me linting this would be much more difficult and error prone.
The text was updated successfully, but these errors were encountered: