chore: prefix unused loop control variables with underscore (ruff B007)#170
Open
alexzhu0 wants to merge 1 commit into
Open
chore: prefix unused loop control variables with underscore (ruff B007)#170alexzhu0 wants to merge 1 commit into
alexzhu0 wants to merge 1 commit into
Conversation
Pure cosmetic fix: when a tuple-unpacking or enumerate loop discards a variable, the underscore prefix signals intent to readers and silences B007. No runtime behavior change. Touches 6 files across adapters, api, config, memory, retrieval, tests. All 11 occurrences flagged by `ruff --select B007` are addressed: 9 via `ruff --fix --unsafe-fixes`, 2 reviewed and applied manually (the third remaining hit is a false positive — `result` is read after the async-for loop as the return value, kept as-is).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cosmetic fix for B007 — when a loop variable is discarded (typical in tuple-unpacking from
.items(),enumerate(), or graph edges), prefixing with_signals intent to readers and matches PEP 8's convention for ignored bindings. No runtime change.Coverage
10 of 11
B007hits across the codebase. The remaining one (process_data_items.py:266) is a false positive —resultis read after theasync forloop as the return value (the idiom is to drain the generator and keep the last yielded value). Left untouched intentionally.Files Changed
adapters/hybrid/neptune_analytics/NeptuneAnalyticsAdapter.pyi→_iin vector-padding enumerateapi/v1/delete/node_deletion.pysrc_props, rel_name→_src_props, _rel_name(onlydst_propsis read)config/settings/persist_env.pyold_value→_old_valuememory/procedural/validators/procedural_validator.py(×2)edge→_edge(only the pack is read)retrieval/procedural_retriever.py(×2)pid→_pidin dict iterationretrieval/time/query_time_parser.pyptype→_ptypetests/unit/auth/test_permission_concurrency.pyi→_iin stress-loopVerification
Method: 9 hits applied via
ruff --fix --unsafe-fixes --select B007, 1 manual (_ptype). All diffs reviewed by hand to confirm the variable is genuinely unused in each scope.