Skip to content

Commit 9d9425b

Browse files
committed
De-indent loop body (whitespace-only / reformatting-only change)
Deliberately in a separate. There are no functional changes, but there are some reformatting changes (line merges) as a consequence of the de-indent.
1 parent 1bffc2d commit 9d9425b

File tree

1 file changed

+58
-64
lines changed

1 file changed

+58
-64
lines changed

codespell_lib/_codespell.py

Lines changed: 58 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -965,80 +965,74 @@ def parse_file(
965965

966966
issues = spellchecker.spellcheck_line(line, line_tokenizer, extra_words_to_ignore=extra_words_to_ignore)
967967
for issue in issues:
968-
# TODO: De-indent in next commit
969-
misspelling = issue.misspelling
970-
word = issue.word
971-
lword = issue.lword
968+
misspelling = issue.misspelling
969+
word = issue.word
970+
lword = issue.lword
972971

973-
context_shown = False
974-
fix = misspelling.fix
975-
candidates = fix_case(word, misspelling.candidates)
972+
context_shown = False
973+
fix = misspelling.fix
974+
candidates = fix_case(word, misspelling.candidates)
976975

977-
if options.interactive and lword not in asked_for:
978-
if context is not None:
979-
context_shown = True
980-
print_context(lines, i, context)
981-
fix, candidates = ask_for_word_fix(
982-
lines[i],
983-
issue,
984-
options.interactive,
985-
colors=colors,
986-
)
987-
asked_for.add(lword)
976+
if options.interactive and lword not in asked_for:
977+
if context is not None:
978+
context_shown = True
979+
print_context(lines, i, context)
980+
fix, candidates = ask_for_word_fix(
981+
lines[i],
982+
issue,
983+
options.interactive,
984+
colors=colors,
985+
)
986+
asked_for.add(lword)
988987

989-
if summary and fix:
990-
summary.update(lword)
988+
if summary and fix:
989+
summary.update(lword)
991990

992-
if word in fixed_words: # can skip because of re.sub below
993-
continue
991+
if word in fixed_words: # can skip because of re.sub below
992+
continue
994993

995-
if options.write_changes and fix:
996-
changed = True
997-
lines[i] = re.sub(rf"\b{word}\b", candidates[0], lines[i])
998-
fixed_words.add(word)
999-
continue
994+
if options.write_changes and fix:
995+
changed = True
996+
lines[i] = re.sub(rf"\b{word}\b", candidates[0], lines[i])
997+
fixed_words.add(word)
998+
continue
1000999

1001-
# otherwise warning was explicitly set by interactive mode
1002-
if (
1003-
options.interactive & 2
1004-
and not fix
1005-
and not misspelling.reason
1006-
):
1007-
continue
1000+
# otherwise warning was explicitly set by interactive mode
1001+
if options.interactive & 2 and not fix and not misspelling.reason:
1002+
continue
10081003

1009-
cfilename = f"{colors.FILE}{filename}{colors.DISABLE}"
1010-
cline = f"{colors.FILE}{i + 1}{colors.DISABLE}"
1011-
cwrongword = f"{colors.WWORD}{word}{colors.DISABLE}"
1012-
crightword = f"{colors.FWORD}{', '.join(candidates)}{colors.DISABLE}"
1004+
cfilename = f"{colors.FILE}{filename}{colors.DISABLE}"
1005+
cline = f"{colors.FILE}{i + 1}{colors.DISABLE}"
1006+
cwrongword = f"{colors.WWORD}{word}{colors.DISABLE}"
1007+
crightword = f"{colors.FWORD}{', '.join(candidates)}{colors.DISABLE}"
10131008

1014-
reason = misspelling.reason
1015-
if reason:
1016-
if options.quiet_level & QuietLevels.DISABLED_FIXES:
1017-
continue
1018-
creason = f" | {colors.FILE}{reason}{colors.DISABLE}"
1019-
else:
1020-
if options.quiet_level & QuietLevels.NON_AUTOMATIC_FIXES:
1021-
continue
1022-
creason = ""
1009+
reason = misspelling.reason
1010+
if reason:
1011+
if options.quiet_level & QuietLevels.DISABLED_FIXES:
1012+
continue
1013+
creason = f" | {colors.FILE}{reason}{colors.DISABLE}"
1014+
else:
1015+
if options.quiet_level & QuietLevels.NON_AUTOMATIC_FIXES:
1016+
continue
1017+
creason = ""
10231018

1024-
# If we get to this point (uncorrected error) we should change
1025-
# our bad_count and thus return value
1026-
bad_count += 1
1019+
# If we get to this point (uncorrected error) we should change
1020+
# our bad_count and thus return value
1021+
bad_count += 1
10271022

1028-
if (not context_shown) and (context is not None):
1029-
print_context(lines, i, context)
1030-
if filename != "-":
1031-
print(
1032-
f"{cfilename}:{cline}: {cwrongword} "
1033-
f"==> {crightword}{creason}"
1034-
)
1035-
elif options.stdin_single_line:
1036-
print(f"{cline}: {cwrongword} ==> {crightword}{creason}")
1037-
else:
1038-
print(
1039-
f"{cline}: {line.strip()}\n\t{cwrongword} "
1040-
f"==> {crightword}{creason}"
1041-
)
1023+
if (not context_shown) and (context is not None):
1024+
print_context(lines, i, context)
1025+
if filename != "-":
1026+
print(
1027+
f"{cfilename}:{cline}: {cwrongword} " f"==> {crightword}{creason}"
1028+
)
1029+
elif options.stdin_single_line:
1030+
print(f"{cline}: {cwrongword} ==> {crightword}{creason}")
1031+
else:
1032+
print(
1033+
f"{cline}: {line.strip()}\n\t{cwrongword} "
1034+
f"==> {crightword}{creason}"
1035+
)
10421036

10431037
if changed:
10441038
if filename == "-":

0 commit comments

Comments
 (0)