mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-02 04:48:06 +00:00
[pydocstyle] Escaped docstring in docstring (D301 ) (#12192)
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> This PR updates D301 rule to allow inclduing escaped docstring, e.g. `\"""Foo.\"""` or `\"\"\"Bar.\"\"\"`, within a docstring. Related issue: #12152 ## Test Plan Add more test cases to D301.py and update the snapshot file. <!-- How was it tested? -->
This commit is contained in:
parent
fa5b19d4b6
commit
0ba7fc63d0
3 changed files with 143 additions and 15 deletions
|
|
@ -35,3 +35,67 @@ def make_unique_pod_id(pod_id: str) -> str | None:
|
|||
|
||||
def shouldnt_add_raw_here2():
|
||||
u"Sum\\mary."
|
||||
|
||||
|
||||
def shouldnt_add_raw_for_double_quote_docstring_contains_docstring():
|
||||
"""
|
||||
This docstring contains another double-quote docstring.
|
||||
|
||||
def foo():
|
||||
\"\"\"Foo.\"\"\"
|
||||
"""
|
||||
|
||||
|
||||
def shouldnt_add_raw_for_double_quote_docstring_contains_docstring2():
|
||||
"""
|
||||
This docstring contains another double-quote docstring.
|
||||
|
||||
def bar():
|
||||
\"""Bar.\"""
|
||||
|
||||
More content here.
|
||||
"""
|
||||
|
||||
|
||||
def shouldnt_add_raw_for_single_quote_docstring_contains_docstring():
|
||||
'''
|
||||
This docstring contains another single-quote docstring.
|
||||
|
||||
def foo():
|
||||
\'\'\'Foo.\'\'\'
|
||||
|
||||
More content here.
|
||||
'''
|
||||
|
||||
|
||||
def shouldnt_add_raw_for_single_quote_docstring_contains_docstring2():
|
||||
'''
|
||||
This docstring contains another single-quote docstring.
|
||||
|
||||
def bar():
|
||||
\'''Bar.\'''
|
||||
|
||||
More content here.
|
||||
'''
|
||||
|
||||
def shouldnt_add_raw_for_docstring_contains_escaped_double_triple_quotes():
|
||||
"""
|
||||
Escaped triple quote \""" or \"\"\".
|
||||
"""
|
||||
|
||||
def shouldnt_add_raw_for_docstring_contains_escaped_single_triple_quotes():
|
||||
'''
|
||||
Escaped triple quote \''' or \'\'\'.
|
||||
'''
|
||||
|
||||
|
||||
def should_add_raw_for_single_double_quote_escape():
|
||||
"""
|
||||
This is single quote escape \".
|
||||
"""
|
||||
|
||||
|
||||
def should_add_raw_for_single_single_quote_escape():
|
||||
'''
|
||||
This is single quote escape \'.
|
||||
'''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue