mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
Avoid erroneous Q002 error message for single-quote docstrings (#1777)
Fixes #1775. Before implementing your solution I thought of a slightly simpler one. However, it will let this function pass: ``` def double_inside_single(a): 'Double inside "single "' ``` If we want function to pass, my implementation works. But if we do not, then I can go with how you suggested I implemented this (I left how I would begin to handle it commented out). The bottom of the flake8-quotes documentation seems to suggest that this should pass: https://pypi.org/project/flake8-quotes/ Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
588399e415
commit
329946f162
7 changed files with 48 additions and 11 deletions
|
@ -17,6 +17,15 @@ def fun_with_params_no_docstring(a, b="""
|
|||
""" """docstring"""):
|
||||
pass
|
||||
|
||||
|
||||
def fun_with_params_no_docstring2(a, b=c[foo():], c=\
|
||||
""" not a docstring """):
|
||||
pass
|
||||
|
||||
|
||||
def function_with_single_docstring(a):
|
||||
"Single line docstring"
|
||||
|
||||
|
||||
def double_inside_single(a):
|
||||
'Double inside "single "'
|
||||
|
|
|
@ -13,11 +13,19 @@ def foo2():
|
|||
|
||||
|
||||
def fun_with_params_no_docstring(a, b='''
|
||||
not a
|
||||
not a
|
||||
''' '''docstring'''):
|
||||
pass
|
||||
|
||||
|
||||
def fun_with_params_no_docstring2(a, b=c[foo():], c=\
|
||||
''' not a docstring '''):
|
||||
pass
|
||||
|
||||
|
||||
def function_with_single_docstring(a):
|
||||
'Single line docstring'
|
||||
|
||||
|
||||
def double_inside_single(a):
|
||||
"Double inside 'single '"
|
||||
|
|
|
@ -36,8 +36,8 @@ fn good_multiline_ending(quote: &Quote) -> &str {
|
|||
|
||||
fn good_docstring(quote: &Quote) -> &str {
|
||||
match quote {
|
||||
Quote::Single => "'''",
|
||||
Quote::Double => "\"\"\"",
|
||||
Quote::Single => "'",
|
||||
Quote::Double => "\"",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
source: src/flake8_quotes/mod.rs
|
||||
expression: checks
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
BadQuotesMultilineString: single
|
||||
|
@ -45,10 +45,10 @@ expression: checks
|
|||
- kind:
|
||||
BadQuotesMultilineString: single
|
||||
location:
|
||||
row: 21
|
||||
row: 22
|
||||
column: 4
|
||||
end_location:
|
||||
row: 21
|
||||
row: 22
|
||||
column: 27
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
source: src/flake8_quotes/mod.rs
|
||||
expression: checks
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
BadQuotesDocstring: double
|
||||
|
@ -22,4 +22,14 @@ expression: checks
|
|||
column: 7
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
BadQuotesDocstring: double
|
||||
location:
|
||||
row: 27
|
||||
column: 4
|
||||
end_location:
|
||||
row: 27
|
||||
column: 27
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
source: src/flake8_quotes/mod.rs
|
||||
expression: checks
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
BadQuotesDocstring: single
|
||||
|
@ -22,4 +22,14 @@ expression: checks
|
|||
column: 7
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
BadQuotesDocstring: single
|
||||
location:
|
||||
row: 27
|
||||
column: 4
|
||||
end_location:
|
||||
row: 27
|
||||
column: 27
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
source: src/flake8_quotes/mod.rs
|
||||
expression: checks
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
BadQuotesMultilineString: double
|
||||
|
@ -45,10 +45,10 @@ expression: checks
|
|||
- kind:
|
||||
BadQuotesMultilineString: double
|
||||
location:
|
||||
row: 21
|
||||
row: 22
|
||||
column: 4
|
||||
end_location:
|
||||
row: 21
|
||||
row: 22
|
||||
column: 27
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue