diff --git a/crates/ruff_linter/resources/test/fixtures/refurb/FURB167.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB167.py index 0903404c15b977..7df815352fd74a 100644 --- a/crates/ruff_linter/resources/test/fixtures/refurb/FURB167.py +++ b/crates/ruff_linter/resources/test/fixtures/refurb/FURB167.py @@ -2,7 +2,7 @@ def func(): import re # OK - if re.match("^hello", "hello world", re.IGNORECASE): + if re.search("^hello", "hello world", re.IGNORECASE): pass @@ -10,13 +10,13 @@ def func(): import re # FURB167 - if re.match("^hello", "hello world", re.I): + if re.search("^hello", "hello world", re.I): pass def func(): - from re import match, I + from re import search, I # FURB167 - if match("^hello", "hello world", I): + if search("^hello", "hello world", I): pass diff --git a/crates/ruff_linter/src/rules/refurb/rules/regex_flag_alias.rs b/crates/ruff_linter/src/rules/refurb/rules/regex_flag_alias.rs index 5d8b332475613c..80254d27bab336 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/regex_flag_alias.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/regex_flag_alias.rs @@ -20,7 +20,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix}; /// ```python /// import re /// -/// if re.match("^hello", "hello world", re.I): +/// if re.search("^hello", "hello world", re.I): /// ... /// ``` /// @@ -28,7 +28,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix}; /// ```python /// import re /// -/// if re.match("^hello", "hello world", re.IGNORECASE): +/// if re.search("^hello", "hello world", re.IGNORECASE): /// ... /// ``` #[derive(ViolationMetadata)] diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap index 9f70110621000f..14d04ea9d0aa3c 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap @@ -2,29 +2,29 @@ source: crates/ruff_linter/src/rules/refurb/mod.rs --- FURB167 [*] Use of regular expression alias `re.I` - --> FURB167.py:13:42 + --> FURB167.py:13:43 | 12 | # FURB167 -13 | if re.match("^hello", "hello world", re.I): - | ^^^^ +13 | if re.search("^hello", "hello world", re.I): + | ^^^^ 14 | pass | help: Replace with `re.IGNORECASE` 10 | import re 11 | 12 | # FURB167 - - if re.match("^hello", "hello world", re.I): -13 + if re.match("^hello", "hello world", re.IGNORECASE): + - if re.search("^hello", "hello world", re.I): +13 + if re.search("^hello", "hello world", re.IGNORECASE): 14 | pass 15 | 16 | FURB167 [*] Use of regular expression alias `re.I` - --> FURB167.py:21:39 + --> FURB167.py:21:40 | 20 | # FURB167 -21 | if match("^hello", "hello world", I): - | ^ +21 | if search("^hello", "hello world", I): + | ^ 22 | pass | help: Replace with `re.IGNORECASE` @@ -33,9 +33,9 @@ help: Replace with `re.IGNORECASE` 3 | import re 4 | -------------------------------------------------------------------------------- -19 | from re import match, I +19 | from re import search, I 20 | 21 | # FURB167 - - if match("^hello", "hello world", I): -22 + if match("^hello", "hello world", re.IGNORECASE): + - if search("^hello", "hello world", I): +22 + if search("^hello", "hello world", re.IGNORECASE): 23 | pass