Skip to content

Commit 0d86cc6

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 e830c50 commit 0d86cc6

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
@@ -960,80 +960,74 @@ def parse_file(
960960

961961
issues = spellchecker.spellcheck_line(line, line_tokenizer, extra_words_to_ignore=extra_words_to_ignore)
962962
for issue in issues:
963-
# TODO: De-indent in next commit
964-
misspelling = issue.misspelling
965-
word = issue.word
966-
lword = issue.lword
963+
misspelling = issue.misspelling
964+
word = issue.word
965+
lword = issue.lword
967966

968-
context_shown = False
969-
fix = misspelling.fix
970-
candidates = fix_case(word, misspelling.candidates)
967+
context_shown = False
968+
fix = misspelling.fix
969+
candidates = fix_case(word, misspelling.candidates)
971970

972-
if options.interactive and lword not in asked_for:
973-
if context is not None:
974-
context_shown = True
975-
print_context(lines, i, context)
976-
fix, candidates = ask_for_word_fix(
977-
lines[i],
978-
issue,
979-
options.interactive,
980-
colors=colors,
981-
)
982-
asked_for.add(lword)
971+
if options.interactive and lword not in asked_for:
972+
if context is not None:
973+
context_shown = True
974+
print_context(lines, i, context)
975+
fix, candidates = ask_for_word_fix(
976+
lines[i],
977+
issue,
978+
options.interactive,
979+
colors=colors,
980+
)
981+
asked_for.add(lword)
983982

984-
if summary and fix:
985-
summary.update(lword)
983+
if summary and fix:
984+
summary.update(lword)
986985

987-
if word in fixed_words: # can skip because of re.sub below
988-
continue
986+
if word in fixed_words: # can skip because of re.sub below
987+
continue
989988

990-
if options.write_changes and fix:
991-
changed = True
992-
lines[i] = re.sub(rf"\b{word}\b", candidates[0], lines[i])
993-
fixed_words.add(word)
994-
continue
989+
if options.write_changes and fix:
990+
changed = True
991+
lines[i] = re.sub(rf"\b{word}\b", candidates[0], lines[i])
992+
fixed_words.add(word)
993+
continue
995994

996-
# otherwise warning was explicitly set by interactive mode
997-
if (
998-
options.interactive & 2
999-
and not fix
1000-
and not misspelling.reason
1001-
):
1002-
continue
995+
# otherwise warning was explicitly set by interactive mode
996+
if options.interactive & 2 and not fix and not misspelling.reason:
997+
continue
1003998

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}"
999+
cfilename = f"{colors.FILE}{filename}{colors.DISABLE}"
1000+
cline = f"{colors.FILE}{i + 1}{colors.DISABLE}"
1001+
cwrongword = f"{colors.WWORD}{word}{colors.DISABLE}"
1002+
crightword = f"{colors.FWORD}{', '.join(candidates)}{colors.DISABLE}"
10081003

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 = ""
1004+
reason = misspelling.reason
1005+
if reason:
1006+
if options.quiet_level & QuietLevels.DISABLED_FIXES:
1007+
continue
1008+
creason = f" | {colors.FILE}{reason}{colors.DISABLE}"
1009+
else:
1010+
if options.quiet_level & QuietLevels.NON_AUTOMATIC_FIXES:
1011+
continue
1012+
creason = ""
10181013

1019-
# If we get to this point (uncorrected error) we should change
1020-
# our bad_count and thus return value
1021-
bad_count += 1
1014+
# If we get to this point (uncorrected error) we should change
1015+
# our bad_count and thus return value
1016+
bad_count += 1
10221017

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} "
1028-
f"==> {crightword}{creason}"
1029-
)
1030-
elif options.stdin_single_line:
1031-
print(f"{cline}: {cwrongword} ==> {crightword}{creason}")
1032-
else:
1033-
print(
1034-
f"{cline}: {line.strip()}\n\t{cwrongword} "
1035-
f"==> {crightword}{creason}"
1036-
)
1018+
if (not context_shown) and (context is not None):
1019+
print_context(lines, i, context)
1020+
if filename != "-":
1021+
print(
1022+
f"{cfilename}:{cline}: {cwrongword} " f"==> {crightword}{creason}"
1023+
)
1024+
elif options.stdin_single_line:
1025+
print(f"{cline}: {cwrongword} ==> {crightword}{creason}")
1026+
else:
1027+
print(
1028+
f"{cline}: {line.strip()}\n\t{cwrongword} "
1029+
f"==> {crightword}{creason}"
1030+
)
10371031

10381032
if changed:
10391033
if filename == "-":

0 commit comments

Comments
 (0)