Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/ruff_linter/resources/test/fixtures/refurb/FURB167.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ def func():
import re

# OK
if re.match("^hello", "hello world", re.IGNORECASE):
if re.search("^hello", "hello world", re.IGNORECASE):
pass


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
4 changes: 2 additions & 2 deletions crates/ruff_linter/src/rules/refurb/rules/regex_flag_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
/// ```python
/// import re
///
/// if re.match("^hello", "hello world", re.I):
/// if re.search("^hello", "hello world", re.I):
/// ...
/// ```
///
/// Use instead:
/// ```python
/// import re
///
/// if re.match("^hello", "hello world", re.IGNORECASE):
/// if re.search("^hello", "hello world", re.IGNORECASE):
/// ...
/// ```
#[derive(ViolationMetadata)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
Loading