@@ -183,7 +183,9 @@ def remove_contractions(word: str):
183
183
logger = logging .getLogger ("comment_spell_check" )
184
184
for contraction in CONTRACTIONS :
185
185
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
+ )
187
189
return word [: - len (contraction )]
188
190
return word
189
191
@@ -192,7 +194,7 @@ def remove_prefix(word: str, prefixes: list[str]):
192
194
"""Remove the prefix from the word."""
193
195
for prefix in prefixes :
194
196
if word .startswith (prefix ):
195
- return word [len (prefix ) :]
197
+ return word [len (prefix ):]
196
198
return word
197
199
198
200
@@ -222,7 +224,9 @@ def spell_check_comment(
222
224
prefixes = prefixes or []
223
225
error_word = remove_prefix (error_word , prefixes )
224
226
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 :
226
230
continue
227
231
228
232
# Try splitting camel case words and checking each sub-word
@@ -233,7 +237,10 @@ def spell_check_comment(
233
237
if len (sub_words ) > 1 and spell_check_words (spell , sub_words ):
234
238
continue
235
239
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
+ )
237
244
mistakes .append (msg )
238
245
239
246
return mistakes
@@ -359,7 +366,8 @@ def output_results(args, bad_words):
359
366
print (f"vim +{ line_num } { found_file } " , file = sys .stderr )
360
367
else :
361
368
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 } " ,
363
371
file = sys .stderr ,
364
372
)
365
373
@@ -441,7 +449,9 @@ def comment_spell_check(args):
441
449
# f is a directory, so search for files inside
442
450
dir_entries = []
443
451
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
+ )
445
455
446
456
logger .info (dir_entries )
447
457
@@ -487,6 +497,7 @@ def comment_spell_check(args):
487
497
488
498
489
499
def main ():
500
+ """Main function to run the spell checker."""
490
501
args = parseargs .parse_args ()
491
502
comment_spell_check (args )
492
503
0 commit comments