[ruff] Treat ) as a regex metacharacter (RUF043, RUF055) (#15318)

## Summary

Resolves #15316.

## Test Plan

`cargo nextest run` and `cargo insta test`.
This commit is contained in:
InSync 2025-01-08 00:11:05 +07:00 committed by GitHub
parent 5567e7c26b
commit e4139568b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 225 additions and 209 deletions

View file

@ -18,6 +18,9 @@ def test_foo():
with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ...
with pytest.raises(UnescapedFollowedByEscaped, match="foo.\\*bar"): ...
# https://github.com/astral-sh/ruff/issues/15316
with pytest.raises(ClosingParenthesis, match="foo)"): ...
## Metasequences

View file

@ -58,6 +58,7 @@ re.sub(r"abc{2,3}", "", s)
re.sub(r"abc\n", "", s) # this one could be fixed but is not currently
re.sub(r"abc|def", "", s)
re.sub(r"(a)bc", "", s)
re.sub(r"a)bc", "", s) # https://github.com/astral-sh/ruff/issues/15316
# and these should not be modified because they have extra arguments
re.sub("abc", "", s, flags=re.A)