Simpler dictionary parsing (#2986)
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index 19999cd..800e12c 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py
@@ -637,19 +637,14 @@ if key in ignore_words: continue data = data.strip() - fix = data.rfind(",") - if fix < 0: + if "," in data: + fix = False + data, reason = data.rsplit(",", 1) + reason = reason.lstrip() + else: fix = True reason = "" - elif fix == (len(data) - 1): - data = data[:fix] - reason = "" - fix = False - else: - reason = data[fix + 1 :].strip() - data = data[:fix] - fix = False misspellings[key] = Misspelling(data, fix, reason)