Skip to content

Commit

Permalink
Handle abbreviation 'etc.' (et cetera)
Browse files Browse the repository at this point in the history
(Also add a missed comma in the test parametrization)
  • Loading branch information
Josef Kemetmüller committed Jan 9, 2024
1 parent 504107b commit 61f6649
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/docformatter/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def split_first_sentence(text):

sentence += previous_delimiter + word

if sentence.endswith(("e.g.", "i.e.", "Dr.", "Mr.", "Mrs.", "Ms.")):
if sentence.endswith(("e.g.", "i.e.", "etc.", "Dr.", "Mr.", "Mrs.", "Ms.")):
# Ignore false end of sentence.
pass
elif sentence.endswith((".", "?", "!")):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_string_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ def test_split_summary_and_description_without_punctuation(self):
def test_split_summary_and_description_with_abbreviation(self):
""""""
for text in [
"Test e.g. now" "Test i.e. now",
"Test e.g. now",
"Test foo, bar, etc. now",
"Test i.e. now",
"Test Dr. now",
"Test Mr. now",
"Test Mrs. now",
Expand Down

0 comments on commit 61f6649

Please sign in to comment.