Skip to content

Commit 673c8cc

Browse files
authored
Merge pull request #39 from jcfr/refactor-introducing-spell_check_words
ENH: Refactor introducing spell_check_words function
2 parents 48248fd + 8ec00ef commit 673c8cc

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

codespell.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ def load_text_file(filename):
8181
return output
8282

8383

84+
def spell_check_words(spell_checker: SpellChecker, words: list[str]):
85+
"""Check each word and report False if at least one has an spelling error."""
86+
for word in words:
87+
if not spell_checker.check(word):
88+
return False
89+
return True
90+
91+
8492
def spell_check_comment(
8593
spell_checker: SpellChecker,
8694
c: comment_parser.common.Comment,
@@ -123,13 +131,8 @@ def spell_check_comment(
123131
if output_lvl > 1:
124132
print(f"Trying splitting camel case word: {error.word}")
125133
sub_words = splitCamelCase(error.word)
126-
if len(sub_words) > 1:
127-
ok_flag = True
128-
for s in sub_words:
129-
if not spell_checker.check(s):
130-
ok_flag = False
131-
if ok_flag:
132-
continue
134+
if len(sub_words) > 1 and spell_check_words(spell_checker, sub_words):
135+
continue
133136

134137
# Check for possessive words
135138
if error.word.endswith("'s"):

0 commit comments

Comments
 (0)