Update applicability messages for clarity in tests (#8541)

These names are only ever displayed internally right now and we could be
clearer in our test snapshots.

The diff is kind of scary because all of the tests fixtures are updated.
This commit is contained in:
Zanie Blue 2023-11-07 10:11:43 -06:00 committed by GitHub
parent 7dabc4598b
commit 7873ca38e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
523 changed files with 3085 additions and 3086 deletions

View file

@ -12,7 +12,7 @@ use crate::edit::Edit;
pub enum Applicability {
/// The fix is unsafe and should only be displayed for manual application by the user.
/// The fix is likely to be incorrect or the resulting code may have invalid syntax.
Display,
DisplayOnly,
/// The fix is unsafe and should only be applied with user opt-in.
/// The fix may be what the user intended, but it is uncertain; the resulting code will have valid syntax.
@ -87,22 +87,22 @@ impl Fix {
}
}
/// Create a new [`Fix`] that should only [display](Applicability::Display) and not apply from an [`Edit`] element .
pub fn display_edit(edit: Edit) -> Self {
/// Create a new [`Fix`] that should only [display](Applicability::DisplayOnly) and not apply from an [`Edit`] element .
pub fn display_only_edit(edit: Edit) -> Self {
Self {
edits: vec![edit],
applicability: Applicability::Display,
applicability: Applicability::DisplayOnly,
isolation_level: IsolationLevel::default(),
}
}
/// Create a new [`Fix`] that should only [display](Applicability::Display) and not apply from multiple [`Edit`] elements.
pub fn display_edits(edit: Edit, rest: impl IntoIterator<Item = Edit>) -> Self {
/// Create a new [`Fix`] that should only [display](Applicability::DisplayOnly) and not apply from multiple [`Edit`] elements.
pub fn display_only_edits(edit: Edit, rest: impl IntoIterator<Item = Edit>) -> Self {
let mut edits: Vec<Edit> = std::iter::once(edit).chain(rest).collect();
edits.sort_by_key(|edit| (edit.start(), edit.end()));
Self {
edits,
applicability: Applicability::Display,
applicability: Applicability::DisplayOnly,
isolation_level: IsolationLevel::default(),
}
}

View file

@ -54,9 +54,9 @@ impl Display for Diff<'_> {
let message = match self.fix.applicability() {
// TODO(zanieb): Adjust this messaging once it's user-facing
Applicability::Safe => "Fix",
Applicability::Unsafe => "Suggested fix",
Applicability::Display => "Possible fix",
Applicability::Safe => "Safe fix",
Applicability::Unsafe => "Unsafe fix",
Applicability::DisplayOnly => "Display-only fix",
};
writeln!(f, " {}", message.blue())?;

View file

@ -66,7 +66,7 @@ pub(crate) fn commented_out_code(
if is_standalone_comment(line) && comment_contains_code(line, &settings.task_tags[..]) {
let mut diagnostic = Diagnostic::new(CommentedOutCode, *range);
diagnostic.set_fix(Fix::display_edit(Edit::range_deletion(
diagnostic.set_fix(Fix::display_only_edit(Edit::range_deletion(
locator.full_lines_range(*range),
)));
diagnostics.push(diagnostic);

View file

@ -10,7 +10,7 @@ ERA001.py:1:1: ERA001 Found commented-out code
|
= help: Remove commented-out code
Possible fix
Display-only fix
1 |-#import os
2 1 | # from foo import junk
3 2 | #a = 3
@ -26,7 +26,7 @@ ERA001.py:2:1: ERA001 Found commented-out code
|
= help: Remove commented-out code
Possible fix
Display-only fix
1 1 | #import os
2 |-# from foo import junk
3 2 | #a = 3
@ -44,7 +44,7 @@ ERA001.py:3:1: ERA001 Found commented-out code
|
= help: Remove commented-out code
Possible fix
Display-only fix
1 1 | #import os
2 2 | # from foo import junk
3 |-#a = 3
@ -63,7 +63,7 @@ ERA001.py:5:1: ERA001 Found commented-out code
|
= help: Remove commented-out code
Possible fix
Display-only fix
2 2 | # from foo import junk
3 3 | #a = 3
4 4 | a = 4
@ -82,7 +82,7 @@ ERA001.py:13:5: ERA001 Found commented-out code
|
= help: Remove commented-out code
Possible fix
Display-only fix
10 10 |
11 11 | # This is a real comment.
12 12 | # # This is a (nested) comment.
@ -100,7 +100,7 @@ ERA001.py:21:5: ERA001 Found commented-out code
|
= help: Remove commented-out code
Possible fix
Display-only fix
18 18 |
19 19 | class A():
20 20 | pass
@ -120,7 +120,7 @@ ERA001.py:26:5: ERA001 Found commented-out code
|
= help: Remove commented-out code
Possible fix
Display-only fix
23 23 |
24 24 | dictionary = {
25 25 | # "key1": 123, # noqa: ERA001
@ -139,7 +139,7 @@ ERA001.py:27:5: ERA001 Found commented-out code
|
= help: Remove commented-out code
Possible fix
Display-only fix
24 24 | dictionary = {
25 25 | # "key1": 123, # noqa: ERA001
26 26 | # "key2": 456,

View file

@ -252,7 +252,7 @@ annotation_presence.py:159:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
156 156 |
157 157 | class Foo:
158 158 | @decorator()
@ -272,7 +272,7 @@ annotation_presence.py:165:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
162 162 |
163 163 | # Regression test for: https://github.com/astral-sh/ruff/issues/7711
164 164 | class Class:

View file

@ -11,7 +11,7 @@ mypy_init_return.py:5:9: ANN204 [*] Missing return type annotation for special m
|
= help: Add `None` return type
Suggested fix
Unsafe fix
2 2 |
3 3 | # Error
4 4 | class Foo:
@ -31,7 +31,7 @@ mypy_init_return.py:11:9: ANN204 [*] Missing return type annotation for special
|
= help: Add `None` return type
Suggested fix
Unsafe fix
8 8 |
9 9 | # Error
10 10 | class Foo:
@ -59,7 +59,7 @@ mypy_init_return.py:47:9: ANN204 [*] Missing return type annotation for special
|
= help: Add `None` return type
Suggested fix
Unsafe fix
44 44 | # Error used to be ok for a moment since the mere presence
45 45 | # of a vararg falsely indicated that the function has a typed argument.
46 46 | class Foo:

View file

@ -10,7 +10,7 @@ simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for speci
|
= help: Add `None` return type
Suggested fix
Unsafe fix
1 1 | class Foo:
2 |- def __str__(self):
2 |+ def __str__(self) -> str:
@ -28,7 +28,7 @@ simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for speci
|
= help: Add `None` return type
Suggested fix
Unsafe fix
2 2 | def __str__(self):
3 3 | ...
4 4 |
@ -48,7 +48,7 @@ simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for speci
|
= help: Add `None` return type
Suggested fix
Unsafe fix
5 5 | def __repr__(self):
6 6 | ...
7 7 |
@ -68,7 +68,7 @@ simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
8 8 | def __len__(self):
9 9 | ...
10 10 |
@ -88,7 +88,7 @@ simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
11 11 | def __length_hint__(self):
12 12 | ...
13 13 |
@ -108,7 +108,7 @@ simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
14 14 | def __init__(self):
15 15 | ...
16 16 |
@ -128,7 +128,7 @@ simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
17 17 | def __del__(self):
18 18 | ...
19 19 |
@ -148,7 +148,7 @@ simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
20 20 | def __bool__(self):
21 21 | ...
22 22 |
@ -168,7 +168,7 @@ simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
23 23 | def __bytes__(self):
24 24 | ...
25 25 |
@ -188,7 +188,7 @@ simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
26 26 | def __format__(self, format_spec):
27 27 | ...
28 28 |
@ -208,7 +208,7 @@ simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
29 29 | def __contains__(self, item):
30 30 | ...
31 31 |
@ -228,7 +228,7 @@ simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
32 32 | def __complex__(self):
33 33 | ...
34 34 |
@ -248,7 +248,7 @@ simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
35 35 | def __int__(self):
36 36 | ...
37 37 |
@ -268,7 +268,7 @@ simple_magic_methods.py:41:9: ANN204 [*] Missing return type annotation for spec
|
= help: Add `None` return type
Suggested fix
Unsafe fix
38 38 | def __float__(self):
39 39 | ...
40 40 |

View file

@ -12,7 +12,7 @@ B004.py:3:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is
|
= help: Replace with `callable()`
Fix
Safe fix
1 1 | def this_is_a_bug():
2 2 | o = object()
3 |- if hasattr(o, "__call__"):

View file

@ -12,7 +12,7 @@ B006_1.py:3:22: B006 [*] Do not use mutable data structures for argument default
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
1 1 | # Docstring followed by a newline
2 2 |
3 |-def foobar(foor, bar={}):

View file

@ -12,7 +12,7 @@ B006_2.py:4:22: B006 [*] Do not use mutable data structures for argument default
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
1 1 | # Docstring followed by whitespace with no newline
2 2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155
3 3 |

View file

@ -10,7 +10,7 @@ B006_3.py:4:22: B006 [*] Do not use mutable data structures for argument default
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
1 1 | # Docstring with no newline
2 2 |
3 3 |

View file

@ -10,7 +10,7 @@ B006_4.py:7:26: B006 [*] Do not use mutable data structures for argument default
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
4 4 |
5 5 |
6 6 | class FormFeedIndent:

View file

@ -9,7 +9,7 @@ B006_5.py:5:49: B006 [*] Do not use mutable data structures for argument default
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
2 2 | # https://github.com/astral-sh/ruff/issues/7616
3 3 |
4 4 |
@ -30,7 +30,7 @@ B006_5.py:9:61: B006 [*] Do not use mutable data structures for argument default
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
6 6 | import os
7 7 |
8 8 |
@ -53,7 +53,7 @@ B006_5.py:15:50: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
12 12 | return 2
13 13 |
14 14 |
@ -76,7 +76,7 @@ B006_5.py:21:54: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
18 18 | import itertools
19 19 |
20 20 |
@ -98,7 +98,7 @@ B006_5.py:25:55: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
22 22 | from os import path
23 23 |
24 24 |
@ -121,7 +121,7 @@ B006_5.py:30:66: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
27 27 | from sys import version_info
28 28 |
29 29 |
@ -144,7 +144,7 @@ B006_5.py:35:59: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
32 32 | from sys import version_info
33 33 |
34 34 |
@ -167,7 +167,7 @@ B006_5.py:40:49: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
37 37 | import os
38 38 |
39 39 |
@ -190,7 +190,7 @@ B006_5.py:45:49: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
42 42 | import os; import sys
43 43 |
44 44 |
@ -212,7 +212,7 @@ B006_5.py:50:49: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
47 47 | import os; import sys; x = 1
48 48 |
49 49 |
@ -234,7 +234,7 @@ B006_5.py:55:49: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
52 52 | import os; import sys
53 53 |
54 54 |
@ -255,7 +255,7 @@ B006_5.py:59:49: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
56 56 | import os; import sys
57 57 |
58 58 |
@ -275,7 +275,7 @@ B006_5.py:63:49: B006 [*] Do not use mutable data structures for argument defaul
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
60 60 | import os; import sys; x = 1
61 61 |
62 62 |

View file

@ -11,7 +11,7 @@ B006_6.py:4:22: B006 [*] Do not use mutable data structures for argument default
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
1 1 | # Import followed by whitespace with no newline
2 2 | # Same as B006_2.py, but import instead of docstring
3 3 |

View file

@ -11,7 +11,7 @@ B006_7.py:4:22: B006 [*] Do not use mutable data structures for argument default
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
1 1 | # Import with no newline
2 2 | # Same as B006_3.py, but import instead of docstring
3 3 |

View file

@ -9,7 +9,7 @@ B006_B008.py:63:25: B006 [*] Do not use mutable data structures for argument def
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
60 60 | # Flag mutable literals/comprehensions
61 61 |
62 62 |
@ -29,7 +29,7 @@ B006_B008.py:67:30: B006 [*] Do not use mutable data structures for argument def
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
64 64 | ...
65 65 |
66 66 |
@ -51,7 +51,7 @@ B006_B008.py:73:52: B006 [*] Do not use mutable data structures for argument def
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
70 70 |
71 71 | class Foo:
72 72 | @staticmethod
@ -74,7 +74,7 @@ B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument def
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
74 74 | pass
75 75 |
76 76 |
@ -105,7 +105,7 @@ B006_B008.py:85:20: B006 [*] Do not use mutable data structures for argument def
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
82 82 | def single_line_func_wrong(value = {}): ...
83 83 |
84 84 |
@ -125,7 +125,7 @@ B006_B008.py:89:20: B006 [*] Do not use mutable data structures for argument def
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
86 86 | ...
87 87 |
88 88 |
@ -145,7 +145,7 @@ B006_B008.py:93:32: B006 [*] Do not use mutable data structures for argument def
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
90 90 | ...
91 91 |
92 92 |
@ -165,7 +165,7 @@ B006_B008.py:97:26: B006 [*] Do not use mutable data structures for argument def
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
94 94 | ...
95 95 |
96 96 |
@ -186,7 +186,7 @@ B006_B008.py:102:46: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
99 99 |
100 100 |
101 101 | # N.B. we're also flagging the function call in the comprehension
@ -206,7 +206,7 @@ B006_B008.py:106:46: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
103 103 | pass
104 104 |
105 105 |
@ -226,7 +226,7 @@ B006_B008.py:110:45: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
107 107 | pass
108 108 |
109 109 |
@ -246,7 +246,7 @@ B006_B008.py:114:33: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
111 111 | pass
112 112 |
113 113 |
@ -268,7 +268,7 @@ B006_B008.py:239:20: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
236 236 |
237 237 | # B006 and B008
238 238 | # We should handle arbitrary nesting of these B008.
@ -290,7 +290,7 @@ B006_B008.py:276:27: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
273 273 |
274 274 |
275 275 | def mutable_annotations(
@ -317,7 +317,7 @@ B006_B008.py:277:35: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
274 274 |
275 275 | def mutable_annotations(
276 276 | a: list[int] | None = [],
@ -343,7 +343,7 @@ B006_B008.py:278:62: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
275 275 | def mutable_annotations(
276 276 | a: list[int] | None = [],
277 277 | b: Optional[Dict[int, int]] = {},
@ -368,7 +368,7 @@ B006_B008.py:279:80: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
276 276 | a: list[int] | None = [],
277 277 | b: Optional[Dict[int, int]] = {},
278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(),
@ -389,7 +389,7 @@ B006_B008.py:284:52: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
281 281 | pass
282 282 |
283 283 |
@ -411,7 +411,7 @@ B006_B008.py:288:52: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
285 285 | """Docstring"""
286 286 |
287 287 |
@ -432,7 +432,7 @@ B006_B008.py:293:52: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
290 290 | ...
291 291 |
292 292 |
@ -453,7 +453,7 @@ B006_B008.py:297:52: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
294 294 | """Docstring"""; ...
295 295 |
296 296 |
@ -476,7 +476,7 @@ B006_B008.py:302:52: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
299 299 | ...
300 300 |
301 301 |
@ -508,7 +508,7 @@ B006_B008.py:313:52: B006 [*] Do not use mutable data structures for argument de
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
310 310 | """Docstring"""
311 311 |
312 312 |

View file

@ -21,7 +21,7 @@ B007.py:18:13: B007 [*] Loop control variable `k` not used within loop body
|
= help: Rename unused `k` to `_k`
Suggested fix
Unsafe fix
15 15 |
16 16 | for i in range(10):
17 17 | for j in range(10):
@ -47,7 +47,7 @@ B007.py:30:13: B007 [*] Loop control variable `k` not used within loop body
|
= help: Rename unused `k` to `_k`
Suggested fix
Unsafe fix
27 27 | yield i, (j, (k, l))
28 28 |
29 29 |
@ -110,7 +110,7 @@ B007.py:52:14: B007 [*] Loop control variable `bar` not used within loop body
|
= help: Rename unused `bar` to `_bar`
Suggested fix
Unsafe fix
49 49 |
50 50 | def f():
51 51 | # Fixable.
@ -142,7 +142,7 @@ B007.py:68:14: B007 [*] Loop control variable `bar` not used within loop body
|
= help: Rename unused `bar` to `_bar`
Suggested fix
Unsafe fix
65 65 |
66 66 | def f():
67 67 | # Fixable.

View file

@ -11,7 +11,7 @@ B009_B010.py:19:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
16 16 | getattr(foo, "__123abc")
17 17 |
18 18 | # Invalid usage
@ -32,7 +32,7 @@ B009_B010.py:20:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
17 17 |
18 18 | # Invalid usage
19 19 | getattr(foo, "bar")
@ -53,7 +53,7 @@ B009_B010.py:21:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
18 18 | # Invalid usage
19 19 | getattr(foo, "bar")
20 20 | getattr(foo, "_123abc")
@ -74,7 +74,7 @@ B009_B010.py:22:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
19 19 | getattr(foo, "bar")
20 20 | getattr(foo, "_123abc")
21 21 | getattr(foo, "__123abc__")
@ -95,7 +95,7 @@ B009_B010.py:23:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
20 20 | getattr(foo, "_123abc")
21 21 | getattr(foo, "__123abc__")
22 22 | getattr(foo, "abc123")
@ -116,7 +116,7 @@ B009_B010.py:24:15: B009 [*] Do not call `getattr` with a constant attribute val
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
21 21 | getattr(foo, "__123abc__")
22 22 | getattr(foo, "abc123")
23 23 | getattr(foo, r"abc123")
@ -137,7 +137,7 @@ B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
22 22 | getattr(foo, "abc123")
23 23 | getattr(foo, r"abc123")
24 24 | _ = lambda x: getattr(x, "bar")
@ -158,7 +158,7 @@ B009_B010.py:27:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
24 24 | _ = lambda x: getattr(x, "bar")
25 25 | if getattr(x, "bar"):
26 26 | pass
@ -179,7 +179,7 @@ B009_B010.py:28:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
25 25 | if getattr(x, "bar"):
26 26 | pass
27 27 | getattr(1, "real")
@ -200,7 +200,7 @@ B009_B010.py:29:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
26 26 | pass
27 27 | getattr(1, "real")
28 28 | getattr(1., "real")
@ -221,7 +221,7 @@ B009_B010.py:30:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
27 27 | getattr(1, "real")
28 28 | getattr(1., "real")
29 29 | getattr(1.0, "real")
@ -242,7 +242,7 @@ B009_B010.py:31:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
28 28 | getattr(1., "real")
29 29 | getattr(1.0, "real")
30 30 | getattr(1j, "real")
@ -263,7 +263,7 @@ B009_B010.py:32:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
29 29 | getattr(1.0, "real")
30 30 | getattr(1j, "real")
31 31 | getattr(True, "real")
@ -284,7 +284,7 @@ B009_B010.py:33:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
30 30 | getattr(1j, "real")
31 31 | getattr(True, "real")
32 32 | getattr(x := 1, "real")
@ -304,7 +304,7 @@ B009_B010.py:34:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
31 31 | getattr(True, "real")
32 32 | getattr(x := 1, "real")
33 33 | getattr(x + y, "real")
@ -326,7 +326,7 @@ B009_B010.py:58:8: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
55 55 | setattr(foo.bar, r"baz", None)
56 56 |
57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885
@ -345,7 +345,7 @@ B009_B010.py:65:1: B009 [*] Do not call `getattr` with a constant attribute valu
|
= help: Replace `getattr` with attribute access
Fix
Safe fix
62 62 | setattr(*foo, "bar", None)
63 63 |
64 64 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1739800901

View file

@ -11,7 +11,7 @@ B009_B010.py:50:1: B010 [*] Do not call `setattr` with a constant attribute valu
|
= help: Replace `setattr` with assignment
Fix
Safe fix
47 47 | pass
48 48 |
49 49 | # Invalid usage
@ -32,7 +32,7 @@ B009_B010.py:51:1: B010 [*] Do not call `setattr` with a constant attribute valu
|
= help: Replace `setattr` with assignment
Fix
Safe fix
48 48 |
49 49 | # Invalid usage
50 50 | setattr(foo, "bar", None)
@ -53,7 +53,7 @@ B009_B010.py:52:1: B010 [*] Do not call `setattr` with a constant attribute valu
|
= help: Replace `setattr` with assignment
Fix
Safe fix
49 49 | # Invalid usage
50 50 | setattr(foo, "bar", None)
51 51 | setattr(foo, "_123abc", None)
@ -74,7 +74,7 @@ B009_B010.py:53:1: B010 [*] Do not call `setattr` with a constant attribute valu
|
= help: Replace `setattr` with assignment
Fix
Safe fix
50 50 | setattr(foo, "bar", None)
51 51 | setattr(foo, "_123abc", None)
52 52 | setattr(foo, "__123abc__", None)
@ -94,7 +94,7 @@ B009_B010.py:54:1: B010 [*] Do not call `setattr` with a constant attribute valu
|
= help: Replace `setattr` with assignment
Fix
Safe fix
51 51 | setattr(foo, "_123abc", None)
52 52 | setattr(foo, "__123abc__", None)
53 53 | setattr(foo, "abc123", None)
@ -115,7 +115,7 @@ B009_B010.py:55:1: B010 [*] Do not call `setattr` with a constant attribute valu
|
= help: Replace `setattr` with assignment
Fix
Safe fix
52 52 | setattr(foo, "__123abc__", None)
53 53 | setattr(foo, "abc123", None)
54 54 | setattr(foo, r"abc123", None)

View file

@ -11,7 +11,7 @@ B011.py:8:8: B011 [*] Do not `assert False` (`python -O` removes these calls), r
|
= help: Replace `assert False`
Suggested fix
Unsafe fix
5 5 | """
6 6 |
7 7 | assert 1 != 2
@ -29,7 +29,7 @@ B011.py:10:8: B011 [*] Do not `assert False` (`python -O` removes these calls),
|
= help: Replace `assert False`
Suggested fix
Unsafe fix
7 7 | assert 1 != 2
8 8 | assert False
9 9 | assert 1 != 2, "message"

View file

@ -12,7 +12,7 @@ B013.py:5:8: B013 [*] A length-one tuple literal is redundant in exception handl
|
= help: Replace with `except ValueError`
Fix
Safe fix
2 2 |
3 3 | try:
4 4 | pass
@ -33,7 +33,7 @@ B013.py:11:8: B013 [*] A length-one tuple literal is redundant in exception hand
|
= help: Replace with `except retriable_exceptions`
Fix
Safe fix
8 8 | pass
9 9 | except (ImportError, TypeError):
10 10 | pass
@ -53,7 +53,7 @@ B013.py:13:7: B013 [*] A length-one tuple literal is redundant in exception hand
|
= help: Replace with `except ValueError`
Fix
Safe fix
10 10 | pass
11 11 | except (*retriable_exceptions,):
12 12 | pass

View file

@ -12,7 +12,7 @@ B014.py:17:8: B014 [*] Exception handler with duplicate exception: `OSError`
|
= help: De-duplicate exceptions
Fix
Safe fix
14 14 |
15 15 | try:
16 16 | pass
@ -33,7 +33,7 @@ B014.py:28:8: B014 [*] Exception handler with duplicate exception: `MyError`
|
= help: De-duplicate exceptions
Fix
Safe fix
25 25 |
26 26 | try:
27 27 | pass
@ -54,7 +54,7 @@ B014.py:49:8: B014 [*] Exception handler with duplicate exception: `re.error`
|
= help: De-duplicate exceptions
Fix
Safe fix
46 46 |
47 47 | try:
48 48 | pass
@ -74,7 +74,7 @@ B014.py:82:8: B014 [*] Exception handler with duplicate exception: `ValueError`
|
= help: De-duplicate exceptions
Fix
Safe fix
79 79 | # Regression test for: https://github.com/astral-sh/ruff/issues/6412
80 80 | try:
81 81 | pass
@ -94,7 +94,7 @@ B014.py:89:7: B014 [*] Exception handler with duplicate exception: `re.error`
|
= help: De-duplicate exceptions
Fix
Safe fix
86 86 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1739801758
87 87 | try:
88 88 | pas

View file

@ -9,7 +9,7 @@ B006_extended.py:17:55: B006 [*] Do not use mutable data structures for argument
|
= help: Replace with `None`; initialize within function
Suggested fix
Unsafe fix
14 14 | ...
15 15 |
16 16 |

View file

@ -12,7 +12,7 @@ COM81.py:4:18: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
1 1 | # ==> bad_function_call.py <==
2 2 | bad_function_call(
3 3 | param1='test',
@ -32,7 +32,7 @@ COM81.py:10:6: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
7 7 | bad_list = [
8 8 | 1,
9 9 | 2,
@ -53,7 +53,7 @@ COM81.py:16:6: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
13 13 | bad_list_with_comment = [
14 14 | 1,
15 15 | 2,
@ -72,7 +72,7 @@ COM81.py:23:6: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
20 20 | bad_list_with_extra_empty = [
21 21 | 1,
22 22 | 2,
@ -159,7 +159,7 @@ COM81.py:70:8: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
67 67 | pass
68 68 |
69 69 | {'foo': foo}['foo'](
@ -178,7 +178,7 @@ COM81.py:78:8: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
75 75 | )
76 76 |
77 77 | (foo)(
@ -197,7 +197,7 @@ COM81.py:86:8: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
83 83 | )
84 84 |
85 85 | [foo][0](
@ -217,7 +217,7 @@ COM81.py:152:6: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
149 149 |
150 150 | # ==> keyword_before_parenth_form/base_bad.py <==
151 151 | from x import (
@ -237,7 +237,7 @@ COM81.py:158:11: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
155 155 | assert(
156 156 | SyntaxWarning,
157 157 | ThrownHere,
@ -258,7 +258,7 @@ COM81.py:293:15: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
290 290 |
291 291 | # ==> multiline_bad_dict.py <==
292 292 | multiline_bad_dict = {
@ -279,7 +279,7 @@ COM81.py:304:14: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
301 301 |
302 302 | def func_bad(
303 303 | a = 3,
@ -300,7 +300,7 @@ COM81.py:310:14: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
307 307 |
308 308 | # ==> multiline_bad_function_one_param.py <==
309 309 | def func(
@ -319,7 +319,7 @@ COM81.py:316:10: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
313 313 |
314 314 |
315 315 | func(
@ -339,7 +339,7 @@ COM81.py:322:15: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
319 319 | # ==> multiline_bad_or_dict.py <==
320 320 | multiline_bad_or_dict = {
321 321 | "good": True or False,
@ -359,7 +359,7 @@ COM81.py:368:15: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
365 365 |
366 366 | multiline_index_access[
367 367 | "probably fine",
@ -379,7 +379,7 @@ COM81.py:375:15: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
372 372 | "fine",
373 373 | "fine",
374 374 | :
@ -399,7 +399,7 @@ COM81.py:404:15: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
401 401 | "fine",
402 402 | "fine"
403 403 | :
@ -419,7 +419,7 @@ COM81.py:432:15: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
429 429 | "fine"
430 430 | :
431 431 | "fine",
@ -439,7 +439,7 @@ COM81.py:485:21: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
482 482 | )
483 483 |
484 484 | # ==> prohibited.py <==
@ -460,7 +460,7 @@ COM81.py:487:13: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
484 484 | # ==> prohibited.py <==
485 485 | foo = ['a', 'b', 'c',]
486 486 |
@ -480,7 +480,7 @@ COM81.py:489:18: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
486 486 |
487 487 | bar = { a: b,}
488 488 |
@ -501,7 +501,7 @@ COM81.py:494:6: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
491 491 |
492 492 | (0,)
493 493 |
@ -522,7 +522,7 @@ COM81.py:496:21: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
493 493 |
494 494 | (0, 1,)
495 495 |
@ -543,7 +543,7 @@ COM81.py:498:13: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
495 495 |
496 496 | foo = ['a', 'b', 'c', ]
497 497 |
@ -563,7 +563,7 @@ COM81.py:500:18: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
497 497 |
498 498 | bar = { a: b, }
499 499 |
@ -584,7 +584,7 @@ COM81.py:505:6: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
502 502 |
503 503 | (0, )
504 504 |
@ -605,7 +605,7 @@ COM81.py:511:10: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
508 508 |
509 509 | image[:,]
510 510 |
@ -626,7 +626,7 @@ COM81.py:513:9: COM819 [*] Trailing comma prohibited
|
= help: Remove trailing comma
Fix
Safe fix
510 510 |
511 511 | image[:,:,]
512 512 |
@ -647,7 +647,7 @@ COM81.py:519:13: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
516 516 | def function(
517 517 | foo,
518 518 | bar,
@ -668,7 +668,7 @@ COM81.py:526:10: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
523 523 | def function(
524 524 | foo,
525 525 | bar,
@ -689,7 +689,7 @@ COM81.py:534:16: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
531 531 | foo,
532 532 | bar,
533 533 | *args,
@ -709,7 +709,7 @@ COM81.py:541:13: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
538 538 | result = function(
539 539 | foo,
540 540 | bar,
@ -729,7 +729,7 @@ COM81.py:547:24: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
544 544 | result = function(
545 545 | foo,
546 546 | bar,
@ -750,7 +750,7 @@ COM81.py:554:15: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
551 551 | ham,
552 552 | spam,
553 553 | *args,
@ -769,7 +769,7 @@ COM81.py:561:13: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
558 558 | # In python 3.5 if it's not a function def, commas are mandatory.
559 559 |
560 560 | foo(
@ -788,7 +788,7 @@ COM81.py:565:13: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
562 562 | )
563 563 |
564 564 | {
@ -807,7 +807,7 @@ COM81.py:573:10: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
570 570 | )
571 571 |
572 572 | {
@ -826,7 +826,7 @@ COM81.py:577:10: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
574 574 | }
575 575 |
576 576 | [
@ -847,7 +847,7 @@ COM81.py:583:10: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
580 580 | def foo(
581 581 | ham,
582 582 | spam,
@ -868,7 +868,7 @@ COM81.py:590:13: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
587 587 | def foo(
588 588 | ham,
589 589 | spam,
@ -889,7 +889,7 @@ COM81.py:598:15: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
595 595 | ham,
596 596 | spam,
597 597 | *args,
@ -909,7 +909,7 @@ COM81.py:627:20: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
624 624 | result = function(
625 625 | foo,
626 626 | bar,
@ -929,7 +929,7 @@ COM81.py:632:42: COM812 [*] Trailing comma missing
|
= help: Add trailing comma
Fix
Safe fix
629 629 |
630 630 | # Make sure the COM812 and UP034 rules don't fix simultaneously and cause a syntax error.
631 631 | the_first_one = next(

View file

@ -10,7 +10,7 @@ C400.py:1:5: C400 [*] Unnecessary generator (rewrite as a `list` comprehension)
|
= help: Rewrite as a `list` comprehension
Suggested fix
Unsafe fix
1 |-x = list(x for x in range(3))
1 |+x = [x for x in range(3)]
2 2 | x = list(
@ -28,7 +28,7 @@ C400.py:2:5: C400 [*] Unnecessary generator (rewrite as a `list` comprehension)
|
= help: Rewrite as a `list` comprehension
Suggested fix
Unsafe fix
1 1 | x = list(x for x in range(3))
2 |-x = list(
2 |+x = [

View file

@ -10,7 +10,7 @@ C401.py:1:5: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
1 |-x = set(x for x in range(3))
1 |+x = {x for x in range(3)}
2 2 | x = set(x for x in range(3))
@ -27,7 +27,7 @@ C401.py:2:5: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
1 1 | x = set(x for x in range(3))
2 |-x = set(x for x in range(3))
2 |+x = {x for x in range(3)}
@ -46,7 +46,7 @@ C401.py:3:8: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
1 1 | x = set(x for x in range(3))
2 2 | x = set(x for x in range(3))
3 |-y = f"{set(a if a < 6 else 0 for a in range(3))}"
@ -65,7 +65,7 @@ C401.py:4:17: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
1 1 | x = set(x for x in range(3))
2 2 | x = set(x for x in range(3))
3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}"
@ -84,7 +84,7 @@ C401.py:5:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
2 2 | x = set(x for x in range(3))
3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}"
4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3)))
@ -103,7 +103,7 @@ C401.py:12:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
9 9 | return x
10 10 |
11 11 |
@ -123,7 +123,7 @@ C401.py:13:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
10 10 |
11 11 |
12 12 | print(f'Hello {set(a for a in "abc")} World')
@ -144,7 +144,7 @@ C401.py:14:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
11 11 |
12 12 | print(f'Hello {set(a for a in "abc")} World')
13 13 | print(f"Hello {set(a for a in 'abc')} World")
@ -164,7 +164,7 @@ C401.py:15:10: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
12 12 | print(f'Hello {set(a for a in "abc")} World')
13 13 | print(f"Hello {set(a for a in 'abc')} World")
14 14 | print(f"Hello {set(f(a) for a in 'abc')} World")
@ -184,7 +184,7 @@ C401.py:15:34: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
12 12 | print(f'Hello {set(a for a in "abc")} World')
13 13 | print(f"Hello {set(a for a in 'abc')} World")
14 14 | print(f"Hello {set(f(a) for a in 'abc')} World")
@ -205,7 +205,7 @@ C401.py:16:11: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
13 13 | print(f"Hello {set(a for a in 'abc')} World")
14 14 | print(f"Hello {set(f(a) for a in 'abc')} World")
15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}")
@ -226,7 +226,7 @@ C401.py:16:35: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
13 13 | print(f"Hello {set(a for a in 'abc')} World")
14 14 | print(f"Hello {set(f(a) for a in 'abc')} World")
15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}")
@ -245,7 +245,7 @@ C401.py:20:12: C401 [*] Unnecessary generator (rewrite as a `set` comprehension)
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
17 17 |
18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space
19 19 | # around the set comprehension.

View file

@ -10,7 +10,7 @@ C402.py:1:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
1 |-dict((x, x) for x in range(3))
1 |+{x: x for x in range(3)}
2 2 | dict(
@ -29,7 +29,7 @@ C402.py:2:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
1 1 | dict((x, x) for x in range(3))
2 |-dict(
3 |- (x, x) for x in range(3)
@ -52,7 +52,7 @@ C402.py:6:8: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
3 3 | (x, x) for x in range(3)
4 4 | )
5 5 | dict(((x, x) for x in range(3)), z=3)
@ -73,7 +73,7 @@ C402.py:7:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
4 4 | )
5 5 | dict(((x, x) for x in range(3)), z=3)
6 6 | y = f'{dict((x, x) for x in range(3))}'
@ -94,7 +94,7 @@ C402.py:8:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
5 5 | dict(((x, x) for x in range(3)), z=3)
6 6 | y = f'{dict((x, x) for x in range(3))}'
7 7 | print(f'Hello {dict((x, x) for x in range(3))} World')
@ -114,7 +114,7 @@ C402.py:9:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
6 6 | y = f'{dict((x, x) for x in range(3))}'
7 7 | print(f'Hello {dict((x, x) for x in range(3))} World')
8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World")
@ -135,7 +135,7 @@ C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
7 7 | print(f'Hello {dict((x, x) for x in range(3))} World')
8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World")
9 9 | print(f'Hello {dict((x, x) for x in "abc")} World')
@ -155,7 +155,7 @@ C402.py:12:4: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
9 9 | print(f'Hello {dict((x, x) for x in "abc")} World')
10 10 | print(f'Hello {dict((x,x) for x in "abc")} World')
11 11 |
@ -175,7 +175,7 @@ C402.py:12:37: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
9 9 | print(f'Hello {dict((x, x) for x in "abc")} World')
10 10 | print(f'Hello {dict((x,x) for x in "abc")} World')
11 11 |
@ -195,7 +195,7 @@ C402.py:13:5: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
10 10 | print(f'Hello {dict((x,x) for x in "abc")} World')
11 11 |
12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}'
@ -215,7 +215,7 @@ C402.py:13:38: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
10 10 | print(f'Hello {dict((x,x) for x in "abc")} World')
11 11 |
12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}'
@ -236,7 +236,7 @@ C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
15 15 | def f(x):
16 16 | return x
17 17 |
@ -256,7 +256,7 @@ C402.py:21:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension)
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
18 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World')
19 19 |
20 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086

View file

@ -10,7 +10,7 @@ C403.py:1:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` compr
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
1 |-s = set([x for x in range(3)])
1 |+s = {x for x in range(3)}
2 2 | s = set(
@ -30,7 +30,7 @@ C403.py:2:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` compr
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
1 1 | s = set([x for x in range(3)])
2 |-s = set(
3 |- [x for x in range(3)]
@ -52,7 +52,7 @@ C403.py:6:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` compr
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
3 3 | [x for x in range(3)]
4 4 | )
5 5 |
@ -72,7 +72,7 @@ C403.py:7:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` compr
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
4 4 | )
5 5 |
6 6 | s = f"{set([x for x in 'ab'])}"
@ -93,7 +93,7 @@ C403.py:12:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comp
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
9 9 | def f(x):
10 10 | return x
11 11 |
@ -113,7 +113,7 @@ C403.py:14:9: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comp
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
11 11 |
12 12 | s = f"{set([f(x) for x in 'ab'])}"
13 13 |
@ -131,7 +131,7 @@ C403.py:14:34: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` com
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
11 11 |
12 12 | s = f"{set([f(x) for x in 'ab'])}"
13 13 |
@ -147,7 +147,7 @@ C403.py:15:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comp
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
12 12 | s = f"{set([f(x) for x in 'ab'])}"
13 13 |
14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }"
@ -162,7 +162,7 @@ C403.py:15:33: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` com
|
= help: Rewrite as a `set` comprehension
Suggested fix
Unsafe fix
12 12 | s = f"{set([f(x) for x in 'ab'])}"
13 13 |
14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }"

View file

@ -9,7 +9,7 @@ C404.py:1:1: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comp
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
1 |-dict([(i, i) for i in range(3)])
1 |+{i: i for i in range(3)}
2 2 | dict([(i, i) for i in range(3)], z=4)
@ -27,7 +27,7 @@ C404.py:7:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comp
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
4 4 | def f(x):
5 5 | return x
6 6 |
@ -47,7 +47,7 @@ C404.py:8:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comp
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
5 5 | return x
6 6 |
7 7 | f'{dict([(s,s) for s in "ab"])}'
@ -67,7 +67,7 @@ C404.py:9:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comp
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
6 6 |
7 7 | f'{dict([(s,s) for s in "ab"])}'
8 8 | f"{dict([(s,s) for s in 'ab'])}"
@ -88,7 +88,7 @@ C404.py:10:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` com
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
7 7 | f'{dict([(s,s) for s in "ab"])}'
8 8 | f"{dict([(s,s) for s in 'ab'])}"
9 9 | f"{dict([(s, s) for s in 'ab'])}"
@ -108,7 +108,7 @@ C404.py:12:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` com
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
9 9 | f"{dict([(s, s) for s in 'ab'])}"
10 10 | f"{dict([(s,f(s)) for s in 'ab'])}"
11 11 |
@ -128,7 +128,7 @@ C404.py:12:34: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` co
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
9 9 | f"{dict([(s, s) for s in 'ab'])}"
10 10 | f"{dict([(s,f(s)) for s in 'ab'])}"
11 11 |
@ -148,7 +148,7 @@ C404.py:13:5: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` com
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
10 10 | f"{dict([(s,f(s)) for s in 'ab'])}"
11 11 |
12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}'
@ -168,7 +168,7 @@ C404.py:13:35: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` co
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
10 10 | f"{dict([(s,f(s)) for s in 'ab'])}"
11 11 |
12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}'
@ -186,7 +186,7 @@ C404.py:16:14: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` co
|
= help: Rewrite as a `dict` comprehension
Suggested fix
Unsafe fix
13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }'
14 14 |
15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087

View file

@ -10,7 +10,7 @@ C405.py:1:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
1 |-set([1, 2])
1 |+{1, 2}
2 2 | set((1, 2))
@ -27,7 +27,7 @@ C405.py:2:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
1 1 | set([1, 2])
2 |-set((1, 2))
2 |+{1, 2}
@ -46,7 +46,7 @@ C405.py:3:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
1 1 | set([1, 2])
2 2 | set((1, 2))
3 |-set([])
@ -66,7 +66,7 @@ C405.py:4:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
1 1 | set([1, 2])
2 2 | set((1, 2))
3 3 | set([])
@ -88,7 +88,7 @@ C405.py:6:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
3 3 | set([])
4 4 | set(())
5 5 | set()
@ -111,7 +111,7 @@ C405.py:7:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
4 4 | set(())
5 5 | set()
6 6 | set((1,))
@ -137,7 +137,7 @@ C405.py:10:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
7 7 | set((
8 8 | 1,
9 9 | ))
@ -163,7 +163,7 @@ C405.py:13:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
10 10 | set([
11 11 | 1,
12 12 | ])
@ -188,7 +188,7 @@ C405.py:16:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
13 13 | set(
14 14 | (1,)
15 15 | )
@ -211,7 +211,7 @@ C405.py:19:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
16 16 | set(
17 17 | [1,]
18 18 | )
@ -231,7 +231,7 @@ C405.py:20:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
17 17 | [1,]
18 18 | )
19 19 | f"{set([1,2,3])}"
@ -252,7 +252,7 @@ C405.py:21:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
18 18 | )
19 19 | f"{set([1,2,3])}"
20 20 | f"{set(['a', 'b'])}"
@ -273,7 +273,7 @@ C405.py:23:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
20 20 | f"{set(['a', 'b'])}"
21 21 | f'{set(["a", "b"])}'
22 22 |
@ -294,7 +294,7 @@ C405.py:23:22: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
20 20 | f"{set(['a', 'b'])}"
21 21 | f'{set(["a", "b"])}'
22 22 |
@ -314,7 +314,7 @@ C405.py:24:5: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
21 21 | f'{set(["a", "b"])}'
22 22 |
23 23 | f"{set(['a', 'b']) - set(['a'])}"
@ -333,7 +333,7 @@ C405.py:24:23: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
21 21 | f'{set(["a", "b"])}'
22 22 |
23 23 | f"{set(['a', 'b']) - set(['a'])}"
@ -352,7 +352,7 @@ C405.py:25:6: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
22 22 |
23 23 | f"{set(['a', 'b']) - set(['a'])}"
24 24 | f"{ set(['a', 'b']) - set(['a']) }"
@ -370,7 +370,7 @@ C405.py:25:24: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
22 22 |
23 23 | f"{set(['a', 'b']) - set(['a'])}"
24 24 | f"{ set(['a', 'b']) - set(['a']) }"
@ -387,7 +387,7 @@ C405.py:26:7: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
23 23 | f"{set(['a', 'b']) - set(['a'])}"
24 24 | f"{ set(['a', 'b']) - set(['a']) }"
25 25 | f"a {set(['a', 'b']) - set(['a'])} b"
@ -403,7 +403,7 @@ C405.py:26:25: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal)
|
= help: Rewrite as a `set` literal
Suggested fix
Unsafe fix
23 23 | f"{set(['a', 'b']) - set(['a'])}"
24 24 | f"{ set(['a', 'b']) - set(['a']) }"
25 25 | f"a {set(['a', 'b']) - set(['a'])} b"

View file

@ -10,7 +10,7 @@ C406.py:1:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal)
|
= help: Rewrite as a `dict` literal
Suggested fix
Unsafe fix
1 |-d1 = dict([(1, 2)])
1 |+d1 = {1: 2}
2 2 | d2 = dict(((1, 2),))
@ -27,7 +27,7 @@ C406.py:2:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal)
|
= help: Rewrite as a `dict` literal
Suggested fix
Unsafe fix
1 1 | d1 = dict([(1, 2)])
2 |-d2 = dict(((1, 2),))
2 |+d2 = {1: 2,}
@ -46,7 +46,7 @@ C406.py:3:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal)
|
= help: Rewrite as a `dict` literal
Suggested fix
Unsafe fix
1 1 | d1 = dict([(1, 2)])
2 2 | d2 = dict(((1, 2),))
3 |-d3 = dict([])
@ -64,7 +64,7 @@ C406.py:4:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal)
|
= help: Rewrite as a `dict` literal
Suggested fix
Unsafe fix
1 1 | d1 = dict([(1, 2)])
2 2 | d2 = dict(((1, 2),))
3 3 | d3 = dict([])

View file

@ -10,7 +10,7 @@ C408.py:1:5: C408 [*] Unnecessary `tuple` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
1 |-t = tuple()
1 |+t = ()
2 2 | l = list()
@ -27,7 +27,7 @@ C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
1 1 | t = tuple()
2 |-l = list()
2 |+l = []
@ -46,7 +46,7 @@ C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
1 1 | t = tuple()
2 2 | l = list()
3 |-d1 = dict()
@ -65,7 +65,7 @@ C408.py:4:6: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
1 1 | t = tuple()
2 2 | l = list()
3 3 | d1 = dict()
@ -86,7 +86,7 @@ C408.py:14:4: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
11 11 |
12 12 | a = list()
13 13 |
@ -106,7 +106,7 @@ C408.py:15:4: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
12 12 | a = list()
13 13 |
14 14 | f"{dict(x='y')}"
@ -126,7 +126,7 @@ C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
13 13 |
14 14 | f"{dict(x='y')}"
15 15 | f'{dict(x="y")}'
@ -147,7 +147,7 @@ C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
14 14 | f"{dict(x='y')}"
15 15 | f'{dict(x="y")}'
16 16 | f"{dict()}"
@ -168,7 +168,7 @@ C408.py:19:4: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
16 16 | f"{dict()}"
17 17 | f"a {dict()} b"
18 18 |
@ -189,7 +189,7 @@ C408.py:19:18: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
16 16 | f"{dict()}"
17 17 | f"a {dict()} b"
18 18 |
@ -209,7 +209,7 @@ C408.py:20:5: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
17 17 | f"a {dict()} b"
18 18 |
19 19 | f"{dict(x='y') | dict(y='z')}"
@ -228,7 +228,7 @@ C408.py:20:19: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
17 17 | f"a {dict()} b"
18 18 |
19 19 | f"{dict(x='y') | dict(y='z')}"
@ -247,7 +247,7 @@ C408.py:21:6: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
18 18 |
19 19 | f"{dict(x='y') | dict(y='z')}"
20 20 | f"{ dict(x='y') | dict(y='z') }"
@ -265,7 +265,7 @@ C408.py:21:20: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
18 18 |
19 19 | f"{dict(x='y') | dict(y='z')}"
20 20 | f"{ dict(x='y') | dict(y='z') }"
@ -282,7 +282,7 @@ C408.py:22:7: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
19 19 | f"{dict(x='y') | dict(y='z')}"
20 20 | f"{ dict(x='y') | dict(y='z') }"
21 21 | f"a {dict(x='y') | dict(y='z')} b"
@ -298,7 +298,7 @@ C408.py:22:21: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
19 19 | f"{dict(x='y') | dict(y='z')}"
20 20 | f"{ dict(x='y') | dict(y='z') }"
21 21 | f"a {dict(x='y') | dict(y='z')} b"

View file

@ -10,7 +10,7 @@ C408.py:1:5: C408 [*] Unnecessary `tuple` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
1 |-t = tuple()
1 |+t = ()
2 2 | l = list()
@ -27,7 +27,7 @@ C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
1 1 | t = tuple()
2 |-l = list()
2 |+l = []
@ -46,7 +46,7 @@ C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
1 1 | t = tuple()
2 2 | l = list()
3 |-d1 = dict()
@ -65,7 +65,7 @@ C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
13 13 |
14 14 | f"{dict(x='y')}"
15 15 | f'{dict(x="y")}'
@ -86,7 +86,7 @@ C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal)
|
= help: Rewrite as a literal
Suggested fix
Unsafe fix
14 14 | f"{dict(x='y')}"
15 15 | f'{dict(x="y")}'
16 16 | f"{dict()}"

View file

@ -10,7 +10,7 @@ C409.py:1:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as
|
= help: Rewrite as a `tuple` literal
Suggested fix
Unsafe fix
1 |-t1 = tuple([])
1 |+t1 = ()
2 2 | t2 = tuple([1, 2])
@ -27,7 +27,7 @@ C409.py:2:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as
|
= help: Rewrite as a `tuple` literal
Suggested fix
Unsafe fix
1 1 | t1 = tuple([])
2 |-t2 = tuple([1, 2])
2 |+t2 = (1, 2)
@ -46,7 +46,7 @@ C409.py:3:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove th
|
= help: Remove outer `tuple` call
Suggested fix
Unsafe fix
1 1 | t1 = tuple([])
2 2 | t2 = tuple([1, 2])
3 |-t3 = tuple((1, 2))
@ -70,7 +70,7 @@ C409.py:4:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as
|
= help: Rewrite as a `tuple` literal
Suggested fix
Unsafe fix
1 1 | t1 = tuple([])
2 2 | t2 = tuple([1, 2])
3 3 | t3 = tuple((1, 2))
@ -96,7 +96,7 @@ C409.py:8:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove th
|
= help: Remove outer `tuple` call
Suggested fix
Unsafe fix
5 5 | 1,
6 6 | 2
7 7 | ])

View file

@ -10,7 +10,7 @@ C410.py:1:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the
|
= help: Remove outer `list` call
Suggested fix
Unsafe fix
1 |-l1 = list([1, 2])
1 |+l1 = [1, 2]
2 2 | l2 = list((1, 2))
@ -27,7 +27,7 @@ C410.py:2:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as
|
= help: Rewrite as a `list` literal
Suggested fix
Unsafe fix
1 1 | l1 = list([1, 2])
2 |-l2 = list((1, 2))
2 |+l2 = [1, 2]
@ -44,7 +44,7 @@ C410.py:3:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the
|
= help: Remove outer `list` call
Suggested fix
Unsafe fix
1 1 | l1 = list([1, 2])
2 2 | l2 = list((1, 2))
3 |-l3 = list([])
@ -60,7 +60,7 @@ C410.py:4:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as
|
= help: Rewrite as a `list` literal
Suggested fix
Unsafe fix
1 1 | l1 = list([1, 2])
2 2 | l2 = list((1, 2))
3 3 | l3 = list([])

View file

@ -9,7 +9,7 @@ C411.py:2:1: C411 [*] Unnecessary `list` call (remove the outer call to `list()`
|
= help: Remove outer `list` call
Suggested fix
Unsafe fix
1 1 | x = [1, 2, 3]
2 |-list([i for i in x])
2 |+[i for i in x]

View file

@ -12,7 +12,7 @@ C413.py:3:1: C413 [*] Unnecessary `list` call around `sorted()`
|
= help: Remove unnecessary `list` call
Fix
Safe fix
1 1 | x = [2, 3, 1]
2 2 | list(x)
3 |-list(sorted(x))
@ -32,7 +32,7 @@ C413.py:4:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
1 1 | x = [2, 3, 1]
2 2 | list(x)
3 3 | list(sorted(x))
@ -53,7 +53,7 @@ C413.py:5:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
2 2 | list(x)
3 3 | list(sorted(x))
4 4 | reversed(sorted(x))
@ -74,7 +74,7 @@ C413.py:6:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
3 3 | list(sorted(x))
4 4 | reversed(sorted(x))
5 5 | reversed(sorted(x, key=lambda e: e))
@ -95,7 +95,7 @@ C413.py:7:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
4 4 | reversed(sorted(x))
5 5 | reversed(sorted(x, key=lambda e: e))
6 6 | reversed(sorted(x, reverse=True))
@ -116,7 +116,7 @@ C413.py:8:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
5 5 | reversed(sorted(x, key=lambda e: e))
6 6 | reversed(sorted(x, reverse=True))
7 7 | reversed(sorted(x, key=lambda e: e, reverse=True))
@ -137,7 +137,7 @@ C413.py:9:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
6 6 | reversed(sorted(x, reverse=True))
7 7 | reversed(sorted(x, key=lambda e: e, reverse=True))
8 8 | reversed(sorted(x, reverse=True, key=lambda e: e))
@ -157,7 +157,7 @@ C413.py:10:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
7 7 | reversed(sorted(x, key=lambda e: e, reverse=True))
8 8 | reversed(sorted(x, reverse=True, key=lambda e: e))
9 9 | reversed(sorted(x, reverse=False))
@ -178,7 +178,7 @@ C413.py:11:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
8 8 | reversed(sorted(x, reverse=True, key=lambda e: e))
9 9 | reversed(sorted(x, reverse=False))
10 10 | reversed(sorted(x, reverse=x))
@ -197,7 +197,7 @@ C413.py:14:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
11 11 | reversed(sorted(x, reverse=not x))
12 12 |
13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289
@ -216,7 +216,7 @@ C413.py:15:1: C413 [*] Unnecessary `reversed` call around `sorted()`
|
= help: Remove unnecessary `reversed` call
Suggested fix
Unsafe fix
12 12 |
13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289
14 14 | reversed(sorted(i for i in range(42)))

View file

@ -11,7 +11,7 @@ C414.py:2:1: C414 [*] Unnecessary `list` call within `list()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
1 1 | x = [1, 2, 3]
2 |-list(list(x))
2 |+list(x)
@ -30,7 +30,7 @@ C414.py:3:1: C414 [*] Unnecessary `tuple` call within `list()`
|
= help: Remove the inner `tuple` call
Suggested fix
Unsafe fix
1 1 | x = [1, 2, 3]
2 2 | list(list(x))
3 |-list(tuple(x))
@ -50,7 +50,7 @@ C414.py:4:1: C414 [*] Unnecessary `list` call within `tuple()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
1 1 | x = [1, 2, 3]
2 2 | list(list(x))
3 3 | list(tuple(x))
@ -71,7 +71,7 @@ C414.py:5:1: C414 [*] Unnecessary `tuple` call within `tuple()`
|
= help: Remove the inner `tuple` call
Suggested fix
Unsafe fix
2 2 | list(list(x))
3 3 | list(tuple(x))
4 4 | tuple(list(x))
@ -92,7 +92,7 @@ C414.py:6:1: C414 [*] Unnecessary `set` call within `set()`
|
= help: Remove the inner `set` call
Suggested fix
Unsafe fix
3 3 | list(tuple(x))
4 4 | tuple(list(x))
5 5 | tuple(tuple(x))
@ -113,7 +113,7 @@ C414.py:7:1: C414 [*] Unnecessary `list` call within `set()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
4 4 | tuple(list(x))
5 5 | tuple(tuple(x))
6 6 | set(set(x))
@ -134,7 +134,7 @@ C414.py:8:1: C414 [*] Unnecessary `tuple` call within `set()`
|
= help: Remove the inner `tuple` call
Suggested fix
Unsafe fix
5 5 | tuple(tuple(x))
6 6 | set(set(x))
7 7 | set(list(x))
@ -155,7 +155,7 @@ C414.py:9:1: C414 [*] Unnecessary `sorted` call within `set()`
|
= help: Remove the inner `sorted` call
Suggested fix
Unsafe fix
6 6 | set(set(x))
7 7 | set(list(x))
8 8 | set(tuple(x))
@ -176,7 +176,7 @@ C414.py:10:1: C414 [*] Unnecessary `sorted` call within `set()`
|
= help: Remove the inner `sorted` call
Suggested fix
Unsafe fix
7 7 | set(list(x))
8 8 | set(tuple(x))
9 9 | set(sorted(x))
@ -197,7 +197,7 @@ C414.py:11:1: C414 [*] Unnecessary `reversed` call within `set()`
|
= help: Remove the inner `reversed` call
Suggested fix
Unsafe fix
8 8 | set(tuple(x))
9 9 | set(sorted(x))
10 10 | set(sorted(x, key=lambda y: y))
@ -218,7 +218,7 @@ C414.py:12:1: C414 [*] Unnecessary `list` call within `sorted()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
9 9 | set(sorted(x))
10 10 | set(sorted(x, key=lambda y: y))
11 11 | set(reversed(x))
@ -239,7 +239,7 @@ C414.py:13:1: C414 [*] Unnecessary `tuple` call within `sorted()`
|
= help: Remove the inner `tuple` call
Suggested fix
Unsafe fix
10 10 | set(sorted(x, key=lambda y: y))
11 11 | set(reversed(x))
12 12 | sorted(list(x))
@ -260,7 +260,7 @@ C414.py:14:1: C414 [*] Unnecessary `sorted` call within `sorted()`
|
= help: Remove the inner `sorted` call
Suggested fix
Unsafe fix
11 11 | set(reversed(x))
12 12 | sorted(list(x))
13 13 | sorted(tuple(x))
@ -281,7 +281,7 @@ C414.py:15:1: C414 [*] Unnecessary `sorted` call within `sorted()`
|
= help: Remove the inner `sorted` call
Suggested fix
Unsafe fix
12 12 | sorted(list(x))
13 13 | sorted(tuple(x))
14 14 | sorted(sorted(x))
@ -302,7 +302,7 @@ C414.py:16:1: C414 [*] Unnecessary `sorted` call within `sorted()`
|
= help: Remove the inner `sorted` call
Suggested fix
Unsafe fix
13 13 | sorted(tuple(x))
14 14 | sorted(sorted(x))
15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo)
@ -323,7 +323,7 @@ C414.py:17:1: C414 [*] Unnecessary `reversed` call within `sorted()`
|
= help: Remove the inner `reversed` call
Suggested fix
Unsafe fix
14 14 | sorted(sorted(x))
15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo)
16 16 | sorted(sorted(x, reverse=True), reverse=True)
@ -344,7 +344,7 @@ C414.py:18:1: C414 [*] Unnecessary `list` call within `sorted()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo)
16 16 | sorted(sorted(x, reverse=True), reverse=True)
17 17 | sorted(reversed(x))
@ -370,7 +370,7 @@ C414.py:19:1: C414 [*] Unnecessary `list` call within `tuple()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
17 17 | sorted(reversed(x))
18 18 | sorted(list(x), key=lambda y: y)
19 19 | tuple(
@ -394,7 +394,7 @@ C414.py:25:1: C414 [*] Unnecessary `set` call within `set()`
|
= help: Remove the inner `set` call
Suggested fix
Unsafe fix
22 22 | "o"]
23 23 | )
24 24 | )
@ -415,7 +415,7 @@ C414.py:26:1: C414 [*] Unnecessary `list` call within `set()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
23 23 | )
24 24 | )
25 25 | set(set())
@ -435,7 +435,7 @@ C414.py:27:1: C414 [*] Unnecessary `tuple` call within `set()`
|
= help: Remove the inner `tuple` call
Suggested fix
Unsafe fix
24 24 | )
25 25 | set(set())
26 26 | set(list())
@ -456,7 +456,7 @@ C414.py:28:1: C414 [*] Unnecessary `reversed` call within `sorted()`
|
= help: Remove the inner `reversed` call
Suggested fix
Unsafe fix
25 25 | set(set())
26 26 | set(list())
27 27 | set(tuple())
@ -482,7 +482,7 @@ C414.py:37:27: C414 [*] Unnecessary `list` call within `sorted()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
35 35 |
36 36 | # Preserve trailing comments.
37 37 | xxxxxxxxxxx_xxxxx_xxxxx = sorted(
@ -505,7 +505,7 @@ C414.py:44:27: C414 [*] Unnecessary `list` call within `sorted()`
|
= help: Remove the inner `list` call
Suggested fix
Unsafe fix
42 42 | )
43 43 |
44 44 | xxxxxxxxxxx_xxxxx_xxxxx = sorted(

View file

@ -12,7 +12,7 @@ C416.py:6:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
|
= help: Rewrite using `list()`
Suggested fix
Unsafe fix
3 3 | z = [(1,), (2,), (3,)]
4 4 | d = {"a": 1, "b": 2, "c": 3}
5 5 |
@ -32,7 +32,7 @@ C416.py:7:1: C416 [*] Unnecessary `set` comprehension (rewrite using `set()`)
|
= help: Rewrite using `set()`
Suggested fix
Unsafe fix
4 4 | d = {"a": 1, "b": 2, "c": 3}
5 5 |
6 6 | [i for i in x]
@ -53,7 +53,7 @@ C416.py:8:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`)
|
= help: Rewrite using `dict()`
Suggested fix
Unsafe fix
5 5 |
6 6 | [i for i in x]
7 7 | {i for i in x}
@ -74,7 +74,7 @@ C416.py:9:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`)
|
= help: Rewrite using `dict()`
Suggested fix
Unsafe fix
6 6 | [i for i in x]
7 7 | {i for i in x}
8 8 | {k: v for k, v in y}
@ -94,7 +94,7 @@ C416.py:10:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`)
|
= help: Rewrite using `list()`
Suggested fix
Unsafe fix
7 7 | {i for i in x}
8 8 | {k: v for k, v in y}
9 9 | {k: v for k, v in d.items()}
@ -115,7 +115,7 @@ C416.py:11:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`)
|
= help: Rewrite using `dict()`
Suggested fix
Unsafe fix
8 8 | {k: v for k, v in y}
9 9 | {k: v for k, v in d.items()}
10 10 | [(k, v) for k, v in d.items()]
@ -133,7 +133,7 @@ C416.py:24:70: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`
|
= help: Rewrite using `list()`
Suggested fix
Unsafe fix
21 21 | {k: v if v else None for k, v in y}
22 22 |
23 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196

View file

@ -12,7 +12,7 @@ C417.py:3:1: C417 [*] Unnecessary `map` usage (rewrite using a generator express
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
1 1 | # Errors.
2 2 | nums = [1, 2, 3]
3 |-map(lambda x: x + 1, nums)
@ -32,7 +32,7 @@ C417.py:4:1: C417 [*] Unnecessary `map` usage (rewrite using a generator express
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
1 1 | # Errors.
2 2 | nums = [1, 2, 3]
3 3 | map(lambda x: x + 1, nums)
@ -53,7 +53,7 @@ C417.py:5:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehens
|
= help: Replace `map` with a `list` comprehension
Suggested fix
Unsafe fix
2 2 | nums = [1, 2, 3]
3 3 | map(lambda x: x + 1, nums)
4 4 | map(lambda x: str(x), nums)
@ -74,7 +74,7 @@ C417.py:6:1: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehensi
|
= help: Replace `map` with a `set` comprehension
Suggested fix
Unsafe fix
3 3 | map(lambda x: x + 1, nums)
4 4 | map(lambda x: str(x), nums)
5 5 | list(map(lambda x: x * 2, nums))
@ -95,7 +95,7 @@ C417.py:7:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehens
|
= help: Replace `map` with a `dict` comprehension
Suggested fix
Unsafe fix
4 4 | map(lambda x: str(x), nums)
5 5 | list(map(lambda x: x * 2, nums))
6 6 | set(map(lambda x: x % 2 == 0, nums))
@ -116,7 +116,7 @@ C417.py:8:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehens
|
= help: Replace `map` with a `dict` comprehension
Suggested fix
Unsafe fix
5 5 | list(map(lambda x: x * 2, nums))
6 6 | set(map(lambda x: x % 2 == 0, nums))
7 7 | dict(map(lambda v: (v, v**2), nums))
@ -137,7 +137,7 @@ C417.py:9:1: C417 [*] Unnecessary `map` usage (rewrite using a generator express
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
6 6 | set(map(lambda x: x % 2 == 0, nums))
7 7 | dict(map(lambda v: (v, v**2), nums))
8 8 | dict(map(lambda v: [v, v**2], nums))
@ -158,7 +158,7 @@ C417.py:10:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
7 7 | dict(map(lambda v: (v, v**2), nums))
8 8 | dict(map(lambda v: [v, v**2], nums))
9 9 | map(lambda: "const", nums)
@ -179,7 +179,7 @@ C417.py:11:13: C417 [*] Unnecessary `map` usage (rewrite using a generator expre
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
8 8 | dict(map(lambda v: [v, v**2], nums))
9 9 | map(lambda: "const", nums)
10 10 | map(lambda _: 3.0, nums)
@ -200,7 +200,7 @@ C417.py:12:5: C417 [*] Unnecessary `map` usage (rewrite using a generator expres
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
9 9 | map(lambda: "const", nums)
10 10 | map(lambda _: 3.0, nums)
11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123)))
@ -220,7 +220,7 @@ C417.py:13:14: C417 [*] Unnecessary `map` usage (rewrite using a generator expre
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
10 10 | map(lambda _: 3.0, nums)
11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123)))
12 12 | all(map(lambda v: isinstance(v, dict), nums))
@ -241,7 +241,7 @@ C417.py:14:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehen
|
= help: Replace `map` with a `list` comprehension
Suggested fix
Unsafe fix
11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123)))
12 12 | all(map(lambda v: isinstance(v, dict), nums))
13 13 | filter(func, map(lambda v: v, nums))
@ -260,7 +260,7 @@ C417.py:17:8: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehens
|
= help: Replace `map` with a `set` comprehension
Suggested fix
Unsafe fix
14 14 | list(map(lambda x, y: x * y, nums))
15 15 |
16 16 | # When inside f-string, then the fix should be surrounded by whitespace
@ -281,7 +281,7 @@ C417.py:18:8: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehen
|
= help: Replace `map` with a `dict` comprehension
Suggested fix
Unsafe fix
15 15 |
16 16 | # When inside f-string, then the fix should be surrounded by whitespace
17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}"
@ -301,7 +301,7 @@ C417.py:36:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
33 33 | map(lambda x: lambda: x, range(4))
34 34 |
35 35 | # Error: the `x` is overridden by the inner lambda.
@ -321,7 +321,7 @@ C417.py:47:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
44 44 | dict(map(lambda k, v: (k, v), keys, values))
45 45 |
46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121
@ -340,7 +340,7 @@ C417.py:48:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
45 45 |
46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121
47 47 | map(lambda x: x, y if y else z)
@ -357,7 +357,7 @@ C417.py:49:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expres
|
= help: Replace `map` with a generator expression
Suggested fix
Unsafe fix
46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121
47 47 | map(lambda x: x, y if y else z)
48 48 | map(lambda x: x, (y if y else z))

View file

@ -10,7 +10,7 @@ C418.py:1:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the
|
= help: Remove outer `dict` call
Suggested fix
Unsafe fix
1 |-dict({})
1 |+{}
2 2 | dict({'a': 1})
@ -27,7 +27,7 @@ C418.py:2:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the
|
= help: Remove outer `dict` call
Suggested fix
Unsafe fix
1 1 | dict({})
2 |-dict({'a': 1})
2 |+{'a': 1}
@ -46,7 +46,7 @@ C418.py:3:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remov
|
= help: Remove outer `dict` call
Suggested fix
Unsafe fix
1 1 | dict({})
2 2 | dict({'a': 1})
3 |-dict({'x': 1 for x in range(10)})
@ -68,7 +68,7 @@ C418.py:4:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remov
|
= help: Remove outer `dict` call
Suggested fix
Unsafe fix
1 1 | dict({})
2 2 | dict({'a': 1})
3 3 | dict({'x': 1 for x in range(10)})

View file

@ -10,7 +10,7 @@ C419.py:1:5: C419 [*] Unnecessary list comprehension.
|
= help: Remove unnecessary list comprehension
Suggested fix
Unsafe fix
1 |-any([x.id for x in bar])
1 |+any(x.id for x in bar)
2 2 | all([x.id for x in bar])
@ -27,7 +27,7 @@ C419.py:2:5: C419 [*] Unnecessary list comprehension.
|
= help: Remove unnecessary list comprehension
Suggested fix
Unsafe fix
1 1 | any([x.id for x in bar])
2 |-all([x.id for x in bar])
2 |+all(x.id for x in bar)
@ -46,7 +46,7 @@ C419.py:4:5: C419 [*] Unnecessary list comprehension.
|
= help: Remove unnecessary list comprehension
Suggested fix
Unsafe fix
1 1 | any([x.id for x in bar])
2 2 | all([x.id for x in bar])
3 3 | any( # first comment
@ -67,7 +67,7 @@ C419.py:7:5: C419 [*] Unnecessary list comprehension.
|
= help: Remove unnecessary list comprehension
Suggested fix
Unsafe fix
4 4 | [x.id for x in bar], # second comment
5 5 | ) # third comment
6 6 | all( # first comment
@ -88,7 +88,7 @@ C419.py:9:5: C419 [*] Unnecessary list comprehension.
|
= help: Remove unnecessary list comprehension
Suggested fix
Unsafe fix
6 6 | all( # first comment
7 7 | [x.id for x in bar], # second comment
8 8 | ) # third comment
@ -115,7 +115,7 @@ C419.py:24:5: C419 [*] Unnecessary list comprehension.
|
= help: Remove unnecessary list comprehension
Suggested fix
Unsafe fix
21 21 |
22 22 | # Special comment handling
23 23 | any(
@ -147,7 +147,7 @@ C419.py:35:5: C419 [*] Unnecessary list comprehension.
|
= help: Remove unnecessary list comprehension
Suggested fix
Unsafe fix
32 32 |
33 33 | # Weird case where the function call, opening bracket, and comment are all
34 34 | # on the same line.

View file

@ -9,7 +9,7 @@ EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variabl
|
= help: Assign to variable; remove string literal
Suggested fix
Unsafe fix
2 2 |
3 3 |
4 4 | def f_a():
@ -29,7 +29,7 @@ EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to var
|
= help: Assign to variable; remove f-string literal
Suggested fix
Unsafe fix
15 15 |
16 16 | def f_b():
17 17 | example = "example"
@ -48,7 +48,7 @@ EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, ass
|
= help: Assign to variable; remove `.format()` string
Suggested fix
Unsafe fix
19 19 |
20 20 |
21 21 | def f_c():
@ -77,7 +77,7 @@ EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variab
|
= help: Assign to variable; remove string literal
Suggested fix
Unsafe fix
36 36 | def nested():
37 37 | msg = "hello"
38 38 |
@ -107,7 +107,7 @@ EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variab
|
= help: Assign to variable; remove string literal
Suggested fix
Unsafe fix
48 48 |
49 49 | def f_fix_indentation_check(foo):
50 50 | if foo:
@ -128,7 +128,7 @@ EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to var
|
= help: Assign to variable; remove f-string literal
Suggested fix
Unsafe fix
51 51 | raise RuntimeError("This is an example exception")
52 52 | else:
53 53 | if foo == "foo":
@ -148,7 +148,7 @@ EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, ass
|
= help: Assign to variable; remove `.format()` string
Suggested fix
Unsafe fix
52 52 | else:
53 53 | if foo == "foo":
54 54 | raise RuntimeError(f"This is an exception: {foo}")

View file

@ -9,7 +9,7 @@ EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variabl
|
= help: Assign to variable; remove string literal
Suggested fix
Unsafe fix
2 2 |
3 3 |
4 4 | def f_a():
@ -28,7 +28,7 @@ EM.py:9:24: EM101 [*] Exception must not use a string literal, assign to variabl
|
= help: Assign to variable; remove string literal
Suggested fix
Unsafe fix
6 6 |
7 7 |
8 8 | def f_a_short():
@ -47,7 +47,7 @@ EM.py:13:24: EM101 [*] Exception must not use a string literal, assign to variab
|
= help: Assign to variable; remove string literal
Suggested fix
Unsafe fix
10 10 |
11 11 |
12 12 | def f_a_empty():
@ -67,7 +67,7 @@ EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to var
|
= help: Assign to variable; remove f-string literal
Suggested fix
Unsafe fix
15 15 |
16 16 | def f_b():
17 17 | example = "example"
@ -86,7 +86,7 @@ EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, ass
|
= help: Assign to variable; remove `.format()` string
Suggested fix
Unsafe fix
19 19 |
20 20 |
21 21 | def f_c():
@ -115,7 +115,7 @@ EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variab
|
= help: Assign to variable; remove string literal
Suggested fix
Unsafe fix
36 36 | def nested():
37 37 | msg = "hello"
38 38 |
@ -145,7 +145,7 @@ EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variab
|
= help: Assign to variable; remove string literal
Suggested fix
Unsafe fix
48 48 |
49 49 | def f_fix_indentation_check(foo):
50 50 | if foo:
@ -166,7 +166,7 @@ EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to var
|
= help: Assign to variable; remove f-string literal
Suggested fix
Unsafe fix
51 51 | raise RuntimeError("This is an example exception")
52 52 | else:
53 53 | if foo == "foo":
@ -186,7 +186,7 @@ EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, ass
|
= help: Assign to variable; remove `.format()` string
Suggested fix
Unsafe fix
52 52 | else:
53 53 | if foo == "foo":
54 54 | raise RuntimeError(f"This is an exception: {foo}")

View file

@ -8,7 +8,7 @@ EXE004_1.py:1:1: EXE004 [*] Avoid whitespace before shebang
|
= help: Remove whitespace before shebang
Fix
Safe fix
1 |- #!/usr/bin/python
1 |+#!/usr/bin/python

View file

@ -9,7 +9,7 @@ EXE004_4.py:1:1: EXE004 [*] Avoid whitespace before shebang
|
= help: Remove whitespace before shebang
Fix
Safe fix
1 |-
2 |- #!/usr/bin/env python
1 |+#!/usr/bin/env python

View file

@ -10,7 +10,7 @@ ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
1 |-_ = "a" "b" "c"
1 |+_ = "ab" "c"
2 2 |
@ -26,7 +26,7 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
1 |-_ = "a" "b" "c"
1 |+_ = "a" "bc"
2 2 |
@ -44,7 +44,7 @@ ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
35 35 | b"def"
36 36 | )
37 37 |
@ -68,7 +68,7 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
38 38 | _ = """a""" """b"""
39 39 |
40 40 | _ = """a
@ -89,7 +89,7 @@ ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
41 41 | b""" """c
42 42 | d"""
43 43 |
@ -143,7 +143,7 @@ ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
49 49 |
50 50 | _ = 'a' "b"
51 51 |
@ -163,7 +163,7 @@ ISC.py:64:10: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
61 61 | _ = foo + "abc" + bar
62 62 |
63 63 | # Multiple strings nested inside a f-string
@ -183,7 +183,7 @@ ISC.py:64:14: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
61 61 | _ = foo + "abc" + bar
62 62 |
63 63 | # Multiple strings nested inside a f-string
@ -204,7 +204,7 @@ ISC.py:65:14: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
62 62 |
63 63 | # Multiple strings nested inside a f-string
64 64 | _ = f"a {'b' 'c' 'd'} e"
@ -244,7 +244,7 @@ ISC.py:72:14: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
69 69 | } jkl"""
70 70 |
71 71 | # Nested f-strings
@ -265,7 +265,7 @@ ISC.py:73:10: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
70 70 |
71 71 | # Nested f-strings
72 72 | _ = "a" f"b {f"c" f"d"} e" "f"
@ -286,7 +286,7 @@ ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
70 70 |
71 71 | # Nested f-strings
72 72 | _ = "a" f"b {f"c" f"d"} e" "f"

View file

@ -10,7 +10,7 @@ ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
1 |-_ = "a" "b" "c"
1 |+_ = "ab" "c"
2 2 |
@ -26,7 +26,7 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
1 |-_ = "a" "b" "c"
1 |+_ = "a" "bc"
2 2 |
@ -44,7 +44,7 @@ ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
35 35 | b"def"
36 36 | )
37 37 |
@ -68,7 +68,7 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
38 38 | _ = """a""" """b"""
39 39 |
40 40 | _ = """a
@ -89,7 +89,7 @@ ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
41 41 | b""" """c
42 42 | d"""
43 43 |
@ -143,7 +143,7 @@ ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
49 49 |
50 50 | _ = 'a' "b"
51 51 |
@ -163,7 +163,7 @@ ISC.py:64:10: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
61 61 | _ = foo + "abc" + bar
62 62 |
63 63 | # Multiple strings nested inside a f-string
@ -183,7 +183,7 @@ ISC.py:64:14: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
61 61 | _ = foo + "abc" + bar
62 62 |
63 63 | # Multiple strings nested inside a f-string
@ -204,7 +204,7 @@ ISC.py:65:14: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
62 62 |
63 63 | # Multiple strings nested inside a f-string
64 64 | _ = f"a {'b' 'c' 'd'} e"
@ -244,7 +244,7 @@ ISC.py:72:14: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
69 69 | } jkl"""
70 70 |
71 71 | # Nested f-strings
@ -265,7 +265,7 @@ ISC.py:73:10: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
70 70 |
71 71 | # Nested f-strings
72 72 | _ = "a" f"b {f"c" f"d"} e" "f"
@ -286,7 +286,7 @@ ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line
|
= help: Combine string literals
Fix
Safe fix
70 70 |
71 71 | # Nested f-strings
72 72 | _ = "a" f"b {f"c" f"d"} e" "f"

View file

@ -11,7 +11,7 @@ defaults.py:6:12: ICN001 [*] `altair` should be imported as `alt`
|
= help: Alias `altair` to `alt`
Suggested fix
Unsafe fix
3 3 |
4 4 |
5 5 | def unconventional():
@ -43,7 +43,7 @@ defaults.py:8:12: ICN001 [*] `numpy` should be imported as `np`
|
= help: Alias `numpy` to `np`
Suggested fix
Unsafe fix
5 5 | def unconventional():
6 6 | import altair
7 7 | import matplotlib.pyplot
@ -64,7 +64,7 @@ defaults.py:9:12: ICN001 [*] `pandas` should be imported as `pd`
|
= help: Alias `pandas` to `pd`
Suggested fix
Unsafe fix
6 6 | import altair
7 7 | import matplotlib.pyplot
8 8 | import numpy
@ -85,7 +85,7 @@ defaults.py:10:12: ICN001 [*] `seaborn` should be imported as `sns`
|
= help: Alias `seaborn` to `sns`
Suggested fix
Unsafe fix
7 7 | import matplotlib.pyplot
8 8 | import numpy
9 9 | import pandas
@ -105,7 +105,7 @@ defaults.py:11:12: ICN001 [*] `tkinter` should be imported as `tk`
|
= help: Alias `tkinter` to `tk`
Suggested fix
Unsafe fix
8 8 | import numpy
9 9 | import pandas
10 10 | import seaborn
@ -124,7 +124,7 @@ defaults.py:12:12: ICN001 [*] `networkx` should be imported as `nx`
|
= help: Alias `networkx` to `nx`
Suggested fix
Unsafe fix
9 9 | import pandas
10 10 | import seaborn
11 11 | import tkinter
@ -144,7 +144,7 @@ defaults.py:16:22: ICN001 [*] `altair` should be imported as `alt`
|
= help: Alias `altair` to `alt`
Suggested fix
Unsafe fix
13 13 |
14 14 |
15 15 | def unconventional_aliases():
@ -165,7 +165,7 @@ defaults.py:17:33: ICN001 [*] `matplotlib.pyplot` should be imported as `plt`
|
= help: Alias `matplotlib.pyplot` to `plt`
Suggested fix
Unsafe fix
14 14 |
15 15 | def unconventional_aliases():
16 16 | import altair as altr
@ -186,7 +186,7 @@ defaults.py:18:21: ICN001 [*] `numpy` should be imported as `np`
|
= help: Alias `numpy` to `np`
Suggested fix
Unsafe fix
15 15 | def unconventional_aliases():
16 16 | import altair as altr
17 17 | import matplotlib.pyplot as plot
@ -207,7 +207,7 @@ defaults.py:19:22: ICN001 [*] `pandas` should be imported as `pd`
|
= help: Alias `pandas` to `pd`
Suggested fix
Unsafe fix
16 16 | import altair as altr
17 17 | import matplotlib.pyplot as plot
18 18 | import numpy as nmp
@ -228,7 +228,7 @@ defaults.py:20:23: ICN001 [*] `seaborn` should be imported as `sns`
|
= help: Alias `seaborn` to `sns`
Suggested fix
Unsafe fix
17 17 | import matplotlib.pyplot as plot
18 18 | import numpy as nmp
19 19 | import pandas as pdas
@ -248,7 +248,7 @@ defaults.py:21:23: ICN001 [*] `tkinter` should be imported as `tk`
|
= help: Alias `tkinter` to `tk`
Suggested fix
Unsafe fix
18 18 | import numpy as nmp
19 19 | import pandas as pdas
20 20 | import seaborn as sbrn
@ -269,7 +269,7 @@ defaults.py:22:24: ICN001 [*] `networkx` should be imported as `nx`
|
= help: Alias `networkx` to `nx`
Suggested fix
Unsafe fix
19 19 | import pandas as pdas
20 20 | import seaborn as sbrn
21 21 | import tkinter as tkr

View file

@ -12,7 +12,7 @@ tricky.py:7:16: ICN001 [*] `pandas` should be imported as `pd`
|
= help: Alias `pandas` to `pd`
Suggested fix
Unsafe fix
3 3 |
4 4 | def rename_global():
5 5 | try:

View file

@ -12,7 +12,7 @@ LOG001.py:3:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers
|
= help: Replace with `logging.getLogger()`
Suggested fix
Unsafe fix
1 1 | import logging
2 2 |
3 |-logging.Logger(__name__)
@ -29,7 +29,7 @@ LOG001.py:4:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers
|
= help: Replace with `logging.getLogger()`
Suggested fix
Unsafe fix
1 1 | import logging
2 2 |
3 3 | logging.Logger(__name__)

View file

@ -10,7 +10,7 @@ LOG002.py:11:11: LOG002 [*] Use `__name__` with `logging.getLogger()`
|
= help: Replace with `name`
Suggested fix
Unsafe fix
8 8 | logging.getLogger(name="custom")
9 9 |
10 10 | # LOG002
@ -31,7 +31,7 @@ LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()`
|
= help: Replace with `name`
Suggested fix
Unsafe fix
9 9 |
10 10 | # LOG002
11 11 | getLogger(__file__)
@ -51,7 +51,7 @@ LOG002.py:14:19: LOG002 [*] Use `__name__` with `logging.getLogger()`
|
= help: Replace with `name`
Suggested fix
Unsafe fix
11 11 | getLogger(__file__)
12 12 | logging.getLogger(name=__file__)
13 13 |
@ -69,7 +69,7 @@ LOG002.py:15:16: LOG002 [*] Use `__name__` with `logging.getLogger()`
|
= help: Replace with `name`
Suggested fix
Unsafe fix
12 12 | logging.getLogger(name=__file__)
13 13 |
14 14 | logging.getLogger(__cached__)

View file

@ -11,7 +11,7 @@ LOG009.py:3:1: LOG009 [*] Use of undocumented `logging.WARN` constant
|
= help: Replace `logging.WARN` with `logging.WARNING`
Fix
Safe fix
1 1 | import logging
2 2 |
3 |-logging.WARN # LOG009
@ -30,7 +30,7 @@ LOG009.py:8:1: LOG009 [*] Use of undocumented `logging.WARN` constant
|
= help: Replace `logging.WARN` with `logging.WARNING`
Fix
Safe fix
5 5 |
6 6 | from logging import WARN, WARNING
7 7 |

View file

@ -12,7 +12,7 @@ G010.py:6:9: G010 [*] Logging statement uses `warn` instead of `warning`
|
= help: Convert to `warn`
Fix
Safe fix
3 3 |
4 4 | from logging_setup import logger
5 5 |
@ -33,7 +33,7 @@ G010.py:8:8: G010 [*] Logging statement uses `warn` instead of `warning`
|
= help: Convert to `warn`
Fix
Safe fix
5 5 |
6 6 | logging.warn("Hello World!")
7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate
@ -54,7 +54,7 @@ G010.py:10:11: G010 [*] Logging statement uses `warn` instead of `warning`
|
= help: Convert to `warn`
Fix
Safe fix
7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate
8 8 | logger.warn("Hello world!")
9 9 |
@ -74,7 +74,7 @@ G010.py:13:1: G010 [*] Logging statement uses `warn` instead of `warning`
|
= help: Convert to `warn`
Fix
Safe fix
10 10 | logging . warn("Hello World!")
11 11 |
12 12 | from logging import warn, warning, exception

View file

@ -10,7 +10,7 @@ PIE790.py:4:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
1 1 | class Foo:
2 2 | """buzz"""
3 3 |
@ -28,7 +28,7 @@ PIE790.py:9:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
6 6 |
7 7 | if foo:
8 8 | """foo"""
@ -46,7 +46,7 @@ PIE790.py:14:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
11 11 |
12 12 | def multi_statement() -> None:
13 13 | """This is a function."""
@ -65,7 +65,7 @@ PIE790.py:21:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
18 18 | pass
19 19 | else:
20 20 | """bar"""
@ -83,7 +83,7 @@ PIE790.py:28:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
25 25 | pass
26 26 | else:
27 27 | """bar"""
@ -101,7 +101,7 @@ PIE790.py:35:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
32 32 | pass
33 33 | else:
34 34 | """bar"""
@ -119,7 +119,7 @@ PIE790.py:42:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
39 39 | pass
40 40 | else:
41 41 | """bar"""
@ -137,7 +137,7 @@ PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
47 47 | buzz
48 48 | """
49 49 |
@ -155,7 +155,7 @@ PIE790.py:58:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
55 55 | buzz
56 56 | """
57 57 |
@ -175,7 +175,7 @@ PIE790.py:65:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
62 62 | """
63 63 | buzz
64 64 | """
@ -193,7 +193,7 @@ PIE790.py:74:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
71 71 | bar()
72 72 | except ValueError:
73 73 | """bar"""
@ -213,7 +213,7 @@ PIE790.py:79:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
76 76 |
77 77 | for _ in range(10):
78 78 | """buzz"""
@ -233,7 +233,7 @@ PIE790.py:83:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
80 80 |
81 81 | async for _ in range(10):
82 82 | """buzz"""
@ -251,7 +251,7 @@ PIE790.py:87:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
84 84 |
85 85 | while cond:
86 86 | """buzz"""
@ -271,7 +271,7 @@ PIE790.py:92:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
89 89 |
90 90 | with bar:
91 91 | """buzz"""
@ -289,7 +289,7 @@ PIE790.py:96:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
93 93 |
94 94 | async with bar:
95 95 | """buzz"""
@ -307,7 +307,7 @@ PIE790.py:101:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
98 98 |
99 99 | def foo() -> None:
100 100 | """buzz"""
@ -326,7 +326,7 @@ PIE790.py:130:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
127 127 |
128 128 | def foo():
129 129 | print("foo")
@ -344,7 +344,7 @@ PIE790.py:136:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
133 133 | def foo():
134 134 | """A docstring."""
135 135 | print("foo")
@ -362,7 +362,7 @@ PIE790.py:140:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
138 138 |
139 139 | for i in range(10):
140 140 | pass
@ -382,7 +382,7 @@ PIE790.py:141:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
138 138 |
139 139 | for i in range(10):
140 140 | pass
@ -401,7 +401,7 @@ PIE790.py:144:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
141 141 | pass
142 142 |
143 143 | for i in range(10):
@ -421,7 +421,7 @@ PIE790.py:146:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
143 143 | for i in range(10):
144 144 | pass
145 145 |
@ -439,7 +439,7 @@ PIE790.py:149:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
146 146 | pass
147 147 |
148 148 | for i in range(10):
@ -456,7 +456,7 @@ PIE790.py:150:5: PIE790 [*] Unnecessary `pass` statement
|
= help: Remove unnecessary `pass`
Fix
Safe fix
147 147 |
148 148 | for i in range(10):
149 149 | pass # comment

View file

@ -12,7 +12,7 @@ PIE794.py:4:5: PIE794 [*] Class field `name` is defined multiple times
|
= help: Remove duplicate field definition for `name`
Suggested fix
Unsafe fix
1 1 | class Foo(BaseModel):
2 2 | name = StringField()
3 3 | # ....
@ -32,7 +32,7 @@ PIE794.py:13:5: PIE794 [*] Class field `name` is defined multiple times
|
= help: Remove duplicate field definition for `name`
Suggested fix
Unsafe fix
10 10 | class Foo(BaseModel):
11 11 | name: str = StringField()
12 12 | # ....
@ -50,7 +50,7 @@ PIE794.py:23:5: PIE794 [*] Class field `bar` is defined multiple times
|
= help: Remove duplicate field definition for `bar`
Suggested fix
Unsafe fix
20 20 | bar: str = StringField()
21 21 | foo: bool = BooleanField()
22 22 | # ...
@ -68,7 +68,7 @@ PIE794.py:40:5: PIE794 [*] Class field `bar` is defined multiple times
|
= help: Remove duplicate field definition for `bar`
Suggested fix
Unsafe fix
37 37 | bar: str = StringField()
38 38 | foo: bool = BooleanField()
39 39 | # ...

View file

@ -10,7 +10,7 @@ PIE804.py:1:1: PIE804 [*] Unnecessary `dict` kwargs
|
= help: Remove unnecessary kwargs
Fix
Safe fix
1 |-foo(**{"bar": True}) # PIE804
1 |+foo(bar=True) # PIE804
2 2 |
@ -28,7 +28,7 @@ PIE804.py:3:1: PIE804 [*] Unnecessary `dict` kwargs
|
= help: Remove unnecessary kwargs
Fix
Safe fix
1 1 | foo(**{"bar": True}) # PIE804
2 2 |
3 |-foo(**{"r2d2": True}) # PIE804
@ -48,7 +48,7 @@ PIE804.py:5:1: PIE804 [*] Unnecessary `dict` kwargs
|
= help: Remove unnecessary kwargs
Fix
Safe fix
2 2 |
3 3 | foo(**{"r2d2": True}) # PIE804
4 4 |
@ -69,7 +69,7 @@ PIE804.py:7:1: PIE804 [*] Unnecessary `dict` kwargs
|
= help: Remove unnecessary kwargs
Fix
Safe fix
4 4 |
5 5 | Foo.objects.create(**{"bar": True}) # PIE804
6 6 |
@ -90,7 +90,7 @@ PIE804.py:9:1: PIE804 [*] Unnecessary `dict` kwargs
|
= help: Remove unnecessary kwargs
Fix
Safe fix
6 6 |
7 7 | Foo.objects.create(**{"_id": some_id}) # PIE804
8 8 |
@ -109,7 +109,7 @@ PIE804.py:11:1: PIE804 [*] Unnecessary `dict` kwargs
|
= help: Remove unnecessary kwargs
Fix
Safe fix
8 8 |
9 9 | Foo.objects.create(**{**bar}) # PIE804
10 10 |

View file

@ -10,7 +10,7 @@ PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda
|
= help: Replace with `list`
Fix
Safe fix
1 1 | @dataclass
2 2 | class Foo:
3 |- foo: List[str] = field(default_factory=lambda: []) # PIE807
@ -27,7 +27,7 @@ PIE807.py:7:36: PIE807 [*] Prefer `list` over useless lambda
|
= help: Replace with `list`
Fix
Safe fix
4 4 |
5 5 |
6 6 | class FooTable(BaseTable):
@ -45,7 +45,7 @@ PIE807.py:11:28: PIE807 [*] Prefer `list` over useless lambda
|
= help: Replace with `list`
Fix
Safe fix
8 8 |
9 9 |
10 10 | class FooTable(BaseTable):

View file

@ -11,7 +11,7 @@ PIE808.py:2:7: PIE808 [*] Unnecessary `start` argument in `range`
|
= help: Remove `start` argument
Fix
Safe fix
1 1 | # PIE808
2 |-range(0, 10)
2 |+range(10)

View file

@ -11,7 +11,7 @@ PIE810.py:2:1: PIE810 [*] Call `startswith` once with a `tuple`
|
= help: Merge into a single `startswith` call
Suggested fix
Unsafe fix
1 1 | # error
2 |-obj.startswith("foo") or obj.startswith("bar")
2 |+obj.startswith(("foo", "bar"))
@ -30,7 +30,7 @@ PIE810.py:4:1: PIE810 [*] Call `endswith` once with a `tuple`
|
= help: Merge into a single `endswith` call
Suggested fix
Unsafe fix
1 1 | # error
2 2 | obj.startswith("foo") or obj.startswith("bar")
3 3 | # error
@ -51,7 +51,7 @@ PIE810.py:6:1: PIE810 [*] Call `startswith` once with a `tuple`
|
= help: Merge into a single `startswith` call
Suggested fix
Unsafe fix
3 3 | # error
4 4 | obj.endswith("foo") or obj.endswith("bar")
5 5 | # error
@ -72,7 +72,7 @@ PIE810.py:8:1: PIE810 [*] Call `startswith` once with a `tuple`
|
= help: Merge into a single `startswith` call
Suggested fix
Unsafe fix
5 5 | # error
6 6 | obj.startswith(foo) or obj.startswith(bar)
7 7 | # error
@ -93,7 +93,7 @@ PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple`
|
= help: Merge into a single `startswith` call
Suggested fix
Unsafe fix
7 7 | # error
8 8 | obj.startswith(foo) or obj.startswith("foo")
9 9 | # error

View file

@ -12,7 +12,7 @@ PYI009.pyi:3:5: PYI009 [*] Empty body should contain `...`, not `pass`
|
= help: Replace `pass` with `...`
Fix
Safe fix
1 1 | def bar(): ... # OK
2 2 | def foo():
3 |- pass # ERROR PYI009, since we're in a stub file
@ -29,7 +29,7 @@ PYI009.pyi:8:5: PYI009 [*] Empty body should contain `...`, not `pass`
|
= help: Replace `pass` with `...`
Fix
Safe fix
5 5 | class Bar: ... # OK
6 6 |
7 7 | class Foo:

View file

@ -11,7 +11,7 @@ PYI010.pyi:6:5: PYI010 [*] Function body must contain only `...`
|
= help: Replace function body with `...`
Fix
Safe fix
3 3 | """foo""" # OK, docstrings are handled by another rule
4 4 |
5 5 | def buzz():
@ -31,7 +31,7 @@ PYI010.pyi:9:5: PYI010 [*] Function body must contain only `...`
|
= help: Replace function body with `...`
Fix
Safe fix
6 6 | print("buzz") # ERROR PYI010
7 7 |
8 8 | def foo2():
@ -51,7 +51,7 @@ PYI010.pyi:12:5: PYI010 [*] Function body must contain only `...`
|
= help: Replace function body with `...`
Fix
Safe fix
9 9 | 123 # ERROR PYI010
10 10 |
11 11 | def bizz():

View file

@ -12,7 +12,7 @@ PYI011.pyi:10:14: PYI011 [*] Only simple default values allowed for typed argume
|
= help: Replace default value with `...`
Fix
Safe fix
7 7 |
8 8 | def f12(
9 9 | x,
@ -37,7 +37,7 @@ PYI011.pyi:38:9: PYI011 [*] Only simple default values allowed for typed argumen
|
= help: Replace default value with `...`
Fix
Safe fix
35 35 | def f152(
36 36 | x: dict[
37 37 | int, int
@ -74,7 +74,7 @@ PYI011.pyi:46:9: PYI011 [*] Only simple default values allowed for typed argumen
|
= help: Replace default value with `...`
Fix
Safe fix
43 43 | def f153(
44 44 | x: list[
45 45 | int
@ -111,7 +111,7 @@ PYI011.pyi:63:9: PYI011 [*] Only simple default values allowed for typed argumen
|
= help: Replace default value with `...`
Fix
Safe fix
60 60 | def f154(
61 61 | x: tuple[
62 62 | str, tuple[str, ...]
@ -138,7 +138,7 @@ PYI011.pyi:71:9: PYI011 [*] Only simple default values allowed for typed argumen
|
= help: Replace default value with `...`
Fix
Safe fix
68 68 | def f141(
69 69 | x: list[
70 70 | int
@ -164,7 +164,7 @@ PYI011.pyi:78:9: PYI011 [*] Only simple default values allowed for typed argumen
|
= help: Replace default value with `...`
Fix
Safe fix
75 75 | def f142(
76 76 | x: list[
77 77 | int
@ -190,7 +190,7 @@ PYI011.pyi:85:9: PYI011 [*] Only simple default values allowed for typed argumen
|
= help: Replace default value with `...`
Fix
Safe fix
82 82 | def f16(
83 83 | x: frozenset[
84 84 | bytes
@ -215,7 +215,7 @@ PYI011.pyi:90:14: PYI011 [*] Only simple default values allowed for typed argume
|
= help: Replace default value with `...`
Fix
Safe fix
87 87 | )
88 88 | ) -> None: ...
89 89 | def f17(
@ -239,7 +239,7 @@ PYI011.pyi:94:14: PYI011 [*] Only simple default values allowed for typed argume
|
= help: Replace default value with `...`
Fix
Safe fix
91 91 | + "bar",
92 92 | ) -> None: ...
93 93 | def f18(
@ -263,7 +263,7 @@ PYI011.pyi:98:17: PYI011 [*] Only simple default values allowed for typed argume
|
= help: Replace default value with `...`
Fix
Safe fix
95 95 | + b"bar",
96 96 | ) -> None: ...
97 97 | def f19(
@ -287,7 +287,7 @@ PYI011.pyi:102:14: PYI011 [*] Only simple default values allowed for typed argum
|
= help: Replace default value with `...`
Fix
Safe fix
99 99 | + 4,
100 100 | ) -> None: ...
101 101 | def f20(
@ -311,7 +311,7 @@ PYI011.pyi:106:18: PYI011 [*] Only simple default values allowed for typed argum
|
= help: Replace default value with `...`
Fix
Safe fix
103 103 | + 5, # Error PYI011 Only simple default values allowed for typed arguments
104 104 | ) -> None: ...
105 105 | def f21(
@ -335,7 +335,7 @@ PYI011.pyi:110:18: PYI011 [*] Only simple default values allowed for typed argum
|
= help: Replace default value with `...`
Fix
Safe fix
107 107 | - 3j, # Error PYI011 Only simple default values allowed for typed arguments
108 108 | ) -> None: ...
109 109 | def f22(
@ -357,7 +357,7 @@ PYI011.pyi:138:16: PYI011 [*] Only simple default values allowed for typed argum
|
= help: Replace default value with `...`
Fix
Safe fix
135 135 | x: float = -math.inf, # OK
136 136 | ) -> None: ...
137 137 | def f31(
@ -378,7 +378,7 @@ PYI011.pyi:141:16: PYI011 [*] Only simple default values allowed for typed argum
|
= help: Replace default value with `...`
Fix
Safe fix
138 138 | x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments
139 139 | ) -> None: ...
140 140 | def f32(
@ -399,7 +399,7 @@ PYI011.pyi:147:16: PYI011 [*] Only simple default values allowed for typed argum
|
= help: Replace default value with `...`
Fix
Safe fix
144 144 | x: float = math.nan, # OK
145 145 | ) -> None: ...
146 146 | def f34(
@ -422,7 +422,7 @@ PYI011.pyi:150:18: PYI011 [*] Only simple default values allowed for typed argum
|
= help: Replace default value with `...`
Fix
Safe fix
147 147 | x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments
148 148 | ) -> None: ...
149 149 | def f35(
@ -445,7 +445,7 @@ PYI011.pyi:159:14: PYI011 [*] Only simple default values allowed for typed argum
|
= help: Replace default value with `...`
Fix
Safe fix
156 156 | ) -> None: ...
157 157 | def f37(
158 158 | *,

View file

@ -12,7 +12,7 @@ PYI012.pyi:5:5: PYI012 [*] Class body must not contain `pass`
|
= help: Remove unnecessary `pass`
Fix
Safe fix
2 2 |
3 3 | class OneAttributeClass:
4 4 | value: int
@ -30,7 +30,7 @@ PYI012.pyi:8:5: PYI012 [*] Class body must not contain `pass`
|
= help: Remove unnecessary `pass`
Fix
Safe fix
5 5 | pass # PYI012 Class body must not contain `pass`
6 6 |
7 7 | class OneAttributeClassRev:
@ -50,7 +50,7 @@ PYI012.pyi:16:5: PYI012 [*] Class body must not contain `pass`
|
= help: Remove unnecessary `pass`
Fix
Safe fix
13 13 | My body only contains pass.
14 14 | """
15 15 |
@ -70,7 +70,7 @@ PYI012.pyi:20:5: PYI012 [*] Class body must not contain `pass`
|
= help: Remove unnecessary `pass`
Fix
Safe fix
17 17 |
18 18 | class NonEmptyChild(Exception):
19 19 | value: int
@ -88,7 +88,7 @@ PYI012.pyi:23:5: PYI012 [*] Class body must not contain `pass`
|
= help: Remove unnecessary `pass`
Fix
Safe fix
20 20 | pass # PYI012 Class body must not contain `pass`
21 21 |
22 22 | class NonEmptyChild2(Exception):
@ -108,7 +108,7 @@ PYI012.pyi:28:5: PYI012 [*] Class body must not contain `pass`
|
= help: Remove unnecessary `pass`
Fix
Safe fix
25 25 |
26 26 | class NonEmptyWithInit:
27 27 | value: int

View file

@ -10,7 +10,7 @@ PYI013.py:3:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
1 1 | class OneAttributeClass:
2 2 | value: int
3 |- ...
@ -27,7 +27,7 @@ PYI013.py:7:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
4 4 |
5 5 |
6 6 | class OneAttributeClass2:
@ -45,7 +45,7 @@ PYI013.py:12:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
10 10 |
11 11 | class TwoEllipsesClass:
12 12 | ...
@ -63,7 +63,7 @@ PYI013.py:13:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
10 10 |
11 11 | class TwoEllipsesClass:
12 12 | ...
@ -81,7 +81,7 @@ PYI013.py:21:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
18 18 | My body only contains an ellipsis.
19 19 | """
20 20 |
@ -99,7 +99,7 @@ PYI013.py:26:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
23 23 |
24 24 | class NonEmptyChild(Exception):
25 25 | value: int
@ -117,7 +117,7 @@ PYI013.py:30:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
27 27 |
28 28 |
29 29 | class NonEmptyChild2(Exception):
@ -137,7 +137,7 @@ PYI013.py:36:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
33 33 |
34 34 | class NonEmptyWithInit:
35 35 | value: int

View file

@ -12,7 +12,7 @@ PYI013.pyi:5:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
2 2 |
3 3 | class OneAttributeClass:
4 4 | value: int
@ -30,7 +30,7 @@ PYI013.pyi:8:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
5 5 | ... # Error
6 6 |
7 7 | class OneAttributeClass2:
@ -48,7 +48,7 @@ PYI013.pyi:12:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
9 9 | value: int
10 10 |
11 11 | class MyClass:
@ -66,7 +66,7 @@ PYI013.pyi:16:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
13 13 | value: int
14 14 |
15 15 | class TwoEllipsesClass:
@ -86,7 +86,7 @@ PYI013.pyi:17:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
14 14 |
15 15 | class TwoEllipsesClass:
16 16 | ...
@ -106,7 +106,7 @@ PYI013.pyi:24:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
21 21 | My body only contains an ellipsis.
22 22 | """
23 23 |
@ -126,7 +126,7 @@ PYI013.pyi:28:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
25 25 |
26 26 | class NonEmptyChild(Exception):
27 27 | value: int
@ -144,7 +144,7 @@ PYI013.pyi:31:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
28 28 | ... # Error
29 29 |
30 30 | class NonEmptyChild2(Exception):
@ -164,7 +164,7 @@ PYI013.pyi:36:5: PYI013 [*] Non-empty class body must not contain `...`
|
= help: Remove unnecessary `...`
Fix
Safe fix
33 33 |
34 34 | class NonEmptyWithInit:
35 35 | value: int

View file

@ -12,7 +12,7 @@ PYI014.pyi:3:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
1 1 | def f12(
2 2 | x,
3 |- y=os.pathsep, # Error PYI014
@ -36,7 +36,7 @@ PYI014.pyi:29:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
26 26 | ) -> None: ...
27 27 | def f151(x={1: 2}) -> None: ...
28 28 | def f152(
@ -73,7 +73,7 @@ PYI014.pyi:35:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
32 32 | }
33 33 | ) -> None: ...
34 34 | def f153(
@ -110,7 +110,7 @@ PYI014.pyi:50:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
47 47 | ]
48 48 | ) -> None: ...
49 49 | def f154(
@ -134,7 +134,7 @@ PYI014.pyi:56:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
53 53 | )
54 54 | ) -> None: ...
55 55 | def f141(
@ -155,7 +155,7 @@ PYI014.pyi:59:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
56 56 | x=[*range(10)], # Error PYI014
57 57 | ) -> None: ...
58 58 | def f142(
@ -176,7 +176,7 @@ PYI014.pyi:61:11: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
58 58 | def f142(
59 59 | x=list(range(10)), # Error PYI014
60 60 | ) -> None: ...
@ -197,7 +197,7 @@ PYI014.pyi:63:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
60 60 | ) -> None: ...
61 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014
62 62 | def f17(
@ -218,7 +218,7 @@ PYI014.pyi:66:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
63 63 | x="foo" + "bar", # Error PYI014
64 64 | ) -> None: ...
65 65 | def f18(
@ -239,7 +239,7 @@ PYI014.pyi:69:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
66 66 | x=b"foo" + b"bar", # Error PYI014
67 67 | ) -> None: ...
68 68 | def f19(
@ -260,7 +260,7 @@ PYI014.pyi:72:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
69 69 | x="foo" + 4, # Error PYI014
70 70 | ) -> None: ...
71 71 | def f20(
@ -281,7 +281,7 @@ PYI014.pyi:75:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
72 72 | x=5 + 5, # Error PYI014
73 73 | ) -> None: ...
74 74 | def f21(
@ -302,7 +302,7 @@ PYI014.pyi:78:7: PYI014 [*] Only simple default values allowed for arguments
|
= help: Replace default value with `...`
Fix
Safe fix
75 75 | x=3j - 3j, # Error PYI014
76 76 | ) -> None: ...
77 77 | def f22(

View file

@ -11,7 +11,7 @@ PYI015.pyi:44:23: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
41 41 | field22: Final = {"foo": 5}
42 42 |
43 43 | # We *should* emit Y015 for more complex default values
@ -32,7 +32,7 @@ PYI015.pyi:45:23: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
42 42 |
43 43 | # We *should* emit Y015 for more complex default values
44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments
@ -53,7 +53,7 @@ PYI015.pyi:46:23: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
43 43 | # We *should* emit Y015 for more complex default values
44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments
45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments
@ -74,7 +74,7 @@ PYI015.pyi:47:26: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments
45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments
46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments
@ -95,7 +95,7 @@ PYI015.pyi:48:47: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments
46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments
47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments
@ -116,7 +116,7 @@ PYI015.pyi:49:31: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments
47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments
48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments
@ -137,7 +137,7 @@ PYI015.pyi:50:37: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments
48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments
49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments
@ -158,7 +158,7 @@ PYI015.pyi:52:28: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments
50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments
51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node
@ -179,7 +179,7 @@ PYI015.pyi:53:11: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments
51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node
52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments
@ -199,7 +199,7 @@ PYI015.pyi:54:11: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node
52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments
53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments
@ -220,7 +220,7 @@ PYI015.pyi:55:11: PYI015 [*] Only simple default values allowed for assignments
|
= help: Replace default value with `...`
Fix
Safe fix
52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments
53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments
54 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments

View file

@ -11,7 +11,7 @@ PYI016.py:7:15: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
4 4 | field1: str
5 5 |
6 6 | # Should emit for duplicate field types.
@ -30,7 +30,7 @@ PYI016.py:10:23: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
7 7 | field2: str | str # PYI016: Duplicate union member `str`
8 8 |
9 9 | # Should emit for union types in arguments.
@ -49,7 +49,7 @@ PYI016.py:14:22: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
11 11 | print(arg1)
12 12 |
13 13 | # Should emit for unions in return types.
@ -69,7 +69,7 @@ PYI016.py:18:15: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
15 15 | return "my string"
16 16 |
17 17 | # Should emit in longer unions, even if not directly adjacent.
@ -90,7 +90,7 @@ PYI016.py:19:15: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
16 16 |
17 17 | # Should emit in longer unions, even if not directly adjacent.
18 18 | field3: str | str | int # PYI016: Duplicate union member `str`
@ -110,7 +110,7 @@ PYI016.py:20:21: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
17 17 | # Should emit in longer unions, even if not directly adjacent.
18 18 | field3: str | str | int # PYI016: Duplicate union member `str`
19 19 | field4: int | int | str # PYI016: Duplicate union member `int`
@ -131,7 +131,7 @@ PYI016.py:21:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
18 18 | field3: str | str | int # PYI016: Duplicate union member `str`
19 19 | field4: int | int | str # PYI016: Duplicate union member `int`
20 20 | field5: str | int | str # PYI016: Duplicate union member `str`
@ -151,7 +151,7 @@ PYI016.py:27:22: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
24 24 | field7 = str | str
25 25 |
26 26 | # Should emit for strangely-bracketed unions.
@ -170,7 +170,7 @@ PYI016.py:30:16: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int`
28 28 |
29 29 | # Should handle user brackets when fixing.
@ -191,7 +191,7 @@ PYI016.py:31:24: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
28 28 |
29 29 | # Should handle user brackets when fixing.
30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int`
@ -211,7 +211,7 @@ PYI016.py:34:21: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str`
32 32 |
33 33 | # Should emit for nested unions.
@ -230,7 +230,7 @@ PYI016.py:37:16: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
34 34 | field11: dict[int | int, str]
35 35 |
36 36 | # Should emit for unions with more than two cases
@ -249,7 +249,7 @@ PYI016.py:37:22: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
34 34 | field11: dict[int | int, str]
35 35 |
36 36 | # Should emit for unions with more than two cases
@ -270,7 +270,7 @@ PYI016.py:38:16: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
35 35 |
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int # Error
@ -291,7 +291,7 @@ PYI016.py:38:22: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
35 35 |
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int # Error
@ -312,7 +312,7 @@ PYI016.py:38:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
35 35 |
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int # Error
@ -332,7 +332,7 @@ PYI016.py:41:16: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
38 38 | field13: int | int | int | int # Error
39 39 |
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
@ -352,7 +352,7 @@ PYI016.py:41:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
38 38 | field13: int | int | int | int # Error
39 39 |
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
@ -372,7 +372,7 @@ PYI016.py:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]`
|
= help: Remove duplicate union member `typing.Literal[1]`
Fix
Safe fix
41 41 | field14: int | int | str | int # Error
42 42 |
43 43 | # Should emit for duplicate literal types; also covered by PYI030
@ -425,7 +425,7 @@ PYI016.py:69:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error
67 67 |
68 68 | # Should emit in cases with mixed `typing.Union` and `|`
@ -476,7 +476,7 @@ PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]`
|
= help: Remove duplicate union member `set[int]`
Fix
Safe fix
73 73 |
74 74 | # Should emit in cases with newlines
75 75 | field23: set[ # foo
@ -517,7 +517,7 @@ PYI016.py:86:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
83 83 | # Should emit twice (once for each `int` in the nested union, both of which are
84 84 | # duplicates of the outer `int`), but not three times (which would indicate that
85 85 | # we incorrectly re-checked the nested union).
@ -533,7 +533,7 @@ PYI016.py:86:34: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
83 83 | # Should emit twice (once for each `int` in the nested union, both of which are
84 84 | # duplicates of the outer `int`), but not three times (which would indicate that
85 85 | # we incorrectly re-checked the nested union).

View file

@ -11,7 +11,7 @@ PYI016.pyi:7:15: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
4 4 | field1: str
5 5 |
6 6 | # Should emit for duplicate field types.
@ -30,7 +30,7 @@ PYI016.pyi:10:23: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
7 7 | field2: str | str # PYI016: Duplicate union member `str`
8 8 |
9 9 | # Should emit for union types in arguments.
@ -49,7 +49,7 @@ PYI016.pyi:14:22: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
11 11 | print(arg1)
12 12 |
13 13 | # Should emit for unions in return types.
@ -69,7 +69,7 @@ PYI016.pyi:18:15: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
15 15 | return "my string"
16 16 |
17 17 | # Should emit in longer unions, even if not directly adjacent.
@ -90,7 +90,7 @@ PYI016.pyi:19:15: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
16 16 |
17 17 | # Should emit in longer unions, even if not directly adjacent.
18 18 | field3: str | str | int # PYI016: Duplicate union member `str`
@ -110,7 +110,7 @@ PYI016.pyi:20:21: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
17 17 | # Should emit in longer unions, even if not directly adjacent.
18 18 | field3: str | str | int # PYI016: Duplicate union member `str`
19 19 | field4: int | int | str # PYI016: Duplicate union member `int`
@ -131,7 +131,7 @@ PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
18 18 | field3: str | str | int # PYI016: Duplicate union member `str`
19 19 | field4: int | int | str # PYI016: Duplicate union member `int`
20 20 | field5: str | int | str # PYI016: Duplicate union member `str`
@ -151,7 +151,7 @@ PYI016.pyi:27:22: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
24 24 | field7 = str | str
25 25 |
26 26 | # Should emit for strangely-bracketed unions.
@ -170,7 +170,7 @@ PYI016.pyi:30:16: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int`
28 28 |
29 29 | # Should handle user brackets when fixing.
@ -191,7 +191,7 @@ PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str`
|
= help: Remove duplicate union member `str`
Fix
Safe fix
28 28 |
29 29 | # Should handle user brackets when fixing.
30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int`
@ -211,7 +211,7 @@ PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str`
32 32 |
33 33 | # Should emit for nested unions.
@ -230,7 +230,7 @@ PYI016.pyi:37:16: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
34 34 | field11: dict[int | int, str]
35 35 |
36 36 | # Should emit for unions with more than two cases
@ -249,7 +249,7 @@ PYI016.pyi:37:22: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
34 34 | field11: dict[int | int, str]
35 35 |
36 36 | # Should emit for unions with more than two cases
@ -270,7 +270,7 @@ PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
35 35 |
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int # Error
@ -291,7 +291,7 @@ PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
35 35 |
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int # Error
@ -312,7 +312,7 @@ PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
35 35 |
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int # Error
@ -332,7 +332,7 @@ PYI016.pyi:41:16: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
38 38 | field13: int | int | int | int # Error
39 39 |
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
@ -352,7 +352,7 @@ PYI016.pyi:41:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
38 38 | field13: int | int | int | int # Error
39 39 |
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
@ -372,7 +372,7 @@ PYI016.pyi:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]`
|
= help: Remove duplicate union member `typing.Literal[1]`
Fix
Safe fix
41 41 | field14: int | int | str | int # Error
42 42 |
43 43 | # Should emit for duplicate literal types; also covered by PYI030
@ -425,7 +425,7 @@ PYI016.pyi:69:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error
67 67 |
68 68 | # Should emit in cases with mixed `typing.Union` and `|`
@ -476,7 +476,7 @@ PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]`
|
= help: Remove duplicate union member `set[int]`
Fix
Safe fix
73 73 |
74 74 | # Should emit in cases with newlines
75 75 | field23: set[ # foo
@ -517,7 +517,7 @@ PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
83 83 | # Should emit twice (once for each `int` in the nested union, both of which are
84 84 | # duplicates of the outer `int`), but not three times (which would indicate that
85 85 | # we incorrectly re-checked the nested union).
@ -533,7 +533,7 @@ PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int`
|
= help: Remove duplicate union member `int`
Fix
Safe fix
83 83 | # Should emit twice (once for each `int` in the nested union, both of which are
84 84 | # duplicates of the outer `int`), but not three times (which would indicate that
85 85 | # we incorrectly re-checked the nested union).

View file

@ -12,7 +12,7 @@ PYI020.pyi:7:10: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
4 4 |
5 5 | import typing_extensions
6 6 |
@ -31,7 +31,7 @@ PYI020.pyi:8:15: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
5 5 | import typing_extensions
6 6 |
7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs
@ -52,7 +52,7 @@ PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
6 6 |
7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs
8 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs
@ -72,7 +72,7 @@ PYI020.pyi:13:12: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
10 10 |
11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ...
12 12 |
@ -92,7 +92,7 @@ PYI020.pyi:14:25: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ...
12 12 |
13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs
@ -112,7 +112,7 @@ PYI020.pyi:16:18: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs
14 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs
15 15 |
@ -132,7 +132,7 @@ PYI020.pyi:20:8: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs
18 18 |
19 19 | if sys.platform == "linux":
@ -153,7 +153,7 @@ PYI020.pyi:22:8: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
19 19 | if sys.platform == "linux":
20 20 | f: "int" # Y020 Quoted annotations should never be used in stubs
21 21 | elif sys.platform == "win32":
@ -174,7 +174,7 @@ PYI020.pyi:24:8: PYI020 [*] Quoted annotations should not be included in stubs
|
= help: Remove quotes
Fix
Safe fix
21 21 | elif sys.platform == "win32":
22 22 | f: "str" # Y020 Quoted annotations should never be used in stubs
23 23 | else:

View file

@ -9,7 +9,7 @@ PYI025.py:10:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet`
|
= help: Alias `Set` to `AbstractSet`
Suggested fix
Unsafe fix
7 7 |
8 8 |
9 9 | def f():
@ -29,7 +29,7 @@ PYI025.py:14:51: PYI025 [*] Use `from collections.abc import Set as AbstractSet`
|
= help: Alias `Set` to `AbstractSet`
Suggested fix
Unsafe fix
11 11 |
12 12 |
13 13 | def f():

View file

@ -11,7 +11,7 @@ PYI025.pyi:8:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet`
|
= help: Alias `Set` to `AbstractSet`
Suggested fix
Unsafe fix
5 5 | from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # Ok
6 6 |
7 7 | def f():
@ -31,7 +31,7 @@ PYI025.pyi:11:51: PYI025 [*] Use `from collections.abc import Set as AbstractSet
|
= help: Alias `Set` to `AbstractSet`
Suggested fix
Unsafe fix
8 8 | from collections.abc import Set # PYI025
9 9 |
10 10 | def f():
@ -52,7 +52,7 @@ PYI025.pyi:16:37: PYI025 [*] Use `from collections.abc import Set as AbstractSet
|
= help: Alias `Set` to `AbstractSet`
Suggested fix
Unsafe fix
13 13 | def f():
14 14 | """Test: local symbol renaming."""
15 15 | if True:
@ -87,7 +87,7 @@ PYI025.pyi:33:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet
|
= help: Alias `Set` to `AbstractSet`
Suggested fix
Unsafe fix
17 17 | else:
18 18 | Set = 1
19 19 |
@ -130,7 +130,7 @@ PYI025.pyi:44:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet
|
= help: Alias `Set` to `AbstractSet`
Suggested fix
Unsafe fix
41 41 |
42 42 | def f():
43 43 | """Test: nonlocal symbol renaming."""

View file

@ -12,7 +12,7 @@ PYI026.pyi:3:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `NewAny:
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 |-from typing import Literal, Any
1 |+from typing import Literal, Any, TypeAlias
2 2 |
@ -32,7 +32,7 @@ PYI026.pyi:4:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Optiona
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 |-from typing import Literal, Any
1 |+from typing import Literal, Any, TypeAlias
2 2 |
@ -54,7 +54,7 @@ PYI026.pyi:5:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Foo: Ty
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 |-from typing import Literal, Any
1 |+from typing import Literal, Any, TypeAlias
2 2 |
@ -76,7 +76,7 @@ PYI026.pyi:6:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `IntOrSt
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 |-from typing import Literal, Any
1 |+from typing import Literal, Any, TypeAlias
2 2 |
@ -100,7 +100,7 @@ PYI026.pyi:7:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `AliasNo
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 |-from typing import Literal, Any
1 |+from typing import Literal, Any, TypeAlias
2 2 |

View file

@ -11,7 +11,7 @@ PYI029.pyi:10:9: PYI029 [*] Defining `__str__` in a stub is almost always redund
|
= help: Remove definition of `str`
Fix
Safe fix
7 7 | def __repr__(self, *, foo) -> str: ...
8 8 |
9 9 | class ShouldRemoveSingle:
@ -30,7 +30,7 @@ PYI029.pyi:13:9: PYI029 [*] Defining `__repr__` in a stub is almost always redun
|
= help: Remove definition of `repr`
Fix
Safe fix
10 10 | def __str__(self) -> builtins.str: ... # Error: PYI029
11 11 |
12 12 | class ShouldRemove:
@ -50,7 +50,7 @@ PYI029.pyi:14:9: PYI029 [*] Defining `__str__` in a stub is almost always redund
|
= help: Remove definition of `str`
Fix
Safe fix
11 11 |
12 12 | class ShouldRemove:
13 13 | def __repr__(self) -> str: ... # Error: PYI029

View file

@ -10,7 +10,7 @@ PYI032.py:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to
|
= help: Replace with `object`
Fix
Safe fix
3 3 |
4 4 |
5 5 | class Bad:
@ -29,7 +29,7 @@ PYI032.py:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to
|
= help: Replace with `object`
Fix
Safe fix
4 4 |
5 5 | class Bad:
6 6 | def __eq__(self, other: Any) -> bool: ... # Y032

View file

@ -10,7 +10,7 @@ PYI032.pyi:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to
|
= help: Replace with `object`
Fix
Safe fix
3 3 |
4 4 |
5 5 | class Bad:
@ -29,7 +29,7 @@ PYI032.pyi:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to
|
= help: Replace with `object`
Fix
Safe fix
4 4 |
5 5 | class Bad:
6 6 | def __eq__(self, other: Any) -> bool: ... # Y032

View file

@ -10,7 +10,7 @@ PYI036.py:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `ob
|
= help: Annotate star-args with `object`
Fix
Safe fix
51 51 |
52 52 |
53 53 | class BadOne:
@ -111,7 +111,7 @@ PYI036.py:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `ob
|
= help: Annotate star-args with `object`
Fix
Safe fix
67 67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation
68 68 |
69 69 | class BadFive:
@ -132,7 +132,7 @@ PYI036.py:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `o
|
= help: Annotate star-args with `object`
Fix
Safe fix
68 68 |
69 69 | class BadFive:
70 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation

View file

@ -10,7 +10,7 @@ PYI036.pyi:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `o
|
= help: Annotate star-args with `object`
Fix
Safe fix
51 51 |
52 52 |
53 53 | class BadOne:
@ -121,7 +121,7 @@ PYI036.pyi:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `o
|
= help: Annotate star-args with `object`
Fix
Safe fix
67 67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation
68 68 |
69 69 | class BadFive:
@ -142,7 +142,7 @@ PYI036.pyi:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `
|
= help: Annotate star-args with `object`
Fix
Safe fix
68 68 |
69 69 | class BadFive:
70 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation

View file

@ -12,7 +12,7 @@ PYI053.pyi:3:14: PYI053 [*] String and bytes literals longer than 50 characters
|
= help: Replace with `...`
Fix
Safe fix
1 1 | def f1(x: str = "50 character stringggggggggggggggggggggggggggggggg") -> None: ... # OK
2 2 | def f2(
3 |- x: str = "51 character stringgggggggggggggggggggggggggggggggg", # Error: PYI053
@ -32,7 +32,7 @@ PYI053.pyi:9:14: PYI053 [*] String and bytes literals longer than 50 characters
|
= help: Replace with `...`
Fix
Safe fix
6 6 | x: str = "50 character stringgggggggggggggggggggggggggggggg\U0001f600", # OK
7 7 | ) -> None: ...
8 8 | def f4(
@ -52,7 +52,7 @@ PYI053.pyi:21:16: PYI053 [*] String and bytes literals longer than 50 characters
|
= help: Replace with `...`
Fix
Safe fix
18 18 | x: bytes = b"50 character byte stringggggggggggggggggggggggggg\xff", # OK
19 19 | ) -> None: ...
20 20 | def f8(
@ -73,7 +73,7 @@ PYI053.pyi:26:12: PYI053 [*] String and bytes literals longer than 50 characters
|
= help: Replace with `...`
Fix
Safe fix
23 23 |
24 24 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK
25 25 |
@ -94,7 +94,7 @@ PYI053.pyi:30:14: PYI053 [*] String and bytes literals longer than 50 characters
|
= help: Replace with `...`
Fix
Safe fix
27 27 |
28 28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK
29 29 |

View file

@ -11,7 +11,7 @@ PYI054.pyi:2:16: PYI054 [*] Numeric literals with a string representation longer
|
= help: Replace with `...`
Fix
Safe fix
1 1 | field01: int = 0xFFFFFFFF
2 |-field02: int = 0xFFFFFFFFF # Error: PYI054
2 |+field02: int = ... # Error: PYI054
@ -30,7 +30,7 @@ PYI054.pyi:4:17: PYI054 [*] Numeric literals with a string representation longer
|
= help: Replace with `...`
Fix
Safe fix
1 1 | field01: int = 0xFFFFFFFF
2 2 | field02: int = 0xFFFFFFFFF # Error: PYI054
3 3 | field03: int = -0xFFFFFFFF
@ -51,7 +51,7 @@ PYI054.pyi:8:16: PYI054 [*] Numeric literals with a string representation longer
|
= help: Replace with `...`
Fix
Safe fix
5 5 |
6 6 | field05: int = 1234567890
7 7 | field06: int = 12_456_890
@ -72,7 +72,7 @@ PYI054.pyi:10:17: PYI054 [*] Numeric literals with a string representation longe
|
= help: Replace with `...`
Fix
Safe fix
7 7 | field06: int = 12_456_890
8 8 | field07: int = 12345678901 # Error: PYI054
9 9 | field08: int = -1234567801
@ -92,7 +92,7 @@ PYI054.pyi:13:18: PYI054 [*] Numeric literals with a string representation longe
|
= help: Replace with `...`
Fix
Safe fix
10 10 | field09: int = -234_567_890 # Error: PYI054
11 11 |
12 12 | field10: float = 123.456789
@ -113,7 +113,7 @@ PYI054.pyi:15:19: PYI054 [*] Numeric literals with a string representation longe
|
= help: Replace with `...`
Fix
Safe fix
12 12 | field10: float = 123.456789
13 13 | field11: float = 123.4567890 # Error: PYI054
14 14 | field12: float = -123.456789
@ -133,7 +133,7 @@ PYI054.pyi:18:20: PYI054 [*] Numeric literals with a string representation longe
|
= help: Replace with `...`
Fix
Safe fix
15 15 | field13: float = -123.567_890 # Error: PYI054
16 16 |
17 17 | field14: complex = 1e1234567j
@ -151,7 +151,7 @@ PYI054.pyi:20:20: PYI054 [*] Numeric literals with a string representation longe
|
= help: Replace with `...`
Fix
Safe fix
17 17 | field14: complex = 1e1234567j
18 18 | field15: complex = 1e12345678j # Error: PYI054
19 19 | field16: complex = -1e1234567j

View file

@ -11,7 +11,7 @@ PYI055.py:31:8: PYI055 [*] Multiple `type` members in a union. Combine them into
|
= help: Combine multiple `type` members
Fix
Safe fix
28 28 |
29 29 | def func():
30 30 | # PYI055
@ -30,7 +30,7 @@ PYI055.py:32:8: PYI055 [*] Multiple `type` members in a union. Combine them into
|
= help: Combine multiple `type` members
Fix
Safe fix
29 29 | def func():
30 30 | # PYI055
31 31 | x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
@ -48,7 +48,7 @@ PYI055.py:39:8: PYI055 [*] Multiple `type` members in a union. Combine them into
|
= help: Combine multiple `type` members
Fix
Safe fix
36 36 | from typing import Union as U
37 37 |
38 38 | # PYI055

View file

@ -12,7 +12,7 @@ PYI055.pyi:4:4: PYI055 [*] Multiple `type` members in a union. Combine them into
|
= help: Combine multiple `type` members
Fix
Safe fix
1 1 | import builtins
2 2 | from typing import Union
3 3 |
@ -32,7 +32,7 @@ PYI055.pyi:5:4: PYI055 [*] Multiple `type` members in a union. Combine them into
|
= help: Combine multiple `type` members
Fix
Safe fix
2 2 | from typing import Union
3 3 |
4 4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex]
@ -53,7 +53,7 @@ PYI055.pyi:6:4: PYI055 [*] Multiple `type` members in a union. Combine them into
|
= help: Combine multiple `type` members
Fix
Safe fix
3 3 |
4 4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex]
5 5 | x: type[int] | type[str] | type[float]
@ -73,7 +73,7 @@ PYI055.pyi:7:4: PYI055 [*] Multiple `type` members in a union. Combine them into
|
= help: Combine multiple `type` members
Fix
Safe fix
4 4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex]
5 5 | x: type[int] | type[str] | type[float]
6 6 | y: builtins.type[int] | type[str] | builtins.type[complex]
@ -94,7 +94,7 @@ PYI055.pyi:8:4: PYI055 [*] Multiple `type` members in a union. Combine them into
|
= help: Combine multiple `type` members
Fix
Safe fix
5 5 | x: type[int] | type[str] | type[float]
6 6 | y: builtins.type[int] | type[str] | builtins.type[complex]
7 7 | z: Union[type[float], type[complex]]
@ -115,7 +115,7 @@ PYI055.pyi:10:15: PYI055 [*] Multiple `type` members in a union. Combine them in
|
= help: Combine multiple `type` members
Fix
Safe fix
7 7 | z: Union[type[float], type[complex]]
8 8 | z: Union[type[float, int], type[complex]]
9 9 |
@ -135,7 +135,7 @@ PYI055.pyi:20:7: PYI055 [*] Multiple `type` members in a union. Combine them int
|
= help: Combine multiple `type` members
Fix
Safe fix
17 17 | def func(arg: type[int, float] | str) -> None: ...
18 18 |
19 19 | # OK
@ -155,7 +155,7 @@ PYI055.pyi:24:11: PYI055 [*] Multiple `type` members in a union. Combine them in
|
= help: Combine multiple `type` members
Fix
Safe fix
21 21 |
22 22 | def func():
23 23 | # PYI055
@ -172,7 +172,7 @@ PYI055.pyi:25:12: PYI055 [*] Multiple `type` members in a union. Combine them in
|
= help: Combine multiple `type` members
Fix
Safe fix
22 22 | def func():
23 23 | # PYI055
24 24 | item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker

View file

@ -12,7 +12,7 @@ PYI026.pyi:3:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 1 | from typing import Literal, Any
2 |+import typing_extensions
2 3 |
@ -32,7 +32,7 @@ PYI026.pyi:4:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 1 | from typing import Literal, Any
2 |+import typing_extensions
2 3 |
@ -54,7 +54,7 @@ PYI026.pyi:5:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 1 | from typing import Literal, Any
2 |+import typing_extensions
2 3 |
@ -76,7 +76,7 @@ PYI026.pyi:6:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 1 | from typing import Literal, Any
2 |+import typing_extensions
2 3 |
@ -100,7 +100,7 @@ PYI026.pyi:7:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g
|
= help: Add `TypeAlias` annotation
Fix
Safe fix
1 1 | from typing import Literal, Any
2 |+import typing_extensions
2 3 |

View file

@ -10,7 +10,7 @@ PT001.py:9:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
|
= help: Add parentheses
Fix
Safe fix
6 6 | # `import pytest`
7 7 |
8 8 |
@ -29,7 +29,7 @@ PT001.py:34:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
|
= help: Add parentheses
Fix
Safe fix
31 31 | # `from pytest import fixture`
32 32 |
33 33 |
@ -48,7 +48,7 @@ PT001.py:59:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
|
= help: Add parentheses
Fix
Safe fix
56 56 | # `from pytest import fixture as aliased`
57 57 |
58 58 |

View file

@ -10,7 +10,7 @@ PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
= help: Remove parentheses
Fix
Safe fix
11 11 | return 42
12 12 |
13 13 |
@ -31,7 +31,7 @@ PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
= help: Remove parentheses
Fix
Safe fix
21 21 | return 42
22 22 |
23 23 |
@ -52,7 +52,7 @@ PT001.py:39:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
= help: Remove parentheses
Fix
Safe fix
36 36 | return 42
37 37 |
38 38 |
@ -73,7 +73,7 @@ PT001.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
= help: Remove parentheses
Fix
Safe fix
46 46 | return 42
47 47 |
48 48 |
@ -94,7 +94,7 @@ PT001.py:64:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
= help: Remove parentheses
Fix
Safe fix
61 61 | return 42
62 62 |
63 63 |
@ -115,7 +115,7 @@ PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
|
= help: Remove parentheses
Fix
Safe fix
71 71 | return 42
72 72 |
73 73 |

View file

@ -10,7 +10,7 @@ PT003.py:14:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()`
|
= help: Remove implied `scope` argument
Suggested fix
Unsafe fix
11 11 | ...
12 12 |
13 13 |
@ -29,7 +29,7 @@ PT003.py:19:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()`
|
= help: Remove implied `scope` argument
Suggested fix
Unsafe fix
16 16 | ...
17 17 |
18 18 |
@ -48,7 +48,7 @@ PT003.py:24:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()`
|
= help: Remove implied `scope` argument
Suggested fix
Unsafe fix
21 21 | ...
22 22 |
23 23 |
@ -67,7 +67,7 @@ PT003.py:29:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()`
|
= help: Remove implied `scope` argument
Suggested fix
Unsafe fix
26 26 | ...
27 27 |
28 28 |
@ -88,7 +88,7 @@ PT003.py:37:31: PT003 [*] `scope='function'` is implied in `@pytest.fixture()`
|
= help: Remove implied `scope` argument
Suggested fix
Unsafe fix
34 34 | # pytest.fixture does not take positional arguments, however this
35 35 | # tests the general case as we use a helper function that should
36 36 | # work for all cases.
@ -108,7 +108,7 @@ PT003.py:43:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()`
|
= help: Remove implied `scope` argument
Suggested fix
Unsafe fix
40 40 |
41 41 |
42 42 | @pytest.fixture(
@ -128,7 +128,7 @@ PT003.py:52:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()`
|
= help: Remove implied `scope` argument
Suggested fix
Unsafe fix
49 49 |
50 50 | @pytest.fixture(
51 51 | name="my_fixture",
@ -149,7 +149,7 @@ PT003.py:66:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()`
|
= help: Remove implied `scope` argument
Suggested fix
Unsafe fix
63 63 |
64 64 | # another comment ,)
65 65 |

View file

@ -10,7 +10,7 @@ PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `csv` for parameter names
Suggested fix
Unsafe fix
21 21 | ...
22 22 |
23 23 |
@ -29,7 +29,7 @@ PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `csv` for parameter names
Fix
Safe fix
26 26 | ...
27 27 |
28 28 |
@ -48,7 +48,7 @@ PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `csv` for parameter names
Suggested fix
Unsafe fix
31 31 | ...
32 32 |
33 33 |
@ -67,7 +67,7 @@ PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `csv` for parameter names
Fix
Safe fix
36 36 | ...
37 37 |
38 38 |

View file

@ -10,7 +10,7 @@ PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expec
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
6 6 | ...
7 7 |
8 8 |
@ -29,7 +29,7 @@ PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
11 11 | ...
12 12 |
13 13 |
@ -48,7 +48,7 @@ PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
16 16 | ...
17 17 |
18 18 |
@ -67,7 +67,7 @@ PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `csv` for parameter names
Fix
Safe fix
26 26 | ...
27 27 |
28 28 |
@ -86,7 +86,7 @@ PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
31 31 | ...
32 32 |
33 33 |
@ -105,7 +105,7 @@ PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `csv` for parameter names
Fix
Safe fix
36 36 | ...
37 37 |
38 38 |
@ -124,7 +124,7 @@ PT006.py:44:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
41 41 | ...
42 42 |
43 43 |
@ -143,7 +143,7 @@ PT006.py:49:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
46 46 | ...
47 47 |
48 48 |
@ -162,7 +162,7 @@ PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
51 51 | ...
52 52 |
53 53 |
@ -181,7 +181,7 @@ PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
56 56 | ...
57 57 |
58 58 |
@ -200,7 +200,7 @@ PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
61 61 | ...
62 62 |
63 63 |
@ -219,7 +219,7 @@ PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `tuple` for parameter names
Suggested fix
Unsafe fix
66 66 | ...
67 67 |
68 68 |

View file

@ -10,7 +10,7 @@ PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expec
|
= help: Use a `list` for parameter names
Suggested fix
Unsafe fix
6 6 | ...
7 7 |
8 8 |
@ -29,7 +29,7 @@ PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `list` for parameter names
Suggested fix
Unsafe fix
11 11 | ...
12 12 |
13 13 |
@ -48,7 +48,7 @@ PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `list` for parameter names
Suggested fix
Unsafe fix
16 16 | ...
17 17 |
18 18 |
@ -67,7 +67,7 @@ PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `list` for parameter names
Suggested fix
Unsafe fix
21 21 | ...
22 22 |
23 23 |
@ -86,7 +86,7 @@ PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `csv` for parameter names
Fix
Safe fix
26 26 | ...
27 27 |
28 28 |
@ -105,7 +105,7 @@ PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `csv` for parameter names
Fix
Safe fix
36 36 | ...
37 37 |
38 38 |
@ -124,7 +124,7 @@ PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `list` for parameter names
Suggested fix
Unsafe fix
51 51 | ...
52 52 |
53 53 |
@ -143,7 +143,7 @@ PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `list` for parameter names
Suggested fix
Unsafe fix
56 56 | ...
57 57 |
58 58 |
@ -162,7 +162,7 @@ PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `list` for parameter names
Suggested fix
Unsafe fix
61 61 | ...
62 62 |
63 63 |
@ -181,7 +181,7 @@ PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expe
|
= help: Use a `list` for parameter names
Suggested fix
Unsafe fix
66 66 | ...
67 67 |
68 68 |

View file

@ -12,7 +12,7 @@ PT009.py:11:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertTrue(...)` with `assert ...`
Suggested fix
Unsafe fix
8 8 | def test_assert_true(self):
9 9 | expr = 1
10 10 | msg = "Must be True"
@ -33,7 +33,7 @@ PT009.py:12:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertTrue(...)` with `assert ...`
Suggested fix
Unsafe fix
9 9 | expr = 1
10 10 | msg = "Must be True"
11 11 | self.assertTrue(expr) # Error
@ -54,7 +54,7 @@ PT009.py:13:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertTrue(...)` with `assert ...`
Suggested fix
Unsafe fix
10 10 | msg = "Must be True"
11 11 | self.assertTrue(expr) # Error
12 12 | self.assertTrue(expr=expr) # Error
@ -75,7 +75,7 @@ PT009.py:14:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertTrue(...)` with `assert ...`
Suggested fix
Unsafe fix
11 11 | self.assertTrue(expr) # Error
12 12 | self.assertTrue(expr=expr) # Error
13 13 | self.assertTrue(expr, msg) # Error
@ -96,7 +96,7 @@ PT009.py:15:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertTrue(...)` with `assert ...`
Suggested fix
Unsafe fix
12 12 | self.assertTrue(expr=expr) # Error
13 13 | self.assertTrue(expr, msg) # Error
14 14 | self.assertTrue(expr=expr, msg=msg) # Error
@ -193,7 +193,7 @@ PT009.py:28:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertFalse(...)` with `assert ...`
Suggested fix
Unsafe fix
25 25 | return self.assertEqual(True, False) # Error, unfixable
26 26 |
27 27 | def test_assert_false(self):
@ -213,7 +213,7 @@ PT009.py:31:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertEqual(...)` with `assert ...`
Suggested fix
Unsafe fix
28 28 | self.assertFalse(True) # Error
29 29 |
30 30 | def test_assert_equal(self):
@ -233,7 +233,7 @@ PT009.py:34:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertNotEqual(...)` with `assert ...`
Suggested fix
Unsafe fix
31 31 | self.assertEqual(1, 2) # Error
32 32 |
33 33 | def test_assert_not_equal(self):
@ -253,7 +253,7 @@ PT009.py:37:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertGreater(...)` with `assert ...`
Suggested fix
Unsafe fix
34 34 | self.assertNotEqual(1, 1) # Error
35 35 |
36 36 | def test_assert_greater(self):
@ -273,7 +273,7 @@ PT009.py:40:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertGreaterEqual(...)` with `assert ...`
Suggested fix
Unsafe fix
37 37 | self.assertGreater(1, 2) # Error
38 38 |
39 39 | def test_assert_greater_equal(self):
@ -293,7 +293,7 @@ PT009.py:43:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertLess(...)` with `assert ...`
Suggested fix
Unsafe fix
40 40 | self.assertGreaterEqual(1, 2) # Error
41 41 |
42 42 | def test_assert_less(self):
@ -313,7 +313,7 @@ PT009.py:46:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertLessEqual(...)` with `assert ...`
Suggested fix
Unsafe fix
43 43 | self.assertLess(2, 1) # Error
44 44 |
45 45 | def test_assert_less_equal(self):
@ -333,7 +333,7 @@ PT009.py:49:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertIn(...)` with `assert ...`
Suggested fix
Unsafe fix
46 46 | self.assertLessEqual(1, 2) # Error
47 47 |
48 48 | def test_assert_in(self):
@ -353,7 +353,7 @@ PT009.py:52:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertNotIn(...)` with `assert ...`
Suggested fix
Unsafe fix
49 49 | self.assertIn(1, [2, 3]) # Error
50 50 |
51 51 | def test_assert_not_in(self):
@ -373,7 +373,7 @@ PT009.py:55:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertIsNone(...)` with `assert ...`
Suggested fix
Unsafe fix
52 52 | self.assertNotIn(2, [2, 3]) # Error
53 53 |
54 54 | def test_assert_is_none(self):
@ -393,7 +393,7 @@ PT009.py:58:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertIsNotNone(...)` with `assert ...`
Suggested fix
Unsafe fix
55 55 | self.assertIsNone(0) # Error
56 56 |
57 57 | def test_assert_is_not_none(self):
@ -413,7 +413,7 @@ PT009.py:61:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertIs(...)` with `assert ...`
Suggested fix
Unsafe fix
58 58 | self.assertIsNotNone(0) # Error
59 59 |
60 60 | def test_assert_is(self):
@ -433,7 +433,7 @@ PT009.py:64:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertIsNot(...)` with `assert ...`
Suggested fix
Unsafe fix
61 61 | self.assertIs([], []) # Error
62 62 |
63 63 | def test_assert_is_not(self):
@ -453,7 +453,7 @@ PT009.py:67:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertIsInstance(...)` with `assert ...`
Suggested fix
Unsafe fix
64 64 | self.assertIsNot(1, 1) # Error
65 65 |
66 66 | def test_assert_is_instance(self):
@ -473,7 +473,7 @@ PT009.py:70:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertNotIsInstance(...)` with `assert ...`
Suggested fix
Unsafe fix
67 67 | self.assertIsInstance(1, str) # Error
68 68 |
69 69 | def test_assert_is_not_instance(self):
@ -493,7 +493,7 @@ PT009.py:73:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertRegex(...)` with `assert ...`
Suggested fix
Unsafe fix
70 70 | self.assertNotIsInstance(1, int) # Error
71 71 |
72 72 | def test_assert_regex(self):
@ -513,7 +513,7 @@ PT009.py:76:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertNotRegex(...)` with `assert ...`
Suggested fix
Unsafe fix
73 73 | self.assertRegex("abc", r"def") # Error
74 74 |
75 75 | def test_assert_not_regex(self):
@ -533,7 +533,7 @@ PT009.py:79:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertRegexpMatches(...)` with `assert ...`
Suggested fix
Unsafe fix
76 76 | self.assertNotRegex("abc", r"abc") # Error
77 77 |
78 78 | def test_assert_regexp_matches(self):
@ -553,7 +553,7 @@ PT009.py:82:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertNotRegex(...)` with `assert ...`
Suggested fix
Unsafe fix
79 79 | self.assertRegexpMatches("abc", r"def") # Error
80 80 |
81 81 | def test_assert_not_regexp_matches(self):
@ -573,7 +573,7 @@ PT009.py:85:9: PT009 [*] Use a regular `assert` instead of unittest-style `failI
|
= help: Replace `failIf(...)` with `assert ...`
Suggested fix
Unsafe fix
82 82 | self.assertNotRegex("abc", r"abc") # Error
83 83 |
84 84 | def test_fail_if(self):
@ -593,7 +593,7 @@ PT009.py:88:9: PT009 [*] Use a regular `assert` instead of unittest-style `failU
|
= help: Replace `failUnless(...)` with `assert ...`
Suggested fix
Unsafe fix
85 85 | self.failIf("abc") # Error
86 86 |
87 87 | def test_fail_unless(self):
@ -613,7 +613,7 @@ PT009.py:91:9: PT009 [*] Use a regular `assert` instead of unittest-style `failU
|
= help: Replace `failUnlessEqual(...)` with `assert ...`
Suggested fix
Unsafe fix
88 88 | self.failUnless("abc") # Error
89 89 |
90 90 | def test_fail_unless_equal(self):
@ -631,7 +631,7 @@ PT009.py:94:9: PT009 [*] Use a regular `assert` instead of unittest-style `failI
|
= help: Replace `failIfEqual(...)` with `assert ...`
Suggested fix
Unsafe fix
91 91 | self.failUnlessEqual(1, 2) # Error
92 92 |
93 93 | def test_fail_if_equal(self):
@ -651,7 +651,7 @@ PT009.py:98:2: PT009 [*] Use a regular `assert` instead of unittest-style `asser
|
= help: Replace `assertTrue(...)` with `assert ...`
Suggested fix
Unsafe fix
95 95 |
96 96 |
97 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517

View file

@ -10,7 +10,7 @@ PT014.py:4:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.para
|
= help: Remove duplicate test case
Suggested fix
Unsafe fix
1 1 | import pytest
2 2 |
3 3 |
@ -29,7 +29,7 @@ PT014.py:14:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par
|
= help: Remove duplicate test case
Suggested fix
Unsafe fix
11 11 | c = 3
12 12 |
13 13 |
@ -48,7 +48,7 @@ PT014.py:14:41: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.par
|
= help: Remove duplicate test case
Suggested fix
Unsafe fix
11 11 | c = 3
12 12 |
13 13 |
@ -67,7 +67,7 @@ PT014.py:14:44: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.par
|
= help: Remove duplicate test case
Suggested fix
Unsafe fix
11 11 | c = 3
12 12 |
13 13 |
@ -97,7 +97,7 @@ PT014.py:32:39: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par
|
= help: Remove duplicate test case
Suggested fix
Unsafe fix
29 29 | ...
30 30 |
31 31 |
@ -116,7 +116,7 @@ PT014.py:32:48: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par
|
= help: Remove duplicate test case
Suggested fix
Unsafe fix
29 29 | ...
30 30 |
31 31 |
@ -137,7 +137,7 @@ PT014.py:42:10: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par
|
= help: Remove duplicate test case
Suggested fix
Unsafe fix
39 39 | [
40 40 | a,
41 41 | b,
@ -157,7 +157,7 @@ PT014.py:44:11: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.par
|
= help: Remove duplicate test case
Suggested fix
Unsafe fix
41 41 | b,
42 42 | (a),
43 43 | c,

View file

@ -11,7 +11,7 @@ PT018.py:14:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
11 11 |
12 12 |
13 13 | def test_error():
@ -33,7 +33,7 @@ PT018.py:15:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
12 12 |
13 13 | def test_error():
14 14 | assert something and something_else
@ -55,7 +55,7 @@ PT018.py:16:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
13 13 | def test_error():
14 14 | assert something and something_else
15 15 | assert something and something_else and something_third
@ -77,7 +77,7 @@ PT018.py:17:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
14 14 | assert something and something_else
15 15 | assert something and something_else and something_third
16 16 | assert something and not something_else
@ -99,7 +99,7 @@ PT018.py:18:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
15 15 | assert something and something_else and something_third
16 16 | assert something and not something_else
17 17 | assert something and (something_else or something_third)
@ -121,7 +121,7 @@ PT018.py:19:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
16 16 | assert something and not something_else
17 17 | assert something and (something_else or something_third)
18 18 | assert not something and something_else
@ -143,7 +143,7 @@ PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
17 17 | assert something and (something_else or something_third)
18 18 | assert not something and something_else
19 19 | assert not (something or something_else)
@ -168,7 +168,7 @@ PT018.py:21:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
18 18 | assert not something and something_else
19 19 | assert not (something or something_else)
20 20 | assert not (something or something_else or something_third)
@ -197,7 +197,7 @@ PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
21 21 | assert something and something_else == """error
22 22 | message
23 23 | """
@ -219,7 +219,7 @@ PT018.py:33:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
30 30 | )
31 31 |
32 32 | # recursive case
@ -241,7 +241,7 @@ PT018.py:34:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
31 31 |
32 32 | # recursive case
33 33 | assert not (a or not (b or c))
@ -291,7 +291,7 @@ PT018.py:44:1: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
41 41 |
42 42 |
43 43 | assert something # OK
@ -311,7 +311,7 @@ PT018.py:45:1: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
42 42 |
43 43 | assert something # OK
44 44 | assert something and something_else # Error
@ -367,7 +367,7 @@ PT018.py:59:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
59 59 | assert not (
60 60 | self.find_graph_output(node.output[0])
61 61 | or self.find_graph_input(node.input[0])
@ -396,7 +396,7 @@ PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts
|
= help: Break down assertion into multiple parts
Suggested fix
Unsafe fix
62 62 | or self.find_graph_output(node.input[0])
63 63 | )
64 64 |

View file

@ -10,7 +10,7 @@ PT022.py:17:5: PT022 [*] No teardown in fixture `error`, use `return` instead of
|
= help: Replace `yield` with `return`
Fix
Safe fix
14 14 | @pytest.fixture()
15 15 | def error():
16 16 | resource = acquire_resource()
@ -29,7 +29,7 @@ PT022.py:37:5: PT022 [*] No teardown in fixture `error`, use `return` instead of
|
= help: Replace `yield` with `return`
Fix
Safe fix
32 32 |
33 33 |
34 34 | @pytest.fixture()
@ -51,7 +51,7 @@ PT022.py:43:5: PT022 [*] No teardown in fixture `error`, use `return` instead of
|
= help: Replace `yield` with `return`
Fix
Safe fix
38 38 |
39 39 |
40 40 | @pytest.fixture()

View file

@ -10,7 +10,7 @@ PT023.py:12:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
= help: Add/remove parentheses
Fix
Safe fix
9 9 | # Without parentheses
10 10 |
11 11 |
@ -29,7 +29,7 @@ PT023.py:17:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
= help: Add/remove parentheses
Fix
Safe fix
14 14 | pass
15 15 |
16 16 |
@ -49,7 +49,7 @@ PT023.py:24:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
= help: Add/remove parentheses
Fix
Safe fix
21 21 |
22 22 |
23 23 | class TestClass:
@ -69,7 +69,7 @@ PT023.py:30:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
= help: Add/remove parentheses
Fix
Safe fix
27 27 |
28 28 |
29 29 | class TestClass:
@ -90,7 +90,7 @@ PT023.py:38:9: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo`
|
= help: Add/remove parentheses
Fix
Safe fix
35 35 |
36 36 | class TestClass:
37 37 | class TestNestedClass:

View file

@ -10,7 +10,7 @@ PT023.py:46:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
= help: Add/remove parentheses
Fix
Safe fix
43 43 | # With parentheses
44 44 |
45 45 |
@ -29,7 +29,7 @@ PT023.py:51:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
= help: Add/remove parentheses
Fix
Safe fix
48 48 | pass
49 49 |
50 50 |
@ -49,7 +49,7 @@ PT023.py:58:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
= help: Add/remove parentheses
Fix
Safe fix
55 55 |
56 56 |
57 57 | class TestClass:
@ -69,7 +69,7 @@ PT023.py:64:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
= help: Add/remove parentheses
Fix
Safe fix
61 61 |
62 62 |
63 63 | class TestClass:
@ -90,7 +90,7 @@ PT023.py:72:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()`
|
= help: Add/remove parentheses
Fix
Safe fix
69 69 |
70 70 | class TestClass:
71 71 | class TestNestedClass:

View file

@ -10,7 +10,7 @@ PT024.py:14:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures
|
= help: Remove `pytest.mark.asyncio`
Fix
Safe fix
11 11 | pass
12 12 |
13 13 |
@ -28,7 +28,7 @@ PT024.py:20:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures
|
= help: Remove `pytest.mark.asyncio`
Fix
Safe fix
17 17 | return 0
18 18 |
19 19 |
@ -47,7 +47,7 @@ PT024.py:27:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures
|
= help: Remove `pytest.mark.asyncio`
Fix
Safe fix
24 24 |
25 25 |
26 26 | @pytest.fixture()
@ -66,7 +66,7 @@ PT024.py:33:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures
|
= help: Remove `pytest.mark.asyncio`
Fix
Safe fix
30 30 |
31 31 |
32 32 | @pytest.fixture()

View file

@ -10,7 +10,7 @@ PT025.py:9:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures
|
= help: Remove `pytest.mark.usefixtures`
Fix
Safe fix
6 6 | pass
7 7 |
8 8 |
@ -29,7 +29,7 @@ PT025.py:16:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures
|
= help: Remove `pytest.mark.usefixtures`
Fix
Safe fix
13 13 |
14 14 |
15 15 | @pytest.fixture()

View file

@ -10,7 +10,7 @@ PT026.py:19:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters
|
= help: Remove `usefixtures` decorator or pass parameters
Suggested fix
Unsafe fix
16 16 | pass
17 17 |
18 18 |
@ -29,7 +29,7 @@ PT026.py:24:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters
|
= help: Remove `usefixtures` decorator or pass parameters
Suggested fix
Unsafe fix
21 21 | pass
22 22 |
23 23 |

View file

@ -12,7 +12,7 @@ PT027_0.py:6:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assert
|
= help: Replace `assertRaises` with `pytest.raises`
Suggested fix
Unsafe fix
1 1 | import unittest
2 |+import pytest
2 3 |
@ -35,7 +35,7 @@ PT027_0.py:8:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assert
|
= help: Replace `assertRaises` with `pytest.raises`
Suggested fix
Unsafe fix
1 1 | import unittest
2 |+import pytest
2 3 |
@ -60,7 +60,7 @@ PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failU
|
= help: Replace `failUnlessRaises` with `pytest.raises`
Suggested fix
Unsafe fix
1 1 | import unittest
2 |+import pytest
2 3 |
@ -86,7 +86,7 @@ PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser
|
= help: Replace `assertRaisesRegex` with `pytest.raises`
Suggested fix
Unsafe fix
1 1 | import unittest
2 |+import pytest
2 3 |
@ -112,7 +112,7 @@ PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser
|
= help: Replace `assertRaisesRegex` with `pytest.raises`
Suggested fix
Unsafe fix
1 1 | import unittest
2 |+import pytest
2 3 |
@ -139,7 +139,7 @@ PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser
|
= help: Replace `assertRaisesRegex` with `pytest.raises`
Suggested fix
Unsafe fix
1 1 | import unittest
2 |+import pytest
2 3 |
@ -168,7 +168,7 @@ PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser
|
= help: Replace `assertRaisesRegex` with `pytest.raises`
Suggested fix
Unsafe fix
1 1 | import unittest
2 |+import pytest
2 3 |
@ -196,7 +196,7 @@ PT027_0.py:30:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser
|
= help: Replace `assertRaisesRegexp` with `pytest.raises`
Suggested fix
Unsafe fix
1 1 | import unittest
2 |+import pytest
2 3 |

Some files were not shown because too many files have changed in this diff Show more