---
source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs
---
doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes
  |
1 | this_should_raise_Q003 = 'This is a \'string\''
  |                          ^^^^^^^^^^^^^^^^^^^^^^ Q003
2 | this_should_raise_Q003 = 'This is \\ a \\\'string\''
3 | this_is_fine = '"This" is a \'string\''
  |
  = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
1   |-this_should_raise_Q003 = 'This is a \'string\''
  1 |+this_should_raise_Q003 = "This is a 'string'"
2 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\''
3 3 | this_is_fine = '"This" is a \'string\''
4 4 | this_is_fine = "This is a 'string'"

doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner quotes
  |
1 | this_should_raise_Q003 = 'This is a \'string\''
2 | this_should_raise_Q003 = 'This is \\ a \\\'string\''
  |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003
3 | this_is_fine = '"This" is a \'string\''
4 | this_is_fine = "This is a 'string'"
  |
  = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
1 1 | this_should_raise_Q003 = 'This is a \'string\''
2   |-this_should_raise_Q003 = 'This is \\ a \\\'string\''
  2 |+this_should_raise_Q003 = "This is \\ a \\'string'"
3 3 | this_is_fine = '"This" is a \'string\''
4 4 | this_is_fine = "This is a 'string'"
5 5 | this_is_fine = "\"This\" is a 'string'"

doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
 8 | this_should_raise = (
 9 |     'This is a'
10 |     '\'string\''
   |     ^^^^^^^^^^^^ Q003
11 | )
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
7  7  | this_is_fine = R'This is a \'string\''
8  8  | this_should_raise = (
9  9  |     'This is a'
10    |-    '\'string\''
   10 |+    "'string'"
11 11 | )
12 12 | 
13 13 | # Same as above, but with f-strings

doubles_escaped.py:14:1: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
13 | # Same as above, but with f-strings
14 | f'This is a \'string\''  # Q003
   | ^^^^^^^^^^^^^^^^^^^^^^^ Q003
15 | f'This is \\ a \\\'string\''  # Q003
16 | f'"This" is a \'string\''
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
11 11 | )
12 12 | 
13 13 | # Same as above, but with f-strings
14    |-f'This is a \'string\''  # Q003
   14 |+f"This is a 'string'"  # Q003
15 15 | f'This is \\ a \\\'string\''  # Q003
16 16 | f'"This" is a \'string\''
17 17 | f"This is a 'string'"

doubles_escaped.py:15:1: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
13 | # Same as above, but with f-strings
14 | f'This is a \'string\''  # Q003
15 | f'This is \\ a \\\'string\''  # Q003
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003
16 | f'"This" is a \'string\''
17 | f"This is a 'string'"
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
12 12 | 
13 13 | # Same as above, but with f-strings
14 14 | f'This is a \'string\''  # Q003
15    |-f'This is \\ a \\\'string\''  # Q003
   15 |+f"This is \\ a \\'string'"  # Q003
16 16 | f'"This" is a \'string\''
17 17 | f"This is a 'string'"
18 18 | f"\"This\" is a 'string'"

doubles_escaped.py:23:5: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
21 | foo = (
22 |     f'This is a'
23 |     f'\'string\''  # Q003
   |     ^^^^^^^^^^^^^ Q003
24 | )
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
20 20 | fR'This is a \'string\''
21 21 | foo = (
22 22 |     f'This is a'
23    |-    f'\'string\''  # Q003
   23 |+    f"'string'"  # Q003
24 24 | )
25 25 | 
26 26 | # Nested f-strings (Python 3.12+)


