Skip to content

Commit

Permalink
DeepSource issue: Implicit enumerate calls found
Browse files Browse the repository at this point in the history
Using `range(len(...))` is not pythonic. Python does not have not
index-based loops. Instead, it uses collection iterators.

Python has a built-in method enumerate which adds a counter to an
iterable. Using this, you can access the counter and the value from
the iterable at the same time. It is therefore recommended to replace
`range(len(...))` with `enumerate(...)`.
  • Loading branch information
DimitriPapadopoulos committed Sep 27, 2022
1 parent 37d4b84 commit ea21649
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ def ask_for_word_fix(line, wrongword, misspelling, interactivity):
opt = [w.strip() for w in misspelling.data.split(',')]
while not r:
print("%s Choose an option (blank for none): " % line, end='')
for i in range(len(opt)):
fixword = fix_case(wrongword, opt[i])
for i, o in enumerate(opt):
fixword = fix_case(wrongword, o)
print(" %d) %s" % (i, fixword), end='')
print(": ", end='')
sys.stdout.flush()
Expand Down

0 comments on commit ea21649

Please sign in to comment.