Skip to content

Commit

Permalink
Handle abbreviation 'etc.' (et cetera) (#273)
Browse files Browse the repository at this point in the history
(Also add a missed comma in the test parametrization)

Co-authored-by: Josef Kemetmüller <josef.kemetmueller@ims.co.at>
Co-authored-by: Doyle Rowland <doyle.rowland@reliaqual.com>
  • Loading branch information
3 people authored Jul 31, 2024
1 parent 3f92ff6 commit c62abff
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 c62abff

Please sign in to comment.