parent
1648ac5180
commit
abe57e3d92
@ -21,6 +21,7 @@
|
|||||||
multiple lines (#3899)
|
multiple lines (#3899)
|
||||||
- Magic trailing commas are now respected in return types. (#3916)
|
- Magic trailing commas are now respected in return types. (#3916)
|
||||||
- Require one empty line after module-level docstrings. (#3932)
|
- Require one empty line after module-level docstrings. (#3932)
|
||||||
|
- Treat raw triple-quoted strings as docstrings (#3947)
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
|
@ -193,11 +193,16 @@ def is_class_paren_empty(self) -> bool:
|
|||||||
@property
|
@property
|
||||||
def is_triple_quoted_string(self) -> bool:
|
def is_triple_quoted_string(self) -> bool:
|
||||||
"""Is the line a triple quoted string?"""
|
"""Is the line a triple quoted string?"""
|
||||||
return (
|
if not self or self.leaves[0].type != token.STRING:
|
||||||
bool(self)
|
return False
|
||||||
and self.leaves[0].type == token.STRING
|
value = self.leaves[0].value
|
||||||
and self.leaves[0].value.startswith(('"""', "'''"))
|
if value.startswith(('"""', "'''")):
|
||||||
)
|
return True
|
||||||
|
if Preview.accept_raw_docstrings in self.mode and value.startswith(
|
||||||
|
("r'''", 'r"""', "R'''", 'R"""')
|
||||||
|
):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def opens_block(self) -> bool:
|
def opens_block(self) -> bool:
|
||||||
|
@ -188,6 +188,7 @@ class Preview(Enum):
|
|||||||
dummy_implementations = auto()
|
dummy_implementations = auto()
|
||||||
walrus_subscript = auto()
|
walrus_subscript = auto()
|
||||||
module_docstring_newlines = auto()
|
module_docstring_newlines = auto()
|
||||||
|
accept_raw_docstrings = auto()
|
||||||
fix_power_op_line_length = auto()
|
fix_power_op_line_length = auto()
|
||||||
|
|
||||||
|
|
||||||
|
32
tests/data/raw_docstring.py
Normal file
32
tests/data/raw_docstring.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# flags: --preview --skip-string-normalization
|
||||||
|
class C:
|
||||||
|
|
||||||
|
r"""Raw"""
|
||||||
|
|
||||||
|
def f():
|
||||||
|
|
||||||
|
r"""Raw"""
|
||||||
|
|
||||||
|
class SingleQuotes:
|
||||||
|
|
||||||
|
|
||||||
|
r'''Raw'''
|
||||||
|
|
||||||
|
class UpperCaseR:
|
||||||
|
R"""Raw"""
|
||||||
|
|
||||||
|
# output
|
||||||
|
class C:
|
||||||
|
r"""Raw"""
|
||||||
|
|
||||||
|
|
||||||
|
def f():
|
||||||
|
r"""Raw"""
|
||||||
|
|
||||||
|
|
||||||
|
class SingleQuotes:
|
||||||
|
r'''Raw'''
|
||||||
|
|
||||||
|
|
||||||
|
class UpperCaseR:
|
||||||
|
R"""Raw"""
|
Loading…
Reference in New Issue
Block a user