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, 2021
1 parent 37144c6 commit cd33227
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 @@ -532,8 +532,8 @@ def ask_for_word_fix(line, wrongword, misspelling, interactivity):
opt = list(map(lambda x: x.strip(), 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 cd33227

Please sign in to comment.