From a68c8650102a45b2fb663f97db6223f33d0ac6a6 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Sat, 20 May 2023 18:40:35 +0200 Subject: [PATCH] Fix SIM110 and SIM111 ranges (#4545) --- .../rules/reimplemented_builtin.rs | 4 +-- ...ke8_simplify__tests__SIM110_SIM110.py.snap | 28 +++++++-------- ...ke8_simplify__tests__SIM110_SIM111.py.snap | 36 +++++++++---------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs b/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs index 2bbc5740da..3f654ebc4b 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs @@ -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)] diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap index 6048c57d9f..b958d00ed4 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap @@ -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)` diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap index 31159b5430..7355c92fcc 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap @@ -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)`