ruff
38d4f491 - FURB167: change example to `re.search` with `^` anchor (#22984)

Commit
2 days ago
FURB167: change example to `re.search` with `^` anchor (#22984) ## 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, https://github.com/python/cpython/issues/86519, https://github.com/python/cpython/pull/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)
Author
Parents
Loading