Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,20 @@ def ask_for_word_fix(
colors: TermColors,
) -> Tuple[bool, str]:
wrongword = match.group()
match_start = match.start()
match_end = match.end()
# Detect single quotes, i.e. 'wrongword'->wrongword
if wrongword[0] == "'" and wrongword[-1] == "'":
wrongword = wrongword[1:-1]
match_start += 1
match_end -= 1
if interactivity <= 0:
return misspelling.fix, fix_case(wrongword, misspelling.data)

line_ui = (
f"{line[:match.start()]}"
f"{line[:match_start]}"
f"{colors.WWORD}{wrongword}{colors.DISABLE}"
f"{line[match.end():]}"
f"{line[match_end:]}"
)

if misspelling.fix and interactivity & 1:
Expand Down Expand Up @@ -980,14 +987,19 @@ def parse_file(
)
for match in check_matches:
word = match.group()
match_start = match.start()
# Detect single quotes, i.e. 'word'->word
if word[0] == "'" and word[-1] == "'":
word = word[1:-1]
match_start += 1
if word in ignore_words_cased:
continue
lword = word.lower()
if lword in misspellings and lword not in extra_words_to_ignore:
# Sometimes we find a 'misspelling' which is actually a valid word
# preceded by a string escape sequence. Ignore such cases as
# they're usually false alarms; see issue #17 among others.
char_before_idx = match.start() - 1
char_before_idx = match_start - 1
if (
char_before_idx >= 0
and line[char_before_idx] == "\\"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ allow-magic-value-types = ["bytes", "int", "str",]
max-args = 13
max-branches = 48
max-returns = 12
max-statements = 119
max-statements = 123