---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---
RUF039 [*] First argument to `re.compile()` is not raw string
 --> RUF039.py:5:12
  |
4 | # Errors
5 | re.compile('single free-spacing', flags=re.X)
  |            ^^^^^^^^^^^^^^^^^^^^^
6 | re.findall('si\ngle')
7 | re.finditer("dou\ble")
  |
help: Replace with raw string
  |
4 | # Errors
  - re.compile('single free-spacing', flags=re.X)
5 + re.compile(r'single free-spacing', flags=re.X)
6 | re.findall('si\ngle')
  |

RUF039 [*] First argument to `re.findall()` is not raw string
 --> RUF039.py:6:12
  |
4 | # Errors
5 | re.compile('single free-spacing', flags=re.X)
6 | re.findall('si\ngle')
  |            ^^^^^^^^^
7 | re.finditer("dou\ble")
8 | re.fullmatch('''t\riple single''')
  |
help: Replace with raw string
  |
5 | re.compile('single free-spacing', flags=re.X)
  - re.findall('si\ngle')
6 + re.findall(r'si\ngle')
7 | re.finditer("dou\ble")
  |
note: This is an unsafe fix and may change runtime behavior

RUF039 First argument to `re.finditer()` is not raw string
 --> RUF039.py:7:13
  |
5 | re.compile('single free-spacing', flags=re.X)
6 | re.findall('si\ngle')
7 | re.finditer("dou\ble")
  |             ^^^^^^^^^
8 | re.fullmatch('''t\riple single''')
9 | re.match("""\triple double""")
  |
help: Replace with raw string

RUF039 [*] First argument to `re.fullmatch()` is not raw string
  --> RUF039.py:8:14
   |
 6 | re.findall('si\ngle')
 7 | re.finditer("dou\ble")
 8 | re.fullmatch('''t\riple single''')
   |              ^^^^^^^^^^^^^^^^^^^^
 9 | re.match("""\triple double""")
10 | re.search('two', 'args')
   |
help: Replace with raw string
  |
7 | re.finditer("dou\ble")
  - re.fullmatch('''t\riple single''')
8 + re.fullmatch(r'''t\riple single''')
9 | re.match("""\triple double""")
  |
note: This is an unsafe fix and may change runtime behavior

RUF039 [*] First argument to `re.match()` is not raw string
  --> RUF039.py:9:10
   |
 7 | re.finditer("dou\ble")
 8 | re.fullmatch('''t\riple single''')
 9 | re.match("""\triple double""")
   |          ^^^^^^^^^^^^^^^^^^^^
10 | re.search('two', 'args')
11 | re.split("raw", r'second')
   |
help: Replace with raw string
   |
8  | re.fullmatch('''t\riple single''')
   - re.match("""\triple double""")
9  + re.match(r"""\triple double""")
10 | re.search('two', 'args')
   |
note: This is an unsafe fix and may change runtime behavior

RUF039 [*] First argument to `re.search()` is not raw string
  --> RUF039.py:10:11
   |
 8 | re.fullmatch('''t\riple single''')
 9 | re.match("""\triple double""")
10 | re.search('two', 'args')
   |           ^^^^^
11 | re.split("raw", r'second')
12 | re.sub(u'''nicode''', u"f(?i)rst")
   |
help: Replace with raw string
   |
9  | re.match("""\triple double""")
   - re.search('two', 'args')
10 + re.search(r'two', 'args')
11 | re.split("raw", r'second')
   |

RUF039 [*] First argument to `re.split()` is not raw string
  --> RUF039.py:11:10
   |
 9 | re.match("""\triple double""")
10 | re.search('two', 'args')
11 | re.split("raw", r'second')
   |          ^^^^^
12 | re.sub(u'''nicode''', u"f(?i)rst")
13 | re.subn(b"""ytes are""", f"\u006e")
   |
help: Replace with raw string
   |
10 | re.search('two', 'args')
   - re.split("raw", r'second')
11 + re.split(r"raw", r'second')
12 | re.sub(u'''nicode''', u"f(?i)rst")
   |

RUF039 First argument to `re.sub()` is not raw string
  --> RUF039.py:12:8
   |
10 | re.search('two', 'args')
11 | re.split("raw", r'second')
12 | re.sub(u'''nicode''', u"f(?i)rst")
   |        ^^^^^^^^^^^^^
13 | re.subn(b"""ytes are""", f"\u006e")
   |
help: Replace with raw string

RUF039 [*] First argument to `re.subn()` is not raw bytes literal
  --> RUF039.py:13:9
   |
11 | re.split("raw", r'second')
12 | re.sub(u'''nicode''', u"f(?i)rst")
13 | re.subn(b"""ytes are""", f"\u006e")
   |         ^^^^^^^^^^^^^^^
14 |
15 | regex.compile('single free-spacing', flags=regex.X)
   |
help: Replace with raw bytes literal
   |
