@@ -183,7 +183,9 @@ def remove_contractions(word: str):
183183 logger = logging .getLogger ("comment_spell_check" )
184184 for contraction in CONTRACTIONS :
185185 if word .endswith (contraction ):
186- logger .info ("Contraction: %s -> %s" , word , word [: - len (contraction )])
186+ logger .info (
187+ "Contraction: %s -> %s" , word , word [: - len (contraction )]
188+ )
187189 return word [: - len (contraction )]
188190 return word
189191
@@ -192,7 +194,7 @@ def remove_prefix(word: str, prefixes: list[str]):
192194 """Remove the prefix from the word."""
193195 for prefix in prefixes :
194196 if word .startswith (prefix ):
195- return word [len (prefix ) :]
197+ return word [len (prefix ):]
196198 return word
197199
198200
@@ -222,7 +224,9 @@ def spell_check_comment(
222224 prefixes = prefixes or []
223225 error_word = remove_prefix (error_word , prefixes )
224226
225- if len (error_word ) == 0 or error_word in spell or error_word .lower () in spell :
227+ if len (error_word ) == 0 :
228+ continue
229+ if error_word in spell or error_word .lower () in spell :
226230 continue
227231
228232 # Try splitting camel case words and checking each sub-word
@@ -233,7 +237,10 @@ def spell_check_comment(
233237 if len (sub_words ) > 1 and spell_check_words (spell , sub_words ):
234238 continue
235239
236- msg = f"'{ error_word } ', " + f"suggestions: { spell .candidates (error_word )} "
240+ msg = (
241+ f"'{ error_word } ', "
242+ + f"suggestions: { spell .candidates (error_word )} "
243+ )
237244 mistakes .append (msg )
238245
239246 return mistakes
@@ -359,7 +366,8 @@ def output_results(args, bad_words):
359366 print (f"vim +{ line_num } { found_file } " , file = sys .stderr )
360367 else :
361368 print (
362- f"file: { found_file :30} line: { line_num :3d} word: { misspelled_word } " ,
369+ f"file: { found_file :30} line: { line_num :3d} " ,
370+ f"word: { misspelled_word } " ,
363371 file = sys .stderr ,
364372 )
365373
@@ -441,7 +449,9 @@ def comment_spell_check(args):
441449 # f is a directory, so search for files inside
442450 dir_entries = []
443451 for s in suffixes :
444- dir_entries = dir_entries + glob .glob (f + "/**/*" + s , recursive = True )
452+ dir_entries = dir_entries + glob .glob (
453+ f + "/**/*" + s , recursive = True
454+ )
445455
446456 logger .info (dir_entries )
447457
@@ -487,6 +497,7 @@ def comment_spell_check(args):
487497
488498
489499def main ():
500+ """Main function to run the spell checker."""
490501 args = parseargs .parse_args ()
491502 comment_spell_check (args )
492503
0 commit comments