-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
unnecessary-regular-expression (RUF055) treats ) as a normal character that needs no escaping, but it is actually a metacharacter. This leads to false positives and fixes that change program behavior.
$ cat ruf055.py
import re
print(re.split(r")", "a)b"))
$ python ruf055.py 2>&1 | tail -n 1
re.error: unbalanced parenthesis at position 0
$ ruff check --isolated --preview --select RUF055 ruf055.py --fix
Found 1 error (1 fixed, 0 remaining).
$ cat ruf055.py
import re
print("a)b".split(")"))
$ python ruf055.py
['a', 'b']The current behavior was inspired by this review comment, but that comment only applies to ] and }, not ).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working