File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717
1818<!-- Changes that affect Black's preview style -->
1919
20+ - Single-character closing docstring quotes are no longer moved to their own line as
21+ this is invalid. This was a bug introduced in version 22.6.0. (#3166 )
22+
2023### _ Blackd_
2124
2225<!-- Changes to blackd -->
Original file line number Diff line number Diff line change @@ -330,13 +330,14 @@ def visit_STRING(self, leaf: Leaf) -> Iterator[Line]:
330330 # We could enforce triple quotes at this point.
331331 quote = quote_char * quote_len
332332
333- if Preview .long_docstring_quotes_on_newline in self .mode :
333+ # It's invalid to put closing single-character quotes on a new line.
334+ if Preview .long_docstring_quotes_on_newline in self .mode and quote_len == 3 :
334335 # We need to find the length of the last line of the docstring
335336 # to find if we can add the closing quotes to the line without
336337 # exceeding the maximum line length.
337338 # If docstring is one line, then we need to add the length
338- # of the indent, prefix, and starting quotes. Ending quote are
339- # handled later
339+ # of the indent, prefix, and starting quotes. Ending quotes are
340+ # handled later.
340341 lines = docstring .splitlines ()
341342 last_line_length = len (lines [- 1 ]) if docstring else 0
342343
Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ def multiline_docstring_at_line_limit_with_prefix():
4242 second line----------------------------------------------------------------------"""
4343
4444
45+ def single_quote_docstring_over_line_limit ():
46+ "We do not want to put the closing quote on a new line as that is invalid (see GH-3141)."
47+
48+
49+ def single_quote_docstring_over_line_limit2 ():
50+ 'We do not want to put the closing quote on a new line as that is invalid (see GH-3141).'
51+
52+
4553# output
4654
4755
@@ -87,3 +95,11 @@ def multiline_docstring_at_line_limit_with_prefix():
8795 f"""first line----------------------------------------------------------------------
8896
8997 second line----------------------------------------------------------------------"""
98+
99+
100+ def single_quote_docstring_over_line_limit ():
101+ "We do not want to put the closing quote on a new line as that is invalid (see GH-3141)."
102+
103+
104+ def single_quote_docstring_over_line_limit2 ():
105+ "We do not want to put the closing quote on a new line as that is invalid (see GH-3141)."
You can’t perform that action at this time.
0 commit comments