Skip to content

Commit

Permalink
Add Applicability to flake8_quotes fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Jun 15, 2023
1 parent 107a295 commit e24d855
Show file tree
Hide file tree
Showing 29 changed files with 88 additions and 102 deletions.
26 changes: 6 additions & 20 deletions crates/ruff/src/rules/flake8_quotes/rules/from_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +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(
fixed_contents,
range,
)));
diagnostic.set_fix(Fix::manual(Edit::range_replacement(fixed_contents, range)));
}
Some(diagnostic)
}
Expand Down Expand Up @@ -358,11 +354,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(
fixed_contents,
*range,
)));
diagnostic.set_fix(Fix::manual(Edit::range_replacement(fixed_contents, *range)));
}
diagnostics.push(diagnostic);
} else {
Expand Down Expand Up @@ -425,11 +417,8 @@ fn strings(locator: &Locator, sequence: &[TextRange], settings: &Settings) -> Ve

fixed_contents.push(quote);

#[allow(deprecated)]
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
fixed_contents,
*range,
)));
diagnostic
.set_fix(Fix::manual(Edit::range_replacement(fixed_contents, *range)));
}
diagnostics.push(diagnostic);
}
Expand All @@ -452,11 +441,8 @@ 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(
fixed_contents,
*range,
)));
diagnostic
.set_fix(Fix::manual(Edit::range_replacement(fixed_contents, *range)));
}
diagnostics.push(diagnostic);
}
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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible 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
Possible fix
1 |-""" Double quotes singleline module docstring """
1 |+''' Double quotes singleline module docstring '''
2 2 | """ this is not a docstring """
Expand Down
Loading

0 comments on commit e24d855

Please sign in to comment.