---
source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs
---
singles_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_is_fine = "'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_is_fine = "'This' is a \"string\""
3 3 | this_is_fine = 'This is a "string"'
4 4 | this_is_fine = '\'This\' is a "string"'

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

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

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

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

singles_escaped.py:21:5: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
19 | foo = (
20 |     f"This is a"
21 |     f"\"string\""
   |     ^^^^^^^^^^^^^ Q003
22 | )
   |
   = help: Change outer quotes to avoid escaping inner quotes

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

singles_escaped.py:31:1: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
29 | #
30 | # but as the actual string itself is invalid pre 3.12, we don't catch it.
31 | f"\"foo\" {"foo"}"  # Q003
   | ^^^^^^^^^^^^^^^^^^ Q003
32 | f"\"foo\" {f"foo"}"  # Q003
33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
28 28 | #   f'"foo" {"nested"}'
29 29 | #
30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it.
31    |-f"\"foo\" {"foo"}"  # Q003
   31 |+f'"foo" {"foo"}'  # Q003
32 32 | f"\"foo\" {f"foo"}"  # Q003
33 33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
34 34 | 

singles_escaped.py:32:1: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
30 | # but as the actual string itself is invalid pre 3.12, we don't catch it.
31 | f"\"foo\" {"foo"}"  # Q003
32 | f"\"foo\" {f"foo"}"  # Q003
   | ^^^^^^^^^^^^^^^^^^^ Q003
33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
29 29 | #
30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it.
31 31 | f"\"foo\" {"foo"}"  # Q003
32    |-f"\"foo\" {f"foo"}"  # Q003
   32 |+f'"foo" {f"foo"}'  # Q003
33 33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
34 34 | 
35 35 | f"normal {f"nested"} normal"

singles_escaped.py:33:1: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
31 | f"\"foo\" {"foo"}"  # Q003
32 | f"\"foo\" {f"foo"}"  # Q003
33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003
34 | 
35 | f"normal {f"nested"} normal"
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it.
31 31 | f"\"foo\" {"foo"}"  # Q003
32 32 | f"\"foo\" {f"foo"}"  # Q003
33    |-f"\"foo\" {f"\"foo\""} \"\""  # Q003
   33 |+f'"foo" {f"\"foo\""} ""'  # Q003
34 34 | 
35 35 | f"normal {f"nested"} normal"
36 36 | f"\"normal\" {f"nested"} normal"  # Q003

singles_escaped.py:33:12: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
31 | f"\"foo\" {"foo"}"  # Q003
32 | f"\"foo\" {f"foo"}"  # Q003
33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
   |            ^^^^^^^^^^ Q003
34 | 
35 | f"normal {f"nested"} normal"
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it.
31 31 | f"\"foo\" {"foo"}"  # Q003
32 32 | f"\"foo\" {f"foo"}"  # Q003
33    |-f"\"foo\" {f"\"foo\""} \"\""  # Q003
   33 |+f"\"foo\" {f'"foo"'} \"\""  # Q003
34 34 | 
35 35 | f"normal {f"nested"} normal"
36 36 | f"\"normal\" {f"nested"} normal"  # Q003

singles_escaped.py:36:1: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
35 | f"normal {f"nested"} normal"
36 | f"\"normal\" {f"nested"} normal"  # Q003
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003
37 | f"\"normal\" {f"nested"} 'single quotes'"
38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
33 33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
34 34 | 
35 35 | f"normal {f"nested"} normal"
36    |-f"\"normal\" {f"nested"} normal"  # Q003
   36 |+f'"normal" {f"nested"} normal'  # Q003
37 37 | f"\"normal\" {f"nested"} 'single quotes'"
38 38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
39 39 | f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal"  # Q003

singles_escaped.py:38:15: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
36 | f"\"normal\" {f"nested"} normal"  # Q003
37 | f"\"normal\" {f"nested"} 'single quotes'"
38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003
39 | f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
35 35 | f"normal {f"nested"} normal"
36 36 | f"\"normal\" {f"nested"} normal"  # Q003
37 37 | f"\"normal\" {f"nested"} 'single quotes'"
38    |-f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
   38 |+f"\"normal\" {f'"nested" {"other"} normal'} 'single quotes'"  # Q003
39 39 | f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal"  # Q003

singles_escaped.py:39:1: Q003 [*] Change outer quotes to avoid escaping inner quotes
   |
37 | f"\"normal\" {f"nested"} 'single quotes'"
38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
39 | f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003
   |
   = help: Change outer quotes to avoid escaping inner quotes

ℹ Safe fix
36 36 | f"\"normal\" {f"nested"} normal"  # Q003
37 37 | f"\"normal\" {f"nested"} 'single quotes'"
38 38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
39    |-f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
   39 |+f'"normal" {f"\"nested\" {"other"} 'single quotes'"} normal'  # Q003


