Skip to content

Commit 2b8f740

Browse files
authored
Merge pull request #55 from dave3d/ImproveMessaging
Improved misspelled word message; warn about bad dictionary words
2 parents c1609e7 + bc4c30a commit 2b8f740

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

comment_spell_check.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ def add_dict(enchant_dict, filename, verbose=False):
377377

378378
# You better not have more than 1 word in a line
379379
for wrd in lines:
380+
if not wrd.replace("'", "").isidentifier():
381+
print(
382+
"Warning: adding word with non-alphanumeric characters to dictionary:",
383+
wrd,
384+
)
380385
if not enchant_dict.check(wrd):
381386
enchant_dict.add(wrd)
382387

@@ -482,22 +487,26 @@ def main():
482487
# Done spell checking. Print out all the words not found in our dictionary.
483488
#
484489
if not args.miss:
485-
print("\nBad words\n")
490+
print("\nBad words")
486491

487492
previous_word = ""
493+
print("")
488494

489495
for misspelled_word, found_file, line_num in bad_words:
490-
if misspelled_word != previous_word:
496+
if misspelled_word != previous_word and args.first:
491497
print(f"\n{misspelled_word}:")
492498

493499
if (misspelled_word == previous_word) and args.first:
494500
sys.stderr.write(".")
495501
continue
496502

497503
if args.vim:
498-
print(f" vim +{line_num} {found_file}", file=sys.stderr)
504+
print(f"vim +{line_num} {found_file}", file=sys.stderr)
499505
else:
500-
print(f" {found_file}, {line_num}", file=sys.stderr)
506+
print(
507+
f"file: {found_file:30} line: {line_num:3d} word: {misspelled_word}",
508+
file=sys.stderr,
509+
)
501510

502511
previous_word = misspelled_word
503512

0 commit comments

Comments
 (0)