---
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
RUF043.py:8:43: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
 6 |     ### Errors
 7 |
 8 |     with pytest.raises(FooAtTheEnd, match="foo."): ...
   |                                           ^^^^^^ RUF043
 9 |     with pytest.raises(PackageExtraSpecifier, match="Install `foo[bar]` to enjoy all features"): ...
10 |     with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:9:53: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
 8 |     with pytest.raises(FooAtTheEnd, match="foo."): ...
 9 |     with pytest.raises(PackageExtraSpecifier, match="Install `foo[bar]` to enjoy all features"): ...
   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF043
10 |     with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:10:48: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
 8 |     with pytest.raises(FooAtTheEnd, match="foo."): ...
 9 |     with pytest.raises(PackageExtraSpecifier, match="Install `foo[bar]` to enjoy all features"): ...
10 |     with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ...
   |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF043
11 |
12 |     with pytest.raises(StringConcatenation, match="Huh"
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:12:51: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
10 |       with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ...
11 |
12 |       with pytest.raises(StringConcatenation, match="Huh"
   |  ___________________________________________________^
13 | |                                                   "?"): ...
   | |_____________________________________________________^ RUF043
14 |       with pytest.raises(ManuallyEscapedWindowsPathToDotFile, match="C:\\\\Users\\\\Foo\\\\.config"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:14:67: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
12 |     with pytest.raises(StringConcatenation, match="Huh"
13 |                                                   "?"): ...
14 |     with pytest.raises(ManuallyEscapedWindowsPathToDotFile, match="C:\\\\Users\\\\Foo\\\\.config"): ...
   |                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF043
15 |
16 |     with pytest.raises(MiddleDot, match="foo.bar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:16:41: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
14 |     with pytest.raises(ManuallyEscapedWindowsPathToDotFile, match="C:\\\\Users\\\\Foo\\\\.config"): ...
15 |
16 |     with pytest.raises(MiddleDot, match="foo.bar"): ...
   |                                         ^^^^^^^^^ RUF043
17 |     with pytest.raises(EndDot, match="foobar."): ...
18 |     with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:17:38: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
16 |     with pytest.raises(MiddleDot, match="foo.bar"): ...
17 |     with pytest.raises(EndDot, match="foobar."): ...
   |                                      ^^^^^^^^^ RUF043
18 |     with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ...
19 |     with pytest.raises(UnescapedFollowedByEscaped, match="foo.\\*bar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:18:58: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
16 |     with pytest.raises(MiddleDot, match="foo.bar"): ...
17 |     with pytest.raises(EndDot, match="foobar."): ...
18 |     with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ...
   |                                                          ^^^^^^^^^^^^ RUF043
19 |     with pytest.raises(UnescapedFollowedByEscaped, match="foo.\\*bar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:19:58: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
17 |     with pytest.raises(EndDot, match="foobar."): ...
18 |     with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ...
19 |     with pytest.raises(UnescapedFollowedByEscaped, match="foo.\\*bar"): ...
   |                                                          ^^^^^^^^^^^^ RUF043
20 |
21 |     # https://github.com/astral-sh/ruff/issues/15316
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:22:50: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
21 |     # https://github.com/astral-sh/ruff/issues/15316
22 |     with pytest.raises(ClosingParenthesis, match="foo)"): ...
   |                                                  ^^^^^^ RUF043
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:27:44: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
25 |     ## Metasequences
26 |
27 |     with pytest.raises(StartOfInput, match="foo\\Abar"): ...
   |                                            ^^^^^^^^^^^ RUF043
28 |     with pytest.raises(WordBoundary, match="foo\\bbar"): ...
29 |     with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:28:44: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
27 |     with pytest.raises(StartOfInput, match="foo\\Abar"): ...
28 |     with pytest.raises(WordBoundary, match="foo\\bbar"): ...
   |                                            ^^^^^^^^^^^ RUF043
29 |     with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ...
30 |     with pytest.raises(Digit, match="foo\\dbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:29:47: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
27 |     with pytest.raises(StartOfInput, match="foo\\Abar"): ...
28 |     with pytest.raises(WordBoundary, match="foo\\bbar"): ...
29 |     with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ...
   |                                               ^^^^^^^^^^^ RUF043
30 |     with pytest.raises(Digit, match="foo\\dbar"): ...
31 |     with pytest.raises(NonDigit, match="foo\\Dbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:30:37: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
28 |     with pytest.raises(WordBoundary, match="foo\\bbar"): ...
29 |     with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ...
30 |     with pytest.raises(Digit, match="foo\\dbar"): ...
   |                                     ^^^^^^^^^^^ RUF043
31 |     with pytest.raises(NonDigit, match="foo\\Dbar"): ...
32 |     with pytest.raises(Whitespace, match="foo\\sbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:31:40: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
29 |     with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ...
30 |     with pytest.raises(Digit, match="foo\\dbar"): ...
31 |     with pytest.raises(NonDigit, match="foo\\Dbar"): ...
   |                                        ^^^^^^^^^^^ RUF043
32 |     with pytest.raises(Whitespace, match="foo\\sbar"): ...
33 |     with pytest.raises(NonWhitespace, match="foo\\Sbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:32:42: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
30 |     with pytest.raises(Digit, match="foo\\dbar"): ...
31 |     with pytest.raises(NonDigit, match="foo\\Dbar"): ...
32 |     with pytest.raises(Whitespace, match="foo\\sbar"): ...
   |                                          ^^^^^^^^^^^ RUF043
33 |     with pytest.raises(NonWhitespace, match="foo\\Sbar"): ...
34 |     with pytest.raises(WordCharacter, match="foo\\wbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:33:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
31 |     with pytest.raises(NonDigit, match="foo\\Dbar"): ...
32 |     with pytest.raises(Whitespace, match="foo\\sbar"): ...
33 |     with pytest.raises(NonWhitespace, match="foo\\Sbar"): ...
   |                                             ^^^^^^^^^^^ RUF043
34 |     with pytest.raises(WordCharacter, match="foo\\wbar"): ...
35 |     with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:34:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
32 |     with pytest.raises(Whitespace, match="foo\\sbar"): ...
33 |     with pytest.raises(NonWhitespace, match="foo\\Sbar"): ...
34 |     with pytest.raises(WordCharacter, match="foo\\wbar"): ...
   |                                             ^^^^^^^^^^^ RUF043
35 |     with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ...
36 |     with pytest.raises(EndOfInput, match="foo\\zbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:35:48: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
33 |     with pytest.raises(NonWhitespace, match="foo\\Sbar"): ...
34 |     with pytest.raises(WordCharacter, match="foo\\wbar"): ...
35 |     with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ...
   |                                                ^^^^^^^^^^^ RUF043
36 |     with pytest.raises(EndOfInput, match="foo\\zbar"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:36:42: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
34 |     with pytest.raises(WordCharacter, match="foo\\wbar"): ...
35 |     with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ...
36 |     with pytest.raises(EndOfInput, match="foo\\zbar"): ...
   |                                          ^^^^^^^^^^^ RUF043
37 |
38 |     with pytest.raises(StartOfInput2, match="foobar\\A"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:38:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
36 |     with pytest.raises(EndOfInput, match="foo\\zbar"): ...
37 |
38 |     with pytest.raises(StartOfInput2, match="foobar\\A"): ...
   |                                             ^^^^^^^^^^^ RUF043
39 |     with pytest.raises(WordBoundary2, match="foobar\\b"): ...
40 |     with pytest.raises(NonWordBoundary2, match="foobar\\B"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:39:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
38 |     with pytest.raises(StartOfInput2, match="foobar\\A"): ...
39 |     with pytest.raises(WordBoundary2, match="foobar\\b"): ...
   |                                             ^^^^^^^^^^^ RUF043
40 |     with pytest.raises(NonWordBoundary2, match="foobar\\B"): ...
41 |     with pytest.raises(Digit2, match="foobar\\d"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:40:48: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
38 |     with pytest.raises(StartOfInput2, match="foobar\\A"): ...
39 |     with pytest.raises(WordBoundary2, match="foobar\\b"): ...
40 |     with pytest.raises(NonWordBoundary2, match="foobar\\B"): ...
   |                                                ^^^^^^^^^^^ RUF043
41 |     with pytest.raises(Digit2, match="foobar\\d"): ...
42 |     with pytest.raises(NonDigit2, match="foobar\\D"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:41:38: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
39 |     with pytest.raises(WordBoundary2, match="foobar\\b"): ...
40 |     with pytest.raises(NonWordBoundary2, match="foobar\\B"): ...
41 |     with pytest.raises(Digit2, match="foobar\\d"): ...
   |                                      ^^^^^^^^^^^ RUF043
42 |     with pytest.raises(NonDigit2, match="foobar\\D"): ...
43 |     with pytest.raises(Whitespace2, match="foobar\\s"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:42:41: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
40 |     with pytest.raises(NonWordBoundary2, match="foobar\\B"): ...
41 |     with pytest.raises(Digit2, match="foobar\\d"): ...
42 |     with pytest.raises(NonDigit2, match="foobar\\D"): ...
   |                                         ^^^^^^^^^^^ RUF043
43 |     with pytest.raises(Whitespace2, match="foobar\\s"): ...
44 |     with pytest.raises(NonWhitespace2, match="foobar\\S"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:43:43: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
41 |     with pytest.raises(Digit2, match="foobar\\d"): ...
42 |     with pytest.raises(NonDigit2, match="foobar\\D"): ...
43 |     with pytest.raises(Whitespace2, match="foobar\\s"): ...
   |                                           ^^^^^^^^^^^ RUF043
44 |     with pytest.raises(NonWhitespace2, match="foobar\\S"): ...
45 |     with pytest.raises(WordCharacter2, match="foobar\\w"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:44:46: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
42 |     with pytest.raises(NonDigit2, match="foobar\\D"): ...
43 |     with pytest.raises(Whitespace2, match="foobar\\s"): ...
44 |     with pytest.raises(NonWhitespace2, match="foobar\\S"): ...
   |                                              ^^^^^^^^^^^ RUF043
45 |     with pytest.raises(WordCharacter2, match="foobar\\w"): ...
46 |     with pytest.raises(NonWordCharacter2, match="foobar\\W"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:45:46: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
43 |     with pytest.raises(Whitespace2, match="foobar\\s"): ...
44 |     with pytest.raises(NonWhitespace2, match="foobar\\S"): ...
45 |     with pytest.raises(WordCharacter2, match="foobar\\w"): ...
   |                                              ^^^^^^^^^^^ RUF043
46 |     with pytest.raises(NonWordCharacter2, match="foobar\\W"): ...
47 |     with pytest.raises(EndOfInput2, match="foobar\\z"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:46:49: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
44 |     with pytest.raises(NonWhitespace2, match="foobar\\S"): ...
45 |     with pytest.raises(WordCharacter2, match="foobar\\w"): ...
46 |     with pytest.raises(NonWordCharacter2, match="foobar\\W"): ...
   |                                                 ^^^^^^^^^^^ RUF043
47 |     with pytest.raises(EndOfInput2, match="foobar\\z"): ...
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:47:43: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
45 |     with pytest.raises(WordCharacter2, match="foobar\\w"): ...
46 |     with pytest.raises(NonWordCharacter2, match="foobar\\W"): ...
47 |     with pytest.raises(EndOfInput2, match="foobar\\z"): ...
   |                                           ^^^^^^^^^^^ RUF043
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit

RUF043.py:52:42: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw
   |
50 |     ### Acceptable false positives
51 |
52 |     with pytest.raises(NameEscape, match="\\N{EN DASH}"): ...
   |                                          ^^^^^^^^^^^^^^ RUF043
   |
   = help: Use a raw string or `re.escape()` to make the intention explicit
