@@ -365,14 +365,6 @@ def parse_args():
365365 args = parser .parse_args ()
366366 return args
367367
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 ()
376368
377369def add_dict (enchant_dict , filename , verbose = False ):
378370 """Update ``enchant_dict`` spell checking dictionary with the words listed
@@ -385,8 +377,11 @@ def add_dict(enchant_dict, filename, verbose=False):
385377
386378 # You better not have more than 1 word in a line
387379 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+ )
390385 if not enchant_dict .check (wrd ):
391386 enchant_dict .add (wrd )
392387
@@ -508,7 +503,10 @@ def main():
508503 if args .vim :
509504 print (f"vim +{ line_num } { found_file } " , file = sys .stderr )
510505 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+ )
512510
513511 previous_word = misspelled_word
514512
0 commit comments