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

Check sequence type before triggering unnecessary-enumerate (FURB148) len suggestion #7781

Merged
merged 6 commits into from
Oct 3, 2023

Conversation

tjkuson
Copy link
Contributor

@tjkuson tjkuson commented Oct 3, 2023

Summary

Check that the sequence type is a list, set, dict, or tuple before recommending replacing the enumerate(...) call with range(len(...)). Document behaviour so users are aware of the type inference limitation leading to false negatives.

Closes #7656.

Test Plan

cargo test

@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@tjkuson tjkuson marked this pull request as ready for review October 3, 2023 14:12
@charliermarsh charliermarsh added the bug Something isn't working label Oct 3, 2023
@charliermarsh
Copy link
Member

Thanks!

@charliermarsh charliermarsh enabled auto-merge (squash) October 3, 2023 14:29
@charliermarsh charliermarsh merged commit 37d21c0 into astral-sh:main Oct 3, 2023
15 checks passed
@tjkuson tjkuson deleted the avoid-generators branch October 3, 2023 14:39
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.

FURB148 generates invalid fix when arg is a generator
2 participants