@@ -65,6 +65,7 @@ class FinalPeriodFormatter(StringAndQuotesFormatter):
65
65
"""Add a period to the end of single line docstrings and summaries."""
66
66
67
67
name = "final-period"
68
+ END_OF_SENTENCE_PUNCTUATION = {"." , "?" , "!" , "‽" }
68
69
69
70
def _treat_string (
70
71
self ,
@@ -76,7 +77,10 @@ def _treat_string(
76
77
"""Add a period to the end of single-line docstrings and summaries."""
77
78
# Handle single line docstrings
78
79
if not tokeninfo .string .count ("\n " ):
79
- if tokeninfo .string [- quotes_length - 1 ] not in {"." , "?" , "!" , "‽" }:
80
+ if (
81
+ tokeninfo .string [- quotes_length - 1 ]
82
+ not in self .END_OF_SENTENCE_PUNCTUATION
83
+ ):
80
84
return tokeninfo .string [:- quotes_length ] + "." + quotes
81
85
# Handle multi-line docstrings
82
86
else :
@@ -88,7 +92,7 @@ def _treat_string(
88
92
return tokeninfo .string
89
93
# If second line is empty we're dealing with a summary
90
94
if lines [1 ] == "" :
91
- if lines [0 ][- 1 ] not in { "." , "?" , "!" , "‽" } :
95
+ if lines [0 ][- 1 ] not in self . END_OF_SENTENCE_PUNCTUATION :
92
96
return lines [0 ] + ".\n " + "\n " .join (lines [1 :])
93
97
# TODO(#26): Handle multi-line docstrings that do not have a summary
94
98
# This is obviously dependent on whether 'pydocstringformatter' will
0 commit comments