mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
![]() ## Summary Implements some of #14738, by adding support for 6 new patterns: ```py re.search("abc", s) is None # ⇒ "abc" not in s re.search("abc", s) is not None # ⇒ "abc" in s re.match("abc", s) is None # ⇒ not s.startswith("abc") re.match("abc", s) is not None # ⇒ s.startswith("abc") re.fullmatch("abc", s) is None # ⇒ s != "abc" re.fullmatch("abc", s) is not None # ⇒ s == "abc" ``` ## Test Plan ```shell cargo nextest run cargo insta review ``` And ran the fix on my startup's repo. ## Note One minor limitation here: ```py if not re.match('abc', s) is None: pass ``` will get fixed to this (technically correct, just not nice): ```py if not not s.startswith('abc'): pass ``` This seems fine given that Ruff has this covered: the initial code should be caught by [E714](https://docs.astral.sh/ruff/rules/not-is-test/) and the fixed code should be caught by [SIM208](https://docs.astral.sh/ruff/rules/double-negation/). |
||
---|---|---|
.. | ||
fixtures | ||
package | ||
project | ||
__init__.py | ||
disallowed_rule_names.txt |