-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[flake8-simplify
] Implement enumerate-for-loop
(SIM113
)
#7777
[flake8-simplify
] Implement enumerate-for-loop
(SIM113
)
#7777
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good test cases!
/// idx = 0 | ||
/// for item in items: | ||
/// sum += func(item, idx) | ||
/// idx += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// idx += 1 | |
/// idx += 1 |
crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for.rs
Outdated
Show resolved
Hide resolved
any progress on this? |
@danieleades - Na, but I can take it over. |
CodSpeed Performance ReportMerging #7777 will degrade performances by 4.35%Comparing Summary
Benchmarks breakdown
|
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
SIM113 | 14 | 14 | 0 | 0 | 0 |
Formatter (stable)
✅ ecosystem check detected no format changes.
Formatter (preview)
✅ ecosystem check detected no format changes.
(Taking over.) |
flake8-simplify
] Implement enumerate-for-loop
(SIM113
)
I only ask because I think this lint is the last hold-out for deprecating flake8 linting from the sphinx project! |
😲 😲 😲 |
Should be good to go, also addressed some false positives that exist in the upstream implementation. |
Looking at the ecosystem checks, there are a few more false positives we can fix here. |
Namely:
count = 0
for entry in result:
assert 'thing' in entry[0]
count += 1
assert count == 9, 'only 9 query ranges should remain in the DB' There's a lot of this in tests, which seems ok? I could go either way. You can also write as: for count, entry in enumerate(result):
assert 'thing' in entry[0]
assert count == 9, 'only 9 query ranges should remain in the DB' |
bff5628
to
5c25d68
Compare
Implements SIM113 from #998
Added tests
Limitations
for
loop@charliermarsh please review and let me know any improvements