@@ -365,14 +365,6 @@ def parse_args():
365
365
args = parser .parse_args ()
366
366
return args
367
367
368
- def word_check (word ):
369
- """ Check if a word is acceptable for the dictionary. We allow string that
370
- is acceptable as a python idenfier, plus also we allow apostrophes."""
371
- if word .isidentifier ():
372
- return True
373
- # word without apostrophe
374
- word2 = word .replace ("'" , "" )
375
- return word2 .isidentifier ()
376
368
377
369
def add_dict (enchant_dict , filename , verbose = False ):
378
370
"""Update ``enchant_dict`` spell checking dictionary with the words listed
@@ -385,8 +377,11 @@ def add_dict(enchant_dict, filename, verbose=False):
385
377
386
378
# You better not have more than 1 word in a line
387
379
for wrd in lines :
388
- if not word_check (wrd ):
389
- print ("Warning: adding word with non-alphanumeric characters to dictionary:" , wrd )
380
+ if not wrd .replace ("'" , "" ).isidentifier ():
381
+ print (
382
+ "Warning: adding word with non-alphanumeric characters to dictionary:" ,
383
+ wrd ,
384
+ )
390
385
if not enchant_dict .check (wrd ):
391
386
enchant_dict .add (wrd )
392
387
@@ -508,7 +503,10 @@ def main():
508
503
if args .vim :
509
504
print (f"vim +{ line_num } { found_file } " , file = sys .stderr )
510
505
else :
511
- print (f"file: { found_file :30} line: { line_num :3d} word: { misspelled_word } " , file = sys .stderr )
506
+ print (
507
+ f"file: { found_file :30} line: { line_num :3d} word: { misspelled_word } " ,
508
+ file = sys .stderr ,
509
+ )
512
510
513
511
previous_word = misspelled_word
514
512
0 commit comments