---
source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs
---
Q003 [*] Change outer quotes to avoid escaping inner quotes
 --> singles_escaped.py:1:26
  |
1 | this_should_raise_Q003 = "This is a \"string\""
  |                          ^^^^^^^^^^^^^^^^^^^^^^
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
  |
  - this_should_raise_Q003 = "This is a \"string\""
1 + this_should_raise_Q003 = 'This is a "string"'
2 | this_is_fine = "'This' is a \"string\""
  |

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

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

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

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:31:1
   |
29 | #
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
33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
   |
help: 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.
   - f"\"foo\" {"foo"}"  # Q003
31 + f'"foo" {"foo"}'  # Q003
32 | f"\"foo\" {f"foo"}"  # Q003
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:32:1
   |
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
   | ^^^^^^^^^^^^^^^^^^^
33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
   |
help: Change outer quotes to avoid escaping inner quotes
   |
31 | f"\"foo\" {"foo"}"  # Q003
   - f"\"foo\" {f"foo"}"  # Q003
32 + f'"foo" {f"foo"}'  # Q003
33 | f"\"foo\" {f"\"foo\""} \"\""  # Q003
   |

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

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

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:36:1
   |
35 | f"normal {f"nested"} normal"
36 | f"\"normal\" {f"nested"} normal"  # 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
   |
35 | f"normal {f"nested"} normal"
   - f"\"normal\" {f"nested"} normal"  # Q003
36 + f'"normal" {f"nested"} normal'  # Q003
37 | f"\"normal\" {f"nested"} 'single quotes'"
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:38:15
   |
36 | f"\"normal\" {f"nested"} normal"  # Q003
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
   |
help: Change outer quotes to avoid escaping inner quotes
   |
37 | f"\"normal\" {f"nested"} 'single quotes'"
   - f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
38 + f"\"normal\" {f'"nested" {"other"} normal'} 'single quotes'"  # Q003
39 | f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:39:1
   |
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
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Change outer quotes to avoid escaping inner quotes
   |
38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
   - f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
39 + f'"normal" {f"\"nested\" {"other"} 'single quotes'"} normal'  # Q003
40 |
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:43:1
   |
42 | # Same as above, but with t-strings
43 | t"This is a \"string\""
   | ^^^^^^^^^^^^^^^^^^^^^^^
44 | t"'This' is a \"string\""
45 | f'This is a "string"'
   |
help: Change outer quotes to avoid escaping inner quotes
   |
42 | # Same as above, but with t-strings
   - t"This is a \"string\""
43 + t'This is a "string"'
44 | t"'This' is a \"string\""
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:51:5
   |
49 | foo = (
50 |     t"This is a"
51 |     t"\"string\""
   |     ^^^^^^^^^^^^^
52 | )
53 | t"\"foo\" {"foo"}"  # Q003
   |
help: Change outer quotes to avoid escaping inner quotes
   |
50 |     t"This is a"
   -     t"\"string\""
51 +     t'"string"'
52 | )
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:53:1
   |
51 |     t"\"string\""
52 | )
53 | t"\"foo\" {"foo"}"  # Q003
   | ^^^^^^^^^^^^^^^^^^
54 | t"\"foo\" {t"foo"}"  # Q003
55 | t"\"foo\" {t"\"foo\""} \"\""  # Q003
   |
help: Change outer quotes to avoid escaping inner quotes
   |
52 | )
   - t"\"foo\" {"foo"}"  # Q003
53 + t'"foo" {"foo"}'  # Q003
54 | t"\"foo\" {t"foo"}"  # Q003
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:54:1
   |
52 | )
53 | t"\"foo\" {"foo"}"  # Q003
54 | t"\"foo\" {t"foo"}"  # Q003
   | ^^^^^^^^^^^^^^^^^^^
55 | t"\"foo\" {t"\"foo\""} \"\""  # Q003
   |
help: Change outer quotes to avoid escaping inner quotes
   |
53 | t"\"foo\" {"foo"}"  # Q003
   - t"\"foo\" {t"foo"}"  # Q003
54 + t'"foo" {t"foo"}'  # Q003
55 | t"\"foo\" {t"\"foo\""} \"\""  # Q003
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:55:1
   |
53 | t"\"foo\" {"foo"}"  # Q003
54 | t"\"foo\" {t"foo"}"  # Q003
55 | t"\"foo\" {t"\"foo\""} \"\""  # Q003
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56 |
57 | t"normal {t"nested"} normal"
   |
help: Change outer quotes to avoid escaping inner quotes
   |
54 | t"\"foo\" {t"foo"}"  # Q003
   - t"\"foo\" {t"\"foo\""} \"\""  # Q003
55 + t'"foo" {t"\"foo\""} ""'  # Q003
56 |
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:55:12
   |
53 | t"\"foo\" {"foo"}"  # Q003
54 | t"\"foo\" {t"foo"}"  # Q003
55 | t"\"foo\" {t"\"foo\""} \"\""  # Q003
   |            ^^^^^^^^^^
56 |
57 | t"normal {t"nested"} normal"
   |
help: Change outer quotes to avoid escaping inner quotes
   |
54 | t"\"foo\" {t"foo"}"  # Q003
   - t"\"foo\" {t"\"foo\""} \"\""  # Q003
55 + t"\"foo\" {t'"foo"'} \"\""  # Q003
56 |
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:58:1
   |
57 | t"normal {t"nested"} normal"
58 | t"\"normal\" {t"nested"} normal"  # Q003
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59 | t"\"normal\" {t"nested"} 'single quotes'"
60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
   |
help: Change outer quotes to avoid escaping inner quotes
   |
57 | t"normal {t"nested"} normal"
   - t"\"normal\" {t"nested"} normal"  # Q003
58 + t'"normal" {t"nested"} normal'  # Q003
59 | t"\"normal\" {t"nested"} 'single quotes'"
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:60:15
   |
58 | t"\"normal\" {t"nested"} normal"  # Q003
59 | t"\"normal\" {t"nested"} 'single quotes'"
60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
   |
help: Change outer quotes to avoid escaping inner quotes
   |
59 | t"\"normal\" {t"nested"} 'single quotes'"
   - t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
60 + t"\"normal\" {t'"nested" {"other"} normal'} 'single quotes'"  # Q003
61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
   |

Q003 [*] Change outer quotes to avoid escaping inner quotes
  --> singles_escaped.py:61:1
   |
59 | t"\"normal\" {t"nested"} 'single quotes'"
60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Change outer quotes to avoid escaping inner quotes
   |
60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'"  # Q003
   - t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal"  # Q003
61 + t'"normal" {t"\"nested\" {"other"} 'single quotes'"} normal'  # Q003
   |
