Skip to content

Commit d1afa18

Browse files
Simpler dictionary parsing (#2986)
1 parent 9c580df commit d1afa18

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

codespell_lib/_codespell.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -637,19 +637,14 @@ def build_dict(
637637
if key in ignore_words:
638638
continue
639639
data = data.strip()
640-
fix = data.rfind(",")
641640

642-
if fix < 0:
643-
fix = True
644-
reason = ""
645-
elif fix == (len(data) - 1):
646-
data = data[:fix]
647-
reason = ""
641+
if "," in data:
648642
fix = False
643+
data, reason = data.rsplit(",", 1)
644+
reason = reason.lstrip()
649645
else:
650-
reason = data[fix + 1 :].strip()
651-
data = data[:fix]
652-
fix = False
646+
fix = True
647+
reason = ""
653648

654649
misspellings[key] = Misspelling(data, fix, reason)
655650

0 commit comments

Comments
 (0)