mirror of https://github.com/astral-sh/ruff
Remove preview gating for `flake8-pie` rules (#9684)
## Summary Both of the preview behaviors gated here seem like improvements, so let's make them stable in v0.2.0
This commit is contained in:
parent
e201f45e5d
commit
2b6e093868
|
|
@ -9,7 +9,6 @@ mod tests {
|
|||
use test_case::test_case;
|
||||
|
||||
use crate::registry::Rule;
|
||||
use crate::settings::types::PreviewMode;
|
||||
use crate::test::test_path;
|
||||
use crate::{assert_messages, settings};
|
||||
|
||||
|
|
@ -31,23 +30,4 @@ mod tests {
|
|||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(Rule::UnnecessaryPlaceholder, Path::new("PIE790.py"))]
|
||||
#[test_case(Rule::ReimplementedContainerBuiltin, Path::new("PIE807.py"))]
|
||||
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
let snapshot = format!(
|
||||
"preview__{}_{}",
|
||||
rule_code.noqa_code(),
|
||||
path.to_string_lossy()
|
||||
);
|
||||
let diagnostics = test_path(
|
||||
Path::new("flake8_pie").join(path).as_path(),
|
||||
&settings::LinterSettings {
|
||||
preview: PreviewMode::Enabled,
|
||||
..settings::LinterSettings::for_rule(rule_code)
|
||||
},
|
||||
)?;
|
||||
assert_messages!(snapshot, diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,7 @@ use ruff_text_size::Ranged;
|
|||
use crate::checkers::ast::Checker;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for lambdas that can be replaced with the `list` builtin.
|
||||
///
|
||||
/// In [preview], this rule will also flag lambdas that can be replaced with
|
||||
/// the `dict` builtin.
|
||||
/// Checks for lambdas that can be replaced with the `list` or `dict` builtins.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// Using container builtins are more succinct and idiomatic than wrapping
|
||||
|
|
@ -40,8 +37,6 @@ use crate::checkers::ast::Checker;
|
|||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `list`](https://docs.python.org/3/library/functions.html#func-list)
|
||||
///
|
||||
/// [preview]: https://docs.astral.sh/ruff/preview/
|
||||
#[violation]
|
||||
pub struct ReimplementedContainerBuiltin {
|
||||
container: Container,
|
||||
|
|
@ -73,11 +68,7 @@ pub(crate) fn reimplemented_container_builtin(checker: &mut Checker, expr: &Expr
|
|||
if parameters.is_none() {
|
||||
let container = match body.as_ref() {
|
||||
Expr::List(ast::ExprList { elts, .. }) if elts.is_empty() => Some(Container::List),
|
||||
Expr::Dict(ast::ExprDict { values, .. })
|
||||
if values.is_empty() & checker.settings.preview.is_enabled() =>
|
||||
{
|
||||
Some(Container::Dict)
|
||||
}
|
||||
Expr::Dict(ast::ExprDict { values, .. }) if values.is_empty() => Some(Container::Dict),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(container) = container {
|
||||
|
|
|
|||
|
|
@ -10,11 +10,8 @@ use crate::checkers::ast::Checker;
|
|||
use crate::fix;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for unnecessary `pass` statements in functions, classes, and other
|
||||
/// blocks.
|
||||
///
|
||||
/// In [preview], this rule also checks for unnecessary ellipsis (`...`)
|
||||
/// literals.
|
||||
/// Checks for unnecessary `pass` statements and ellipsis (`...`) literals in
|
||||
/// functions, classes, and other blocks.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// In Python, the `pass` statement and ellipsis (`...`) literal serve as
|
||||
|
|
@ -40,7 +37,7 @@ use crate::fix;
|
|||
/// """Placeholder docstring."""
|
||||
/// ```
|
||||
///
|
||||
/// In [preview]:
|
||||
/// Or, given:
|
||||
/// ```python
|
||||
/// def func():
|
||||
/// """Placeholder docstring."""
|
||||
|
|
@ -55,8 +52,6 @@ use crate::fix;
|
|||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: The `pass` statement](https://docs.python.org/3/reference/simple_stmts.html#the-pass-statement)
|
||||
///
|
||||
/// [preview]: https://docs.astral.sh/ruff/preview/
|
||||
#[violation]
|
||||
pub struct UnnecessaryPlaceholder {
|
||||
kind: Placeholder,
|
||||
|
|
@ -90,10 +85,7 @@ pub(crate) fn unnecessary_placeholder(checker: &mut Checker, body: &[Stmt]) {
|
|||
for stmt in body {
|
||||
let kind = match stmt {
|
||||
Stmt::Pass(_) => Placeholder::Pass,
|
||||
Stmt::Expr(expr)
|
||||
if expr.value.is_ellipsis_literal_expr()
|
||||
&& checker.settings.preview.is_enabled() =>
|
||||
{
|
||||
Stmt::Expr(expr) if expr.value.is_ellipsis_literal_expr() => {
|
||||
// Ellipses are significant in protocol methods and abstract methods. Specifically,
|
||||
// Pyright uses the presence of an ellipsis to indicate that a method is a stub,
|
||||
// rather than a default implementation.
|
||||
|
|
|
|||
|
|
@ -467,6 +467,176 @@ PIE790.py:150:5: PIE790 [*] Unnecessary `pass` statement
|
|||
152 151 |
|
||||
153 152 | def foo():
|
||||
|
||||
PIE790.py:155:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
153 | def foo():
|
||||
154 | print("foo")
|
||||
155 | ...
|
||||
| ^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
152 152 |
|
||||
153 153 | def foo():
|
||||
154 154 | print("foo")
|
||||
155 |- ...
|
||||
156 155 |
|
||||
157 156 |
|
||||
158 157 | def foo():
|
||||
|
||||
PIE790.py:161:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
159 | """A docstring."""
|
||||
160 | print("foo")
|
||||
161 | ...
|
||||
| ^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
158 158 | def foo():
|
||||
159 159 | """A docstring."""
|
||||
160 160 | print("foo")
|
||||
161 |- ...
|
||||
162 161 |
|
||||
163 162 |
|
||||
164 163 | for i in range(10):
|
||||
|
||||
PIE790.py:165:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
164 | for i in range(10):
|
||||
165 | ...
|
||||
| ^^^ PIE790
|
||||
166 | ...
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
163 163 |
|
||||
164 164 | for i in range(10):
|
||||
165 165 | ...
|
||||
166 |- ...
|
||||
167 166 |
|
||||
168 167 | for i in range(10):
|
||||
169 168 | ...
|
||||
|
||||
PIE790.py:166:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
164 | for i in range(10):
|
||||
165 | ...
|
||||
166 | ...
|
||||
| ^^^ PIE790
|
||||
167 |
|
||||
168 | for i in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
163 163 |
|
||||
164 164 | for i in range(10):
|
||||
165 165 | ...
|
||||
166 |- ...
|
||||
167 166 |
|
||||
168 167 | for i in range(10):
|
||||
169 168 | ...
|
||||
|
||||
PIE790.py:169:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
168 | for i in range(10):
|
||||
169 | ...
|
||||
| ^^^ PIE790
|
||||
170 |
|
||||
171 | ...
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
166 166 | ...
|
||||
167 167 |
|
||||
168 168 | for i in range(10):
|
||||
169 |- ...
|
||||
170 169 |
|
||||
171 170 | ...
|
||||
172 171 |
|
||||
|
||||
PIE790.py:171:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
169 | ...
|
||||
170 |
|
||||
171 | ...
|
||||
| ^^^ PIE790
|
||||
172 |
|
||||
173 | for i in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
168 168 | for i in range(10):
|
||||
169 169 | ...
|
||||
170 170 |
|
||||
171 |- ...
|
||||
172 171 |
|
||||
173 172 | for i in range(10):
|
||||
174 173 | ... # comment
|
||||
|
||||
PIE790.py:174:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
173 | for i in range(10):
|
||||
174 | ... # comment
|
||||
| ^^^ PIE790
|
||||
175 | ...
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
171 171 | ...
|
||||
172 172 |
|
||||
173 173 | for i in range(10):
|
||||
174 |- ... # comment
|
||||
174 |+ # comment
|
||||
175 175 | ...
|
||||
176 176 |
|
||||
177 177 | for i in range(10):
|
||||
|
||||
PIE790.py:175:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
173 | for i in range(10):
|
||||
174 | ... # comment
|
||||
175 | ...
|
||||
| ^^^ PIE790
|
||||
176 |
|
||||
177 | for i in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
172 172 |
|
||||
173 173 | for i in range(10):
|
||||
174 174 | ... # comment
|
||||
175 |- ...
|
||||
176 175 |
|
||||
177 176 | for i in range(10):
|
||||
178 177 | ...
|
||||
|
||||
PIE790.py:178:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
177 | for i in range(10):
|
||||
178 | ...
|
||||
| ^^^ PIE790
|
||||
179 | pass
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
175 175 | ...
|
||||
176 176 |
|
||||
177 177 | for i in range(10):
|
||||
178 |- ...
|
||||
179 178 | pass
|
||||
180 179 |
|
||||
181 180 | from typing import Protocol
|
||||
|
||||
PIE790.py:179:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
177 | for i in range(10):
|
||||
|
|
@ -487,4 +657,19 @@ PIE790.py:179:5: PIE790 [*] Unnecessary `pass` statement
|
|||
181 180 | from typing import Protocol
|
||||
182 181 |
|
||||
|
||||
PIE790.py:209:9: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
207 | def stub(self) -> str:
|
||||
208 | """Docstring"""
|
||||
209 | ...
|
||||
| ^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
206 206 |
|
||||
207 207 | def stub(self) -> str:
|
||||
208 208 | """Docstring"""
|
||||
209 |- ...
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,25 @@ PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda
|
|||
5 5 |
|
||||
6 6 |
|
||||
|
||||
PIE807.py:4:49: PIE807 [*] Prefer `dict` over useless lambda
|
||||
|
|
||||
2 | class Foo:
|
||||
3 | foo: List[str] = field(default_factory=lambda: []) # PIE807
|
||||
4 | bar: Dict[str, int] = field(default_factory=lambda: {}) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `dict`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | @dataclass
|
||||
2 2 | class Foo:
|
||||
3 3 | foo: List[str] = field(default_factory=lambda: []) # PIE807
|
||||
4 |- bar: Dict[str, int] = field(default_factory=lambda: {}) # PIE807
|
||||
4 |+ bar: Dict[str, int] = field(default_factory=dict) # PIE807
|
||||
5 5 |
|
||||
6 6 |
|
||||
7 7 | class FooTable(BaseTable):
|
||||
|
||||
PIE807.py:8:36: PIE807 [*] Prefer `list` over useless lambda
|
||||
|
|
||||
7 | class FooTable(BaseTable):
|
||||
|
|
@ -39,6 +58,25 @@ PIE807.py:8:36: PIE807 [*] Prefer `list` over useless lambda
|
|||
10 10 |
|
||||
11 11 |
|
||||
|
||||
PIE807.py:9:36: PIE807 [*] Prefer `dict` over useless lambda
|
||||
|
|
||||
7 | class FooTable(BaseTable):
|
||||
8 | foo = fields.ListField(default=lambda: []) # PIE807
|
||||
9 | bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `dict`
|
||||
|
||||
ℹ Safe fix
|
||||
6 6 |
|
||||
7 7 | class FooTable(BaseTable):
|
||||
8 8 | foo = fields.ListField(default=lambda: []) # PIE807
|
||||
9 |- bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
9 |+ bar = fields.ListField(default=dict) # PIE807
|
||||
10 10 |
|
||||
11 11 |
|
||||
12 12 | class FooTable(BaseTable):
|
||||
|
||||
PIE807.py:13:28: PIE807 [*] Prefer `list` over useless lambda
|
||||
|
|
||||
12 | class FooTable(BaseTable):
|
||||
|
|
@ -58,4 +96,23 @@ PIE807.py:13:28: PIE807 [*] Prefer `list` over useless lambda
|
|||
15 15 |
|
||||
16 16 |
|
||||
|
||||
PIE807.py:14:36: PIE807 [*] Prefer `dict` over useless lambda
|
||||
|
|
||||
12 | class FooTable(BaseTable):
|
||||
13 | foo = fields.ListField(lambda: []) # PIE807
|
||||
14 | bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `dict`
|
||||
|
||||
ℹ Safe fix
|
||||
11 11 |
|
||||
12 12 | class FooTable(BaseTable):
|
||||
13 13 | foo = fields.ListField(lambda: []) # PIE807
|
||||
14 |- bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
14 |+ bar = fields.ListField(default=dict) # PIE807
|
||||
15 15 |
|
||||
16 16 |
|
||||
17 17 | @dataclass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,675 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_pie/mod.rs
|
||||
---
|
||||
PIE790.py:4:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
2 | """buzz"""
|
||||
3 |
|
||||
4 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | class Foo:
|
||||
2 2 | """buzz"""
|
||||
3 3 |
|
||||
4 |- pass
|
||||
5 4 |
|
||||
6 5 |
|
||||
7 6 | if foo:
|
||||
|
||||
PIE790.py:9:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
7 | if foo:
|
||||
8 | """foo"""
|
||||
9 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
6 6 |
|
||||
7 7 | if foo:
|
||||
8 8 | """foo"""
|
||||
9 |- pass
|
||||
10 9 |
|
||||
11 10 |
|
||||
12 11 | def multi_statement() -> None:
|
||||
|
||||
PIE790.py:14:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
12 | def multi_statement() -> None:
|
||||
13 | """This is a function."""
|
||||
14 | pass; print("hello")
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
11 11 |
|
||||
12 12 | def multi_statement() -> None:
|
||||
13 13 | """This is a function."""
|
||||
14 |- pass; print("hello")
|
||||
14 |+ print("hello")
|
||||
15 15 |
|
||||
16 16 |
|
||||
17 17 | if foo:
|
||||
|
||||
PIE790.py:21:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
19 | else:
|
||||
20 | """bar"""
|
||||
21 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
18 18 | pass
|
||||
19 19 | else:
|
||||
20 20 | """bar"""
|
||||
21 |- pass
|
||||
22 21 |
|
||||
23 22 |
|
||||
24 23 | while True:
|
||||
|
||||
PIE790.py:28:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
26 | else:
|
||||
27 | """bar"""
|
||||
28 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
25 25 | pass
|
||||
26 26 | else:
|
||||
27 27 | """bar"""
|
||||
28 |- pass
|
||||
29 28 |
|
||||
30 29 |
|
||||
31 30 | for _ in range(10):
|
||||
|
||||
PIE790.py:35:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
33 | else:
|
||||
34 | """bar"""
|
||||
35 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
32 32 | pass
|
||||
33 33 | else:
|
||||
34 34 | """bar"""
|
||||
35 |- pass
|
||||
36 35 |
|
||||
37 36 |
|
||||
38 37 | async for _ in range(10):
|
||||
|
||||
PIE790.py:42:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
40 | else:
|
||||
41 | """bar"""
|
||||
42 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
39 39 | pass
|
||||
40 40 | else:
|
||||
41 41 | """bar"""
|
||||
42 |- pass
|
||||
43 42 |
|
||||
44 43 |
|
||||
45 44 | def foo() -> None:
|
||||
|
||||
PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
48 | """
|
||||
49 |
|
||||
50 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
47 47 | buzz
|
||||
48 48 | """
|
||||
49 49 |
|
||||
50 |- pass
|
||||
51 50 |
|
||||
52 51 |
|
||||
53 52 | async def foo():
|
||||
|
||||
PIE790.py:58:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
56 | """
|
||||
57 |
|
||||
58 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
55 55 | buzz
|
||||
56 56 | """
|
||||
57 57 |
|
||||
58 |- pass
|
||||
59 58 |
|
||||
60 59 |
|
||||
61 60 | try:
|
||||
|
||||
PIE790.py:65:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
63 | buzz
|
||||
64 | """
|
||||
65 | pass
|
||||
| ^^^^ PIE790
|
||||
66 | except ValueError:
|
||||
67 | pass
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
62 62 | """
|
||||
63 63 | buzz
|
||||
64 64 | """
|
||||
65 |- pass
|
||||
66 65 | except ValueError:
|
||||
67 66 | pass
|
||||
68 67 |
|
||||
|
||||
PIE790.py:74:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
72 | except ValueError:
|
||||
73 | """bar"""
|
||||
74 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
71 71 | bar()
|
||||
72 72 | except ValueError:
|
||||
73 73 | """bar"""
|
||||
74 |- pass
|
||||
75 74 |
|
||||
76 75 |
|
||||
77 76 | for _ in range(10):
|
||||
|
||||
PIE790.py:79:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
77 | for _ in range(10):
|
||||
78 | """buzz"""
|
||||
79 | pass
|
||||
| ^^^^ PIE790
|
||||
80 |
|
||||
81 | async for _ in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
76 76 |
|
||||
77 77 | for _ in range(10):
|
||||
78 78 | """buzz"""
|
||||
79 |- pass
|
||||
80 79 |
|
||||
81 80 | async for _ in range(10):
|
||||
82 81 | """buzz"""
|
||||
|
||||
PIE790.py:83:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
81 | async for _ in range(10):
|
||||
82 | """buzz"""
|
||||
83 | pass
|
||||
| ^^^^ PIE790
|
||||
84 |
|
||||
85 | while cond:
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
80 80 |
|
||||
81 81 | async for _ in range(10):
|
||||
82 82 | """buzz"""
|
||||
83 |- pass
|
||||
84 83 |
|
||||
85 84 | while cond:
|
||||
86 85 | """buzz"""
|
||||
|
||||
PIE790.py:87:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
85 | while cond:
|
||||
86 | """buzz"""
|
||||
87 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
84 84 |
|
||||
85 85 | while cond:
|
||||
86 86 | """buzz"""
|
||||
87 |- pass
|
||||
88 87 |
|
||||
89 88 |
|
||||
90 89 | with bar:
|
||||
|
||||
PIE790.py:92:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
90 | with bar:
|
||||
91 | """buzz"""
|
||||
92 | pass
|
||||
| ^^^^ PIE790
|
||||
93 |
|
||||
94 | async with bar:
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
89 89 |
|
||||
90 90 | with bar:
|
||||
91 91 | """buzz"""
|
||||
92 |- pass
|
||||
93 92 |
|
||||
94 93 | async with bar:
|
||||
95 94 | """buzz"""
|
||||
|
||||
PIE790.py:96:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
94 | async with bar:
|
||||
95 | """buzz"""
|
||||
96 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
93 93 |
|
||||
94 94 | async with bar:
|
||||
95 95 | """buzz"""
|
||||
96 |- pass
|
||||
97 96 |
|
||||
98 97 |
|
||||
99 98 | def foo() -> None:
|
||||
|
||||
PIE790.py:101:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
99 | def foo() -> None:
|
||||
100 | """buzz"""
|
||||
101 | pass # bar
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
98 98 |
|
||||
99 99 | def foo() -> None:
|
||||
100 100 | """buzz"""
|
||||
101 |- pass # bar
|
||||
101 |+ # bar
|
||||
102 102 |
|
||||
103 103 |
|
||||
104 104 | class Foo:
|
||||
|
||||
PIE790.py:130:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
128 | def foo():
|
||||
129 | print("foo")
|
||||
130 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
127 127 |
|
||||
128 128 | def foo():
|
||||
129 129 | print("foo")
|
||||
130 |- pass
|
||||
131 130 |
|
||||
132 131 |
|
||||
133 132 | def foo():
|
||||
|
||||
PIE790.py:136:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
134 | """A docstring."""
|
||||
135 | print("foo")
|
||||
136 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
133 133 | def foo():
|
||||
134 134 | """A docstring."""
|
||||
135 135 | print("foo")
|
||||
136 |- pass
|
||||
137 136 |
|
||||
138 137 |
|
||||
139 138 | for i in range(10):
|
||||
|
||||
PIE790.py:140:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
139 | for i in range(10):
|
||||
140 | pass
|
||||
| ^^^^ PIE790
|
||||
141 | pass
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
138 138 |
|
||||
139 139 | for i in range(10):
|
||||
140 140 | pass
|
||||
141 |- pass
|
||||
142 141 |
|
||||
143 142 | for i in range(10):
|
||||
144 143 | pass
|
||||
|
||||
PIE790.py:141:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
139 | for i in range(10):
|
||||
140 | pass
|
||||
141 | pass
|
||||
| ^^^^ PIE790
|
||||
142 |
|
||||
143 | for i in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
138 138 |
|
||||
139 139 | for i in range(10):
|
||||
140 140 | pass
|
||||
141 |- pass
|
||||
142 141 |
|
||||
143 142 | for i in range(10):
|
||||
144 143 | pass
|
||||
|
||||
PIE790.py:144:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
143 | for i in range(10):
|
||||
144 | pass
|
||||
| ^^^^ PIE790
|
||||
145 |
|
||||
146 | pass
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
141 141 | pass
|
||||
142 142 |
|
||||
143 143 | for i in range(10):
|
||||
144 |- pass
|
||||
145 144 |
|
||||
146 145 | pass
|
||||
147 146 |
|
||||
|
||||
PIE790.py:146:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
144 | pass
|
||||
145 |
|
||||
146 | pass
|
||||
| ^^^^ PIE790
|
||||
147 |
|
||||
148 | for i in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
143 143 | for i in range(10):
|
||||
144 144 | pass
|
||||
145 145 |
|
||||
146 |- pass
|
||||
147 146 |
|
||||
148 147 | for i in range(10):
|
||||
149 148 | pass # comment
|
||||
|
||||
PIE790.py:149:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
148 | for i in range(10):
|
||||
149 | pass # comment
|
||||
| ^^^^ PIE790
|
||||
150 | pass
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
146 146 | pass
|
||||
147 147 |
|
||||
148 148 | for i in range(10):
|
||||
149 |- pass # comment
|
||||
149 |+ # comment
|
||||
150 150 | pass
|
||||
151 151 |
|
||||
152 152 |
|
||||
|
||||
PIE790.py:150:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
148 | for i in range(10):
|
||||
149 | pass # comment
|
||||
150 | pass
|
||||
| ^^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
147 147 |
|
||||
148 148 | for i in range(10):
|
||||
149 149 | pass # comment
|
||||
150 |- pass
|
||||
151 150 |
|
||||
152 151 |
|
||||
153 152 | def foo():
|
||||
|
||||
PIE790.py:155:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
153 | def foo():
|
||||
154 | print("foo")
|
||||
155 | ...
|
||||
| ^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
152 152 |
|
||||
153 153 | def foo():
|
||||
154 154 | print("foo")
|
||||
155 |- ...
|
||||
156 155 |
|
||||
157 156 |
|
||||
158 157 | def foo():
|
||||
|
||||
PIE790.py:161:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
159 | """A docstring."""
|
||||
160 | print("foo")
|
||||
161 | ...
|
||||
| ^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
158 158 | def foo():
|
||||
159 159 | """A docstring."""
|
||||
160 160 | print("foo")
|
||||
161 |- ...
|
||||
162 161 |
|
||||
163 162 |
|
||||
164 163 | for i in range(10):
|
||||
|
||||
PIE790.py:165:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
164 | for i in range(10):
|
||||
165 | ...
|
||||
| ^^^ PIE790
|
||||
166 | ...
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
163 163 |
|
||||
164 164 | for i in range(10):
|
||||
165 165 | ...
|
||||
166 |- ...
|
||||
167 166 |
|
||||
168 167 | for i in range(10):
|
||||
169 168 | ...
|
||||
|
||||
PIE790.py:166:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
164 | for i in range(10):
|
||||
165 | ...
|
||||
166 | ...
|
||||
| ^^^ PIE790
|
||||
167 |
|
||||
168 | for i in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
163 163 |
|
||||
164 164 | for i in range(10):
|
||||
165 165 | ...
|
||||
166 |- ...
|
||||
167 166 |
|
||||
168 167 | for i in range(10):
|
||||
169 168 | ...
|
||||
|
||||
PIE790.py:169:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
168 | for i in range(10):
|
||||
169 | ...
|
||||
| ^^^ PIE790
|
||||
170 |
|
||||
171 | ...
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
166 166 | ...
|
||||
167 167 |
|
||||
168 168 | for i in range(10):
|
||||
169 |- ...
|
||||
170 169 |
|
||||
171 170 | ...
|
||||
172 171 |
|
||||
|
||||
PIE790.py:171:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
169 | ...
|
||||
170 |
|
||||
171 | ...
|
||||
| ^^^ PIE790
|
||||
172 |
|
||||
173 | for i in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
168 168 | for i in range(10):
|
||||
169 169 | ...
|
||||
170 170 |
|
||||
171 |- ...
|
||||
172 171 |
|
||||
173 172 | for i in range(10):
|
||||
174 173 | ... # comment
|
||||
|
||||
PIE790.py:174:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
173 | for i in range(10):
|
||||
174 | ... # comment
|
||||
| ^^^ PIE790
|
||||
175 | ...
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
171 171 | ...
|
||||
172 172 |
|
||||
173 173 | for i in range(10):
|
||||
174 |- ... # comment
|
||||
174 |+ # comment
|
||||
175 175 | ...
|
||||
176 176 |
|
||||
177 177 | for i in range(10):
|
||||
|
||||
PIE790.py:175:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
173 | for i in range(10):
|
||||
174 | ... # comment
|
||||
175 | ...
|
||||
| ^^^ PIE790
|
||||
176 |
|
||||
177 | for i in range(10):
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
172 172 |
|
||||
173 173 | for i in range(10):
|
||||
174 174 | ... # comment
|
||||
175 |- ...
|
||||
176 175 |
|
||||
177 176 | for i in range(10):
|
||||
178 177 | ...
|
||||
|
||||
PIE790.py:178:5: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
177 | for i in range(10):
|
||||
178 | ...
|
||||
| ^^^ PIE790
|
||||
179 | pass
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
175 175 | ...
|
||||
176 176 |
|
||||
177 177 | for i in range(10):
|
||||
178 |- ...
|
||||
179 178 | pass
|
||||
180 179 |
|
||||
181 180 | from typing import Protocol
|
||||
|
||||
PIE790.py:179:5: PIE790 [*] Unnecessary `pass` statement
|
||||
|
|
||||
177 | for i in range(10):
|
||||
178 | ...
|
||||
179 | pass
|
||||
| ^^^^ PIE790
|
||||
180 |
|
||||
181 | from typing import Protocol
|
||||
|
|
||||
= help: Remove unnecessary `pass`
|
||||
|
||||
ℹ Safe fix
|
||||
176 176 |
|
||||
177 177 | for i in range(10):
|
||||
178 178 | ...
|
||||
179 |- pass
|
||||
180 179 |
|
||||
181 180 | from typing import Protocol
|
||||
182 181 |
|
||||
|
||||
PIE790.py:209:9: PIE790 [*] Unnecessary `...` literal
|
||||
|
|
||||
207 | def stub(self) -> str:
|
||||
208 | """Docstring"""
|
||||
209 | ...
|
||||
| ^^^ PIE790
|
||||
|
|
||||
= help: Remove unnecessary `...`
|
||||
|
||||
ℹ Safe fix
|
||||
206 206 |
|
||||
207 207 | def stub(self) -> str:
|
||||
208 208 | """Docstring"""
|
||||
209 |- ...
|
||||
|
||||
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_pie/mod.rs
|
||||
---
|
||||
PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda
|
||||
|
|
||||
1 | @dataclass
|
||||
2 | class Foo:
|
||||
3 | foo: List[str] = field(default_factory=lambda: []) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
4 | bar: Dict[str, int] = field(default_factory=lambda: {}) # PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `list`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | @dataclass
|
||||
2 2 | class Foo:
|
||||
3 |- foo: List[str] = field(default_factory=lambda: []) # PIE807
|
||||
3 |+ foo: List[str] = field(default_factory=list) # PIE807
|
||||
4 4 | bar: Dict[str, int] = field(default_factory=lambda: {}) # PIE807
|
||||
5 5 |
|
||||
6 6 |
|
||||
|
||||
PIE807.py:4:49: PIE807 [*] Prefer `dict` over useless lambda
|
||||
|
|
||||
2 | class Foo:
|
||||
3 | foo: List[str] = field(default_factory=lambda: []) # PIE807
|
||||
4 | bar: Dict[str, int] = field(default_factory=lambda: {}) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `dict`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | @dataclass
|
||||
2 2 | class Foo:
|
||||
3 3 | foo: List[str] = field(default_factory=lambda: []) # PIE807
|
||||
4 |- bar: Dict[str, int] = field(default_factory=lambda: {}) # PIE807
|
||||
4 |+ bar: Dict[str, int] = field(default_factory=dict) # PIE807
|
||||
5 5 |
|
||||
6 6 |
|
||||
7 7 | class FooTable(BaseTable):
|
||||
|
||||
PIE807.py:8:36: PIE807 [*] Prefer `list` over useless lambda
|
||||
|
|
||||
7 | class FooTable(BaseTable):
|
||||
8 | foo = fields.ListField(default=lambda: []) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
9 | bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `list`
|
||||
|
||||
ℹ Safe fix
|
||||
5 5 |
|
||||
6 6 |
|
||||
7 7 | class FooTable(BaseTable):
|
||||
8 |- foo = fields.ListField(default=lambda: []) # PIE807
|
||||
8 |+ foo = fields.ListField(default=list) # PIE807
|
||||
9 9 | bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
10 10 |
|
||||
11 11 |
|
||||
|
||||
PIE807.py:9:36: PIE807 [*] Prefer `dict` over useless lambda
|
||||
|
|
||||
7 | class FooTable(BaseTable):
|
||||
8 | foo = fields.ListField(default=lambda: []) # PIE807
|
||||
9 | bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `dict`
|
||||
|
||||
ℹ Safe fix
|
||||
6 6 |
|
||||
7 7 | class FooTable(BaseTable):
|
||||
8 8 | foo = fields.ListField(default=lambda: []) # PIE807
|
||||
9 |- bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
9 |+ bar = fields.ListField(default=dict) # PIE807
|
||||
10 10 |
|
||||
11 11 |
|
||||
12 12 | class FooTable(BaseTable):
|
||||
|
||||
PIE807.py:13:28: PIE807 [*] Prefer `list` over useless lambda
|
||||
|
|
||||
12 | class FooTable(BaseTable):
|
||||
13 | foo = fields.ListField(lambda: []) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
14 | bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `list`
|
||||
|
||||
ℹ Safe fix
|
||||
10 10 |
|
||||
11 11 |
|
||||
12 12 | class FooTable(BaseTable):
|
||||
13 |- foo = fields.ListField(lambda: []) # PIE807
|
||||
13 |+ foo = fields.ListField(list) # PIE807
|
||||
14 14 | bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
15 15 |
|
||||
16 16 |
|
||||
|
||||
PIE807.py:14:36: PIE807 [*] Prefer `dict` over useless lambda
|
||||
|
|
||||
12 | class FooTable(BaseTable):
|
||||
13 | foo = fields.ListField(lambda: []) # PIE807
|
||||
14 | bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
| ^^^^^^^^^^ PIE807
|
||||
|
|
||||
= help: Replace with `lambda` with `dict`
|
||||
|
||||
ℹ Safe fix
|
||||
11 11 |
|
||||
12 12 | class FooTable(BaseTable):
|
||||
13 13 | foo = fields.ListField(lambda: []) # PIE807
|
||||
14 |- bar = fields.ListField(default=lambda: {}) # PIE807
|
||||
14 |+ bar = fields.ListField(default=dict) # PIE807
|
||||
15 15 |
|
||||
16 16 |
|
||||
17 17 | @dataclass
|
||||
|
||||
|
||||
Loading…
Reference in New Issue