Skip to content

Commit

Permalink
Per review
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Jan 5, 2025
1 parent ced50f0 commit 805af26
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions crates/ruff_linter/src/rules/ruff/rules/needless_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::checkers::ast::Checker;
/// Checks for `else` clauses that only contains `pass` and `...` statements.
///
/// ## Why is this bad?
/// Such a clause is unnecessary.
/// Such an else clause does nothing and can be removed.
///
/// ## Example
/// ```python
Expand All @@ -36,7 +36,7 @@ impl AlwaysFixableViolation for NeedlessElse {
}

fn fix_title(&self) -> String {
"Remove clause".to_string()
"Remove `else` clause".to_string()
}
}

Expand Down Expand Up @@ -80,7 +80,7 @@ pub(crate) fn needless_else(checker: &mut Checker, stmt: AnyNodeWithOrElse) {
checker.diagnostics.push(diagnostic.with_fix(fix));
}

/// Whether `body` contains only `pass` or `...` statements.
/// Whether `body` contains only one `pass` or `...` statement.
fn body_is_useless(body: &[Stmt]) -> bool {
match body {
[Stmt::Pass(_)] => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUF047_for.py:4:1: RUF047 [*] Empty `else` clause
5 | | pass
| |________^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
1 1 | for _ in range(0):
Expand All @@ -30,7 +30,7 @@ RUF047_for.py:10:1: RUF047 [*] Empty `else` clause
11 | | ...
| |_______^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
7 7 |
Expand All @@ -51,7 +51,7 @@ RUF047_for.py:36:1: RUF047 [*] Empty `else` clause
| |_______^ RUF047
38 | # too
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
33 33 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUF047_if.py:3:1: RUF047 [*] Empty `else` clause
4 | | pass
| |________^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
1 1 | if False:
Expand All @@ -29,7 +29,7 @@ RUF047_if.py:9:1: RUF047 [*] Empty `else` clause
10 | | ...
| |_______^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
6 6 |
Expand All @@ -49,7 +49,7 @@ RUF047_if.py:17:1: RUF047 [*] Empty `else` clause
18 | | pass
| |________^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
14 14 | treated()
Expand All @@ -70,7 +70,7 @@ RUF047_if.py:41:1: RUF047 [*] Empty `else` clause
| |_______^ RUF047
43 | # comment
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
38 38 |
Expand All @@ -90,7 +90,7 @@ RUF047_if.py:52:1: RUF047 [*] Empty `else` clause
53 |
54 | if of_course:
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
49 49 | # this comment doesn't belong to the if
Expand All @@ -110,7 +110,7 @@ RUF047_if.py:56:1: RUF047 [*] Empty `else` clause
57 |
58 | if of_course:
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
53 53 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUF047_try.py:5:1: RUF047 [*] Empty `else` clause
6 | | pass
| |________^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
2 2 | raise try_body_is_not_checked()
Expand All @@ -30,7 +30,7 @@ RUF047_try.py:15:1: RUF047 [*] Empty `else` clause
16 | | ...
| |_______^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
12 12 | belongs()
Expand All @@ -52,7 +52,7 @@ RUF047_try.py:48:1: RUF047 [*] Empty `else` clause
50 | # This comment belongs to else
51 | finally:
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
45 45 | of_course()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUF047_while.py:4:1: RUF047 [*] Empty `else` clause
5 | | pass
| |________^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
1 1 | while True:
Expand All @@ -30,7 +30,7 @@ RUF047_while.py:10:1: RUF047 [*] Empty `else` clause
11 | | ...
| |_______^ RUF047
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
7 7 |
Expand All @@ -51,7 +51,7 @@ RUF047_while.py:35:1: RUF047 [*] Empty `else` clause
| |_______^ RUF047
37 | # this comment belongs to the else
|
= help: Remove clause
= help: Remove `else` clause

Safe fix
32 32 |
Expand Down

0 comments on commit 805af26

Please sign in to comment.