Commit 730e469
authored
FURB167: change example to
## Summary
The example for
[FURB167](https://docs.astral.sh/ruff/rules/regex-flag-alias/#regex-flag-alias-furb167)
has `re.match` with an `^` anchor to match the start of the string:
```python
if re.match("^hello", "hello world", re.I):
```
But `re.match` already implicitly matches the start of the string:
https://docs.python.org/3/library/re.html#search-vs-match
Let's change the example to `re.search` so the anchor isn't redundant.
(The anchor's actually irrelevant to the example for this rule about
long or short flag names.)
(Aside: There's a discussion about adding `re.prefixmatch` and [soft]
deprecating `re.match` because of the confusion around it:
https://discuss.python.org/t/add-re-prefixmatch-deprecate-re-match/105927,
python/cpython#86519,
python/cpython#31137.)
## Test Plan
<!-- How was it tested? -->
1. Create feature branch
2. Push to my fork to run CI
3. Realise feature branches are disabled for forks in Ruff CI
4. Merge feature branch to my `main`
5. Push that
6. Be happy I did, because it failed because I missed something
7. Fixup, pushup
8. Passes [🎉](https://github.com/hugovk/ruff/actions/runs/21524112749)re.search with ^ anchor (#22984)1 parent e84608b commit 730e469
3 files changed
Lines changed: 17 additions & 17 deletions
File tree
- crates/ruff_linter
- resources/test/fixtures/refurb
- src/rules/refurb
- rules
- snapshots
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
Lines changed: 11 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
| 8 | + | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
| 39 | + | |
| 40 | + | |
41 | 41 | | |
0 commit comments