12 | re.sub(u'''nicode''', u"f(?i)rst")
   - re.subn(b"""ytes are""", f"\u006e")
13 + re.subn(rb"""ytes are""", f"\u006e")
14 |
   |

RUF039 [*] First argument to `regex.compile()` is not raw string
  --> RUF039.py:15:15
   |
13 | re.subn(b"""ytes are""", f"\u006e")
14 |
15 | regex.compile('single free-spacing', flags=regex.X)
   |               ^^^^^^^^^^^^^^^^^^^^^
16 | regex.findall('si\ngle')
17 | regex.finditer("dou\ble")
   |
help: Replace with raw string
   |
14 |
   - regex.compile('single free-spacing', flags=regex.X)
15 + regex.compile(r'single free-spacing', flags=regex.X)
16 | regex.findall('si\ngle')
   |

RUF039 [*] First argument to `regex.findall()` is not raw string
  --> RUF039.py:16:15
   |
15 | regex.compile('single free-spacing', flags=regex.X)
16 | regex.findall('si\ngle')
   |               ^^^^^^^^^
17 | regex.finditer("dou\ble")
18 | regex.fullmatch('''t\riple single''')
   |
help: Replace with raw string
   |
15 | regex.compile('single free-spacing', flags=regex.X)
   - regex.findall('si\ngle')
16 + regex.findall(r'si\ngle')
17 | regex.finditer("dou\ble")
   |
note: This is an unsafe fix and may change runtime behavior

RUF039 First argument to `regex.finditer()` is not raw string
  --> RUF039.py:17:16
   |
15 | regex.compile('single free-spacing', flags=regex.X)
16 | regex.findall('si\ngle')
17 | regex.finditer("dou\ble")
   |                ^^^^^^^^^
18 | regex.fullmatch('''t\riple single''')
19 | regex.match("""\triple double""")
   |
help: Replace with raw string

RUF039 [*] First argument to `regex.fullmatch()` is not raw string
  --> RUF039.py:18:17
   |
16 | regex.findall('si\ngle')
17 | regex.finditer("dou\ble")
18 | regex.fullmatch('''t\riple single''')
   |                 ^^^^^^^^^^^^^^^^^^^^
19 | regex.match("""\triple double""")
20 | regex.search('two', 'args')
   |
help: Replace with raw string
   |
17 | regex.finditer("dou\ble")
   - regex.fullmatch('''t\riple single''')
18 + regex.fullmatch(r'''t\riple single''')
19 | regex.match("""\triple double""")
   |
note: This is an unsafe fix and may change runtime behavior

RUF039 [*] First argument to `regex.match()` is not raw string
  --> RUF039.py:19:13
   |
17 | regex.finditer("dou\ble")
18 | regex.fullmatch('''t\riple single''')
19 | regex.match("""\triple double""")
   |             ^^^^^^^^^^^^^^^^^^^^
20 | regex.search('two', 'args')
21 | regex.split("raw", r'second')
   |
help: Replace with raw string
   |
18 | regex.fullmatch('''t\riple single''')
   - regex.match("""\triple double""")
19 + regex.match(r"""\triple double""")
20 | regex.search('two', 'args')
   |
note: This is an unsafe fix and may change runtime behavior

RUF039 [*] First argument to `regex.search()` is not raw string
  --> RUF039.py:20:14
   |
18 | regex.fullmatch('''t\riple single''')
19 | regex.match("""\triple double""")
20 | regex.search('two', 'args')
   |              ^^^^^
21 | regex.split("raw", r'second')
22 | regex.sub(u'''nicode''', u"f(?i)rst")
   |
help: Replace with raw string
   |
19 | regex.match("""\triple double""")
   - regex.search('two', 'args')
20 + regex.search(r'two', 'args')
21 | regex.split("raw", r'second')
   |

RUF039 [*] First argument to `regex.split()` is not raw string
  --> RUF039.py:21:13
   |
19 | regex.match("""\triple double""")
20 | regex.search('two', 'args')
21 | regex.split("raw", r'second')
   |             ^^^^^
22 | regex.sub(u'''nicode''', u"f(?i)rst")
23 | regex.subn(b"""ytes are""", f"\u006e")
   |
help: Replace with raw string
   |
20 | regex.search('two', 'args')
   - regex.split("raw", r'second')
21 + regex.split(r"raw", r'second')
22 | regex.sub(u'''nicode''', u"f(?i)rst")
   |

RUF039 First argument to `regex.sub()` is not raw string
  --> RUF039.py:22:11
   |
20 | regex.search('two', 'args')
21 | regex.split("raw", r'second')
22 | regex.sub(u'''nicode''', u"f(?i)rst")
   |           ^^^^^^^^^^^^^
23 | regex.subn(b"""ytes are""", f"\u006e")
   |
help: Replace with raw string

RUF039 [*] First argument to `regex.subn()` is not raw bytes literal
  --> RUF039.py:23:12
   |
21 | regex.split("raw", r'second')
22 | regex.sub(u'''nicode''', u"f(?i)rst")
23 | regex.subn(b"""ytes are""", f"\u006e")
   |            ^^^^^^^^^^^^^^^
24 |
25 | regex.template("""(?m)
   |
help: Replace with raw bytes literal
   |
22 | regex.sub(u'''nicode''', u"f(?i)rst")
   - regex.subn(b"""ytes are""", f"\u006e")
23 + regex.subn(rb"""ytes are""", f"\u006e")
24 |
   |

RUF039 [*] First argument to `regex.template()` is not raw string
  --> RUF039.py:25:16
   |
23 |   regex.subn(b"""ytes are""", f"\u006e")
24 |
25 |   regex.template("""(?m)
   |  ________________^
26 | |     (?:ulti)?
27 | |     (?=(?<!(?<=(?!l)))
28 | |     l(?i:ne)
29 | | """, flags = regex.X)
   | |___^
   |
help: Replace with raw string
   |
24 |
   - regex.template("""(?m)
25 + regex.template(r"""(?m)
26 |     (?:ulti)?
   |

RUF039 [*] First argument to `re.compile()` is not raw string
  --> RUF039.py:59:12
   |
58 | # https://github.com/astral-sh/ruff/issues/16713
59 | re.compile("\a\f\n\r\t\u27F2\U0001F0A1\v\x41")  # with unsafe fix
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60 | re.compile("\b")  # without fix
61 | re.compile("\"")  # without fix
   |
help: Replace with raw string
   |
58 | # https://github.com/astral-sh/ruff/issues/16713
   - re.compile("\a\f\n\r\t\u27F2\U0001F0A1\v\x41")  # with unsafe fix
59 + re.compile(r"\a\f\n\r\t\u27F2\U0001F0A1\v\x41")  # with unsafe fix
60 | re.compile("\b")  # without fix
   |
note: This is an unsafe fix and may change runtime behavior

RUF039 First argument to `re.compile()` is not raw string
  --> RUF039.py:60:12
   |
58 | # https://github.com/astral-sh/ruff/issues/16713
59 | re.compile("\a\f\n\r\t\u27F2\U0001F0A1\v\x41")  # with unsafe fix
60 | re.compile("\b")  # without fix
   |            ^^^^
61 | re.compile("\"")  # without fix
62 | re.compile("\'")  # without fix
   |
help: Replace with raw string

RUF039 First argument to `re.compile()` is not raw string
  --> RUF039.py:61:12
   |
59 | re.compile("\a\f\n\r\t\u27F2\U0001F0A1\v\x41")  # with unsafe fix
60 | re.compile("\b")  # without fix
61 | re.compile("\"")  # without fix
   |            ^^^^
62 | re.compile("\'")  # without fix
63 | re.compile('\"')  # without fix
   |
help: Replace with raw string

RUF039 First argument to `re.compile()` is not raw string
  --> RUF039.py:62:12
   |
60 | re.compile("\b")  # without fix
61 | re.compile("\"")  # without fix
62 | re.compile("\'")  # without fix
   |            ^^^^
63 | re.compile('\"')  # without fix
64 | re.compile('\'')  # without fix
   |
help: Replace with raw string

RUF039 First argument to `re.compile()` is not raw string
  --> RUF039.py:63:12
   |
61 | re.compile("\"")  # without fix
62 | re.compile("\'")  # without fix
63 | re.compile('\"')  # without fix
   |            ^^^^
64 | re.compile('\'')  # without fix
65 | re.compile("\\")  # without fix
   |
help: Replace with raw string

RUF039 First argument to `re.compile()` is not raw string
  --> RUF039.py:64:12
   |
62 | re.compile("\'")  # without fix
63 | re.compile('\"')  # without fix
64 | re.compile('\'')  # without fix
   |            ^^^^
65 | re.compile("\\")  # without fix
66 | re.compile("\101")  # without fix
   |
help: Replace with raw string

RUF039 First argument to `re.compile()` is not raw string
  --> RUF039.py:65:12
   |
63 | re.compile('\"')  # without fix
64 | re.compile('\'')  # without fix
65 | re.compile("\\")  # without fix
   |            ^^^^
66 | re.compile("\101")  # without fix
67 | re.compile("a\
   |
help: Replace with raw string

RUF039 First argument to `re.compile()` is not raw string
  --> RUF039.py:66:12
   |
64 | re.compile('\'')  # without fix
65 | re.compile("\\")  # without fix
66 | re.compile("\101")  # without fix
   |            ^^^^^^
67 | re.compile("a\
68 | b")  # without fix
   |
help: Replace with raw string

RUF039 First argument to `re.compile()` is not raw string
  --> RUF039.py:67:12
   |
65 |   re.compile("\\")  # without fix
66 |   re.compile("\101")  # without fix
67 |   re.compile("a\
   |  ____________^
68 | | b")  # without fix
   | |__^
   |
help: Replace with raw string
