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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Tweaks
  • Loading branch information
charliermarsh committed Oct 3, 2023
commit 3b0fe589676b24d3cf28f6745c01315d93ce1293
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ use crate::registry::AsRule;
/// This rule is prone to false negatives due to type inference limitations;
/// namely, it will only suggest a fix using the `len` builtin function if the
/// sequence passed to `enumerate` is an instantiated as a list, set, dict, or
/// tuple literal, or annotated as such with a type annotation. This is because
/// the `len` builtin function is not defined for all object types (such as
/// generators).
/// tuple literal, or annotated as such with a type annotation.
///
/// The `len` builtin function is not defined for all object types (such as
/// generators), and so refactoring to use `len` over `enumerate` is not always
/// safe.
///
/// ## Example
/// ```python
Expand Down
Loading