Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Applicability to flake8_quotes fixes #5130

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions crates/ruff/src/rules/flake8_quotes/rules/from_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ fn docstring(locator: &Locator, range: TextRange, settings: &Settings) -> Option
fixed_contents.push_str(&quote);
fixed_contents.push_str(string_contents);
fixed_contents.push_str(&quote);
#[allow(deprecated)]
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
fixed_contents,
range,
)));
Expand Down Expand Up @@ -358,8 +357,7 @@ fn strings(locator: &Locator, sequence: &[TextRange], settings: &Settings) -> Ve
fixed_contents.push_str(quote);
fixed_contents.push_str(string_contents);
fixed_contents.push_str(quote);
#[allow(deprecated)]
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
fixed_contents,
*range,
)));
Expand Down Expand Up @@ -425,8 +423,7 @@ fn strings(locator: &Locator, sequence: &[TextRange], settings: &Settings) -> Ve

fixed_contents.push(quote);

#[allow(deprecated)]
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
fixed_contents,
*range,
)));
Expand All @@ -452,8 +449,7 @@ fn strings(locator: &Locator, sequence: &[TextRange], settings: &Settings) -> Ve
fixed_contents.push(quote);
fixed_contents.push_str(string_contents);
fixed_contents.push(quote);
#[allow(deprecated)]
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
fixed_contents,
*range,
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ docstring_doubles.py:5:1: Q001 [*] Double quote multiline found but single quote
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
2 2 | Double quotes multiline module docstring
3 3 | """
4 4 |
Expand All @@ -41,7 +41,7 @@ docstring_doubles.py:16:5: Q001 [*] Double quote multiline found but single quot
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
13 13 | Double quotes multiline class docstring
14 14 | """
15 15 |
Expand All @@ -66,7 +66,7 @@ docstring_doubles.py:21:21: Q001 [*] Double quote multiline found but single quo
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
18 18 | """
19 19 |
20 20 | # The colon in the list indexing below is an edge case for the docstring scanner
Expand All @@ -92,7 +92,7 @@ docstring_doubles.py:30:9: Q001 [*] Double quote multiline found but single quot
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
27 27 |
28 28 | some_expression = 'hello world'
29 29 |
Expand All @@ -117,7 +117,7 @@ docstring_doubles.py:35:13: Q001 [*] Double quote multiline found but single quo
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
32 32 | """
33 33 |
34 34 | if l:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
1 1 | class SingleLineDocstrings():
2 2 | """ Double quotes single line class docstring """
3 |- """ Not a docstring """
Expand All @@ -32,7 +32,7 @@ docstring_doubles_class.py:5:23: Q001 [*] Double quote multiline found but singl
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
2 2 | """ Double quotes single line class docstring """
3 3 | """ Not a docstring """
4 4 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docstring_doubles_function.py:3:5: Q001 [*] Double quote multiline found but sin
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
1 1 | def foo():
2 2 | """function without params, single line docstring"""
3 |- """ not a docstring"""
Expand All @@ -30,7 +30,7 @@ docstring_doubles_function.py:11:5: Q001 [*] Double quote multiline found but si
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
8 8 | """
9 9 | function without params, multiline docstring
10 10 | """
Expand All @@ -51,7 +51,7 @@ docstring_doubles_function.py:15:39: Q001 [*] Double quote multiline found but s
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
12 12 | return
13 13 |
14 14 |
Expand All @@ -74,7 +74,7 @@ docstring_doubles_function.py:17:5: Q001 [*] Double quote multiline found but si
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
14 14 |
15 15 | def fun_with_params_no_docstring(a, b="""
16 16 | not a
Expand All @@ -93,7 +93,7 @@ docstring_doubles_function.py:22:5: Q001 [*] Double quote multiline found but si
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
19 19 |
20 20 |
21 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ docstring_doubles_module_multiline.py:4:1: Q001 [*] Double quote multiline found
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
1 1 | """
2 2 | Double quotes multiline module docstring
3 3 | """
Expand All @@ -38,7 +38,7 @@ docstring_doubles_module_multiline.py:9:1: Q001 [*] Double quote multiline found
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
6 6 | """
7 7 | def foo():
8 8 | pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docstring_doubles_module_singleline.py:2:1: Q001 [*] Double quote multiline foun
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
1 1 | """ Double quotes singleline module docstring """
2 |-""" this is not a docstring """
2 |+''' this is not a docstring '''
Expand All @@ -28,7 +28,7 @@ docstring_doubles_module_singleline.py:6:1: Q001 [*] Double quote multiline foun
|
= help: Replace double multiline quotes with single quotes

Suggested fix
Fix
3 3 |
4 4 | def foo():
5 5 | pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docstring_singles.py:1:1: Q002 [*] Single quote docstring found but double quote
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
1 |-'''
1 |+"""
2 2 | Single quotes multiline module docstring
Expand All @@ -36,7 +36,7 @@ docstring_singles.py:14:5: Q002 [*] Single quote docstring found but double quot
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
11 11 | class Cls(MakeKlass('''
12 12 | class params \t not a docstring
13 13 | ''')):
Expand All @@ -63,7 +63,7 @@ docstring_singles.py:26:9: Q002 [*] Single quote docstring found but double quot
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
23 23 | def f(self, bar='''
24 24 | definitely not a docstring''',
25 25 | val=l[Cls():3]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docstring_singles_class.py:2:5: Q002 [*] Single quote docstring found but double
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
1 1 | class SingleLineDocstrings():
2 |- ''' Double quotes single line class docstring '''
2 |+ """ Double quotes single line class docstring """
Expand All @@ -27,7 +27,7 @@ docstring_singles_class.py:6:9: Q002 [*] Single quote docstring found but double
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
3 3 | ''' Not a docstring '''
4 4 |
5 5 | def foo(self, bar='''not a docstring'''):
Expand All @@ -46,7 +46,7 @@ docstring_singles_class.py:9:29: Q002 [*] Single quote docstring found but doubl
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
6 6 | ''' Double quotes single line method docstring'''
7 7 | pass
8 8 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docstring_singles_function.py:2:5: Q002 [*] Single quote docstring found but dou
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
1 1 | def foo():
2 |- '''function without params, single line docstring'''
2 |+ """function without params, single line docstring"""
Expand All @@ -32,7 +32,7 @@ docstring_singles_function.py:8:5: Q002 [*] Single quote docstring found but dou
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
5 5 |
6 6 |
7 7 | def foo2():
Expand All @@ -53,7 +53,7 @@ docstring_singles_function.py:27:5: Q002 [*] Single quote docstring found but do
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
24 24 |
25 25 |
26 26 | def function_with_single_docstring(a):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docstring_singles_module_multiline.py:1:1: Q002 [*] Single quote docstring found
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
1 |-'''
1 |+"""
2 2 | Double quotes multiline module docstring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ docstring_singles_module_singleline.py:1:1: Q002 [*] Single quote docstring foun
|
= help: Replace single quotes docstring with double quotes

Suggested fix
Fix
1 |-''' Double quotes singleline module docstring '''
1 |+""" Double quotes singleline module docstring """
2 2 | ''' this is not a docstring '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quote
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
1 |-"""
1 |+'''
2 2 | Double quotes multiline module docstring
Expand All @@ -35,7 +35,7 @@ docstring_doubles.py:12:5: Q002 [*] Double quote docstring found but single quot
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
9 9 | l = []
10 10 |
11 11 | class Cls:
Expand All @@ -62,7 +62,7 @@ docstring_doubles.py:24:9: Q002 [*] Double quote docstring found but single quot
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
21 21 | def f(self, bar="""
22 22 | definitely not a docstring""",
23 23 | val=l[Cls():3]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docstring_doubles_class.py:2:5: Q002 [*] Double quote docstring found but single
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
1 1 | class SingleLineDocstrings():
2 |- """ Double quotes single line class docstring """
2 |+ ''' Double quotes single line class docstring '''
Expand All @@ -27,7 +27,7 @@ docstring_doubles_class.py:6:9: Q002 [*] Double quote docstring found but single
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
3 3 | """ Not a docstring """
4 4 |
5 5 | def foo(self, bar="""not a docstring"""):
Expand All @@ -46,7 +46,7 @@ docstring_doubles_class.py:9:29: Q002 [*] Double quote docstring found but singl
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
6 6 | """ Double quotes single line method docstring"""
7 7 | pass
8 8 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docstring_doubles_function.py:2:5: Q002 [*] Double quote docstring found but sin
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
1 1 | def foo():
2 |- """function without params, single line docstring"""
2 |+ '''function without params, single line docstring'''
Expand All @@ -32,7 +32,7 @@ docstring_doubles_function.py:8:5: Q002 [*] Double quote docstring found but sin
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
5 5 |
6 6 |
7 7 | def foo2():
Expand All @@ -53,7 +53,7 @@ docstring_doubles_function.py:27:5: Q002 [*] Double quote docstring found but si
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
24 24 |
25 25 |
26 26 | def function_with_single_docstring(a):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docstring_doubles_module_multiline.py:1:1: Q002 [*] Double quote docstring found
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
1 |-"""
1 |+'''
2 2 | Double quotes multiline module docstring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ docstring_doubles_module_singleline.py:1:1: Q002 [*] Double quote docstring foun
|
= help: Replace double quotes docstring with single quotes

Suggested fix
Fix
1 |-""" Double quotes singleline module docstring """
1 |+''' Double quotes singleline module docstring '''
2 2 | """ this is not a docstring """
Expand Down
Loading