mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-02 04:48:06 +00:00
Fix SIM110 and SIM111 ranges (#4545)
This commit is contained in:
parent
fe7f2e2e4d
commit
a68c865010
3 changed files with 34 additions and 34 deletions
|
|
@ -236,7 +236,7 @@ pub(crate) fn convert_for_loop_to_any_all(
|
|||
ReimplementedBuiltin {
|
||||
repl: contents.clone(),
|
||||
},
|
||||
stmt.range(),
|
||||
TextRange::new(stmt.start(), loop_info.terminal),
|
||||
);
|
||||
if checker.patch(diagnostic.kind.rule()) && checker.ctx.is_builtin("any") {
|
||||
#[allow(deprecated)]
|
||||
|
|
@ -326,7 +326,7 @@ pub(crate) fn convert_for_loop_to_any_all(
|
|||
ReimplementedBuiltin {
|
||||
repl: contents.clone(),
|
||||
},
|
||||
stmt.range(),
|
||||
TextRange::new(stmt.start(), loop_info.terminal),
|
||||
);
|
||||
if checker.patch(diagnostic.kind.rule()) && checker.ctx.is_builtin("all") {
|
||||
#[allow(deprecated)]
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ SIM110.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead o
|
|||
| _____^
|
||||
6 | | if check(x):
|
||||
7 | | return True
|
||||
| |_______________________^ SIM110
|
||||
8 | return False
|
||||
8 | | return False
|
||||
| |________________^ SIM110
|
||||
|
|
||||
= help: Replace with `return any(check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -34,8 +34,8 @@ SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst
|
|||
| _____^
|
||||
28 | | if check(x):
|
||||
29 | | return False
|
||||
| |________________________^ SIM110
|
||||
30 | return True
|
||||
30 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(not check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst
|
|||
| _____^
|
||||
36 | | if not x.is_empty():
|
||||
37 | | return False
|
||||
| |________________________^ SIM110
|
||||
38 | return True
|
||||
38 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(x.is_empty() for x in iterable)`
|
||||
|
||||
|
|
@ -200,8 +200,8 @@ SIM110.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of
|
|||
| _____^
|
||||
127 | | if check(x):
|
||||
128 | | return True
|
||||
| |_______________________^ SIM110
|
||||
129 | return False
|
||||
129 | | return False
|
||||
| |________________^ SIM110
|
||||
|
|
||||
= help: Replace with `return any(check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -213,8 +213,8 @@ SIM110.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead
|
|||
| _____^
|
||||
137 | | if check(x):
|
||||
138 | | return False
|
||||
| |________________________^ SIM110
|
||||
139 | return True
|
||||
139 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(not check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -225,8 +225,8 @@ SIM110.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead
|
|||
| _____^
|
||||
146 | | if check(x):
|
||||
147 | | return True
|
||||
| |_______________________^ SIM110
|
||||
148 | return False
|
||||
148 | | return False
|
||||
| |________________^ SIM110
|
||||
|
|
||||
= help: Replace with `return any(check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -250,8 +250,8 @@ SIM110.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` ins
|
|||
| _____^
|
||||
156 | | if check(x):
|
||||
157 | | return False
|
||||
| |________________________^ SIM110
|
||||
158 | return True
|
||||
158 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(not check(x) for x in iterable)`
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ SIM111.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead o
|
|||
| _____^
|
||||
6 | | if check(x):
|
||||
7 | | return True
|
||||
| |_______________________^ SIM110
|
||||
8 | return False
|
||||
8 | | return False
|
||||
| |________________^ SIM110
|
||||
|
|
||||
= help: Replace with `return any(check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -34,8 +34,8 @@ SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst
|
|||
| _____^
|
||||
28 | | if check(x):
|
||||
29 | | return False
|
||||
| |________________________^ SIM110
|
||||
30 | return True
|
||||
30 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(not check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst
|
|||
| _____^
|
||||
36 | | if not x.is_empty():
|
||||
37 | | return False
|
||||
| |________________________^ SIM110
|
||||
38 | return True
|
||||
38 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(x.is_empty() for x in iterable)`
|
||||
|
||||
|
|
@ -200,8 +200,8 @@ SIM111.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of
|
|||
| _____^
|
||||
127 | | if check(x):
|
||||
128 | | return True
|
||||
| |_______________________^ SIM110
|
||||
129 | return False
|
||||
129 | | return False
|
||||
| |________________^ SIM110
|
||||
|
|
||||
= help: Replace with `return any(check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -213,8 +213,8 @@ SIM111.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead
|
|||
| _____^
|
||||
137 | | if check(x):
|
||||
138 | | return False
|
||||
| |________________________^ SIM110
|
||||
139 | return True
|
||||
139 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(not check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -225,8 +225,8 @@ SIM111.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead
|
|||
| _____^
|
||||
146 | | if check(x):
|
||||
147 | | return True
|
||||
| |_______________________^ SIM110
|
||||
148 | return False
|
||||
148 | | return False
|
||||
| |________________^ SIM110
|
||||
|
|
||||
= help: Replace with `return any(check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -250,8 +250,8 @@ SIM111.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` ins
|
|||
| _____^
|
||||
156 | | if check(x):
|
||||
157 | | return False
|
||||
| |________________________^ SIM110
|
||||
158 | return True
|
||||
158 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(not check(x) for x in iterable)`
|
||||
|
||||
|
|
@ -276,8 +276,8 @@ SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead o
|
|||
| _____^
|
||||
165 | | if x not in y:
|
||||
166 | | return False
|
||||
| |________________________^ SIM110
|
||||
167 | return True
|
||||
167 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(x in y for x in iterable)`
|
||||
|
||||
|
|
@ -302,8 +302,8 @@ SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead o
|
|||
| _____^
|
||||
173 | | if x > y:
|
||||
174 | | return False
|
||||
| |________________________^ SIM110
|
||||
175 | return True
|
||||
175 | | return True
|
||||
| |_______________^ SIM110
|
||||
|
|
||||
= help: Replace with `return all(x <= y for x in iterable)`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue