Skip to content

[ruff] Detect \Z in pytest.raises() match patterns (RUF043) - #28598

Merged
MichaReiser merged 1 commit into
astral-sh:mainfrom
r-b-1:main
Sep 15, 2026
Merged

MichaReiser merged 1 commit into
astral-sh:mainfrom
r-b-1:main

Conversation

@r-b-1

@r-b-1 r-b-1 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

RUF043 has a lookup table for escaped regex sequences in pytest.raises(..., match=...), but it was missing \Z, Python's end-of-string anchor. It already flagged \z. This adds \Z to that table and extends the RUF043 tests so both anchors are detected.

Test Plan

The test for this change is as follows: cargo test -p ruff_linter ruf043

… \Z, the end of string anchor. I just added it to the table and the regression tests to make sure its now detected.
@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre September 15, 2026 02:27
@r-b-1 r-b-1 changed the title Added the mising \Z end-of-string anchor to lookup table in RUF043 Added the missing \Z end-of-string anchor to lookup table in RUF043 Sep 15, 2026
@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Sep 15, 2026
@astral-sh-bot

astral-sh-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

βœ… ecosystem check detected no linter changes.

Linter (preview)

βœ… ecosystem check detected no linter changes.

@MichaReiser

Copy link
Copy Markdown
Member

Thank you

@MichaReiser MichaReiser changed the title Added the missing \Z end-of-string anchor to lookup table in RUF043 [ruff] Detect \Z in pytest.raises() match patterns (RUF043) Sep 15, 2026
@MichaReiser
MichaReiser merged commit 3955974 into astral-sh:main Sep 15, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants