Skip to content

Commit 9489804

Browse files
committed
Use correct quotes regex in capitalization formatter
1 parent 17036ce commit 9489804

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

pydocstringformatter/_formatting/formatters_default.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class CapitalizeFirstLetterFormatter(StringFormatter):
4444
"""Capitalize the first letter of the docstring if appropriate."""
4545

4646
name = "capitalize-first-letter"
47-
first_letter_re = re.compile(r"""['"]{1,3}\s*(\w)""", re.DOTALL)
47+
first_letter_re = re.compile(
48+
StringAndQuotesFormatter.quotes_regex.pattern + r"""\s*(\w)""", re.DOTALL
49+
)
4850

4951
def treat_string(self, tokeninfo: tokenize.TokenInfo, _: int) -> str:
5052
new_string = None
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def a(self):
2+
"'a.m.' or 'p.m.'"
3+
4+
def b(self):
5+
"""'a.m.' or 'p.m.'"""
6+
7+
def c(self):
8+
"'''a.m.''' or 'p.m.'"
9+
10+
def d(self):
11+
"""'''a.m.''' or 'p.m.'"""
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def a(self):
2+
"""'a.m.' or 'p.m.'."""
3+
4+
def b(self):
5+
"""'a.m.' or 'p.m.'."""
6+
7+
def c(self):
8+
"""'''a.m.''' or 'p.m.'."""
9+
10+
def d(self):
11+
"""'''a.m.''' or 'p.m.'."""

tests/data/format/quotes_type/mix_with_double_at_start.py.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def a(self):
2-
"""'A.m.' or 'p.m.'."""
2+
"""'a.m.' or 'p.m.'."""
33

44
def b(self):
55
"""'a.m.' or 'p.m.'."""

tests/data/format/quotes_type/mix_with_single_at_start.py.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def a(self):
2-
""""A.m." or "p.m."."""
2+
""""a.m." or "p.m."."""
33

44
def b(self):
55
""""a.m." or "p.m."."""

0 commit comments

Comments
 (0)