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"""):
|
""" """docstring"""):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def fun_with_params_no_docstring2(a, b=c[foo():], c=\
|
def fun_with_params_no_docstring2(a, b=c[foo():], c=\
|
||||||
""" not a docstring """):
|
""" not a docstring """):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def function_with_single_docstring(a):
|
||||||
|
"Single line docstring"
|
||||||
|
|
||||||
|
|
||||||
|
def double_inside_single(a):
|
||||||
|
'Double inside "single "'
|
||||||
|
|
|
@ -17,7 +17,15 @@ def fun_with_params_no_docstring(a, b='''
|
||||||
''' '''docstring'''):
|
''' '''docstring'''):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def fun_with_params_no_docstring2(a, b=c[foo():], c=\
|
def fun_with_params_no_docstring2(a, b=c[foo():], c=\
|
||||||
''' not a docstring '''):
|
''' not a docstring '''):
|
||||||
pass
|
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 {
|
fn good_docstring(quote: &Quote) -> &str {
|
||||||
match quote {
|
match quote {
|
||||||
Quote::Single => "'''",
|
Quote::Single => "'",
|
||||||
Quote::Double => "\"\"\"",
|
Quote::Double => "\"",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: src/flake8_quotes/mod.rs
|
source: src/flake8_quotes/mod.rs
|
||||||
expression: checks
|
expression: diagnostics
|
||||||
---
|
---
|
||||||
- kind:
|
- kind:
|
||||||
BadQuotesMultilineString: single
|
BadQuotesMultilineString: single
|
||||||
|
@ -45,10 +45,10 @@ expression: checks
|
||||||
- kind:
|
- kind:
|
||||||
BadQuotesMultilineString: single
|
BadQuotesMultilineString: single
|
||||||
location:
|
location:
|
||||||
row: 21
|
row: 22
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 21
|
row: 22
|
||||||
column: 27
|
column: 27
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: src/flake8_quotes/mod.rs
|
source: src/flake8_quotes/mod.rs
|
||||||
expression: checks
|
expression: diagnostics
|
||||||
---
|
---
|
||||||
- kind:
|
- kind:
|
||||||
BadQuotesDocstring: double
|
BadQuotesDocstring: double
|
||||||
|
@ -22,4 +22,14 @@ expression: checks
|
||||||
column: 7
|
column: 7
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
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
|
source: src/flake8_quotes/mod.rs
|
||||||
expression: checks
|
expression: diagnostics
|
||||||
---
|
---
|
||||||
- kind:
|
- kind:
|
||||||
BadQuotesDocstring: single
|
BadQuotesDocstring: single
|
||||||
|
@ -22,4 +22,14 @@ expression: checks
|
||||||
column: 7
|
column: 7
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
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
|
source: src/flake8_quotes/mod.rs
|
||||||
expression: checks
|
expression: diagnostics
|
||||||
---
|
---
|
||||||
- kind:
|
- kind:
|
||||||
BadQuotesMultilineString: double
|
BadQuotesMultilineString: double
|
||||||
|
@ -45,10 +45,10 @@ expression: checks
|
||||||
- kind:
|
- kind:
|
||||||
BadQuotesMultilineString: double
|
BadQuotesMultilineString: double
|
||||||
location:
|
location:
|
||||||
row: 21
|
row: 22
|
||||||
column: 4
|
column: 4
|
||||||
end_location:
|
end_location:
|
||||||
row: 21
|
row: 22
|
||||||
column: 27
|
column: 27
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue