---
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
---
TC008 [*] Remove quotes from type alias
  --> TC008.py:15:16
   |
13 |     Bar = Foo
14 |
15 | a: TypeAlias = 'int'  # TC008
   |                ^^^^^
16 | b: TypeAlias = 'Dict'  # OK
17 | c: TypeAlias = 'Foo'   # TC008
   |
help: Remove quotes
   |
14 |
   - a: TypeAlias = 'int'  # TC008
15 + a: TypeAlias = int  # TC008
16 | b: TypeAlias = 'Dict'  # OK
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:17:16
   |
15 | a: TypeAlias = 'int'  # TC008
16 | b: TypeAlias = 'Dict'  # OK
17 | c: TypeAlias = 'Foo'   # TC008
   |                ^^^^^
18 | d: TypeAlias = 'Foo[str]'  # OK
19 | e: TypeAlias = 'Foo.bar'  # OK
   |
help: Remove quotes
   |
16 | b: TypeAlias = 'Dict'  # OK
   - c: TypeAlias = 'Foo'   # TC008
17 + c: TypeAlias = Foo   # TC008
18 | d: TypeAlias = 'Foo[str]'  # OK
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:20:16
   |
18 | d: TypeAlias = 'Foo[str]'  # OK
19 | e: TypeAlias = 'Foo.bar'  # OK
20 | f: TypeAlias = 'Foo | None'  # TC008
   |                ^^^^^^^^^^^^
21 | g: TypeAlias = 'OptStr'   # OK
22 | h: TypeAlias = 'Bar'   # TC008
   |
help: Remove quotes
   |
19 | e: TypeAlias = 'Foo.bar'  # OK
   - f: TypeAlias = 'Foo | None'  # TC008
20 + f: TypeAlias = Foo | None  # TC008
21 | g: TypeAlias = 'OptStr'   # OK
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:22:16
   |
20 | f: TypeAlias = 'Foo | None'  # TC008
21 | g: TypeAlias = 'OptStr'   # OK
22 | h: TypeAlias = 'Bar'   # TC008
   |                ^^^^^
23 | i: TypeAlias = Foo['str']   # TC008
24 | j: TypeAlias = 'Baz'   # OK
   |
help: Remove quotes
   |
21 | g: TypeAlias = 'OptStr'   # OK
   - h: TypeAlias = 'Bar'   # TC008
22 + h: TypeAlias = Bar   # TC008
23 | i: TypeAlias = Foo['str']   # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:23:20
   |
21 | g: TypeAlias = 'OptStr'   # OK
22 | h: TypeAlias = 'Bar'   # TC008
23 | i: TypeAlias = Foo['str']   # TC008
   |                    ^^^^^
24 | j: TypeAlias = 'Baz'   # OK
25 | k: TypeAlias = 'k | None'  # OK
   |
help: Remove quotes
   |
22 | h: TypeAlias = 'Bar'   # TC008
   - i: TypeAlias = Foo['str']   # TC008
23 + i: TypeAlias = Foo[str]   # TC008
24 | j: TypeAlias = 'Baz'   # OK
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:26:16
   |
24 | j: TypeAlias = 'Baz'   # OK
25 | k: TypeAlias = 'k | None'  # OK
26 | l: TypeAlias = 'int' | None  # TC008 (because TC010 is not enabled)
   |                ^^^^^
27 | m: TypeAlias = ('int'  # TC008
28 |     | None)
   |
help: Remove quotes
   |
25 | k: TypeAlias = 'k | None'  # OK
   - l: TypeAlias = 'int' | None  # TC008 (because TC010 is not enabled)
26 + l: TypeAlias = int | None  # TC008 (because TC010 is not enabled)
27 | m: TypeAlias = ('int'  # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:27:17
   |
25 | k: TypeAlias = 'k | None'  # OK
26 | l: TypeAlias = 'int' | None  # TC008 (because TC010 is not enabled)
27 | m: TypeAlias = ('int'  # TC008
   |                 ^^^^^
28 |     | None)
29 | n: TypeAlias = ('int'  # TC008 (fix removes comment currently)
   |
help: Remove quotes
   |
26 | l: TypeAlias = 'int' | None  # TC008 (because TC010 is not enabled)
   - m: TypeAlias = ('int'  # TC008
27 + m: TypeAlias = (int  # TC008
28 |     | None)
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:29:17
   |
27 |   m: TypeAlias = ('int'  # TC008
28 |       | None)
29 |   n: TypeAlias = ('int'  # TC008 (fix removes comment currently)
   |  _________________^
30 | |     ' | None')
   | |_____________^
31 |
32 |   type B = 'Dict'  # TC008
   |
help: Remove quotes
   |
28 |     | None)
   - n: TypeAlias = ('int'  # TC008 (fix removes comment currently)
   -     ' | None')
29 + n: TypeAlias = (int | None)
30 |
   |
note: This is an unsafe fix and may change runtime behavior

TC008 [*] Remove quotes from type alias
  --> TC008.py:32:10
   |
30 |     ' | None')
31 |
32 | type B = 'Dict'  # TC008
   |          ^^^^^^
33 | type D = 'Foo[str]'  # TC008
34 | type E = 'Foo.bar'  # TC008
   |
help: Remove quotes
   |
31 |
   - type B = 'Dict'  # TC008
32 + type B = Dict  # TC008
33 | type D = 'Foo[str]'  # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:33:10
   |
32 | type B = 'Dict'  # TC008
33 | type D = 'Foo[str]'  # TC008
   |          ^^^^^^^^^^
34 | type E = 'Foo.bar'  # TC008
35 | type G = 'OptStr'  # TC008
   |
help: Remove quotes
   |
32 | type B = 'Dict'  # TC008
   - type D = 'Foo[str]'  # TC008
33 + type D = Foo[str]  # TC008
34 | type E = 'Foo.bar'  # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:34:10
   |
32 | type B = 'Dict'  # TC008
33 | type D = 'Foo[str]'  # TC008
34 | type E = 'Foo.bar'  # TC008
   |          ^^^^^^^^^
35 | type G = 'OptStr'  # TC008
36 | type I = Foo['str']  # TC008
   |
help: Remove quotes
   |
33 | type D = 'Foo[str]'  # TC008
   - type E = 'Foo.bar'  # TC008
34 + type E = Foo.bar  # TC008
35 | type G = 'OptStr'  # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:35:10
   |
33 | type D = 'Foo[str]'  # TC008
34 | type E = 'Foo.bar'  # TC008
35 | type G = 'OptStr'  # TC008
   |          ^^^^^^^^
36 | type I = Foo['str']  # TC008
37 | type J = 'Baz'  # TC008
   |
help: Remove quotes
   |
34 | type E = 'Foo.bar'  # TC008
   - type G = 'OptStr'  # TC008
35 + type G = OptStr  # TC008
36 | type I = Foo['str']  # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:36:14
   |
34 | type E = 'Foo.bar'  # TC008
35 | type G = 'OptStr'  # TC008
36 | type I = Foo['str']  # TC008
   |              ^^^^^
37 | type J = 'Baz'  # TC008
38 | type K = 'K | None'  # TC008
   |
help: Remove quotes
   |
35 | type G = 'OptStr'  # TC008
   - type I = Foo['str']  # TC008
36 + type I = Foo[str]  # TC008
37 | type J = 'Baz'  # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:37:10
   |
35 | type G = 'OptStr'  # TC008
36 | type I = Foo['str']  # TC008
37 | type J = 'Baz'  # TC008
   |          ^^^^^
38 | type K = 'K | None'  # TC008
39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
   |
help: Remove quotes
   |
36 | type I = Foo['str']  # TC008
   - type J = 'Baz'  # TC008
37 + type J = Baz  # TC008
38 | type K = 'K | None'  # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:38:10
   |
36 | type I = Foo['str']  # TC008
37 | type J = 'Baz'  # TC008
38 | type K = 'K | None'  # TC008
   |          ^^^^^^^^^^
39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
40 | type M = ('int'  # TC008
   |
help: Remove quotes
   |
37 | type J = 'Baz'  # TC008
   - type K = 'K | None'  # TC008
38 + type K = K | None  # TC008
39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:39:10
   |
37 | type J = 'Baz'  # TC008
38 | type K = 'K | None'  # TC008
39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
   |          ^^^^^
40 | type M = ('int'  # TC008
41 |     | None)
   |
help: Remove quotes
   |
38 | type K = 'K | None'  # TC008
   - type L = 'int' | None  # TC008 (because TC010 is not enabled)
39 + type L = int | None  # TC008 (because TC010 is not enabled)
40 | type M = ('int'  # TC008
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:40:11
   |
38 | type K = 'K | None'  # TC008
39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
40 | type M = ('int'  # TC008
   |           ^^^^^
41 |     | None)
42 | type N = ('int'  # TC008 (fix removes comment currently)
   |
help: Remove quotes
   |
39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
   - type M = ('int'  # TC008
40 + type M = (int  # TC008
41 |     | None)
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:42:11
   |
40 |   type M = ('int'  # TC008
41 |       | None)
42 |   type N = ('int'  # TC008 (fix removes comment currently)
   |  ___________^
43 | |     ' | None')
   | |_____________^
   |
help: Remove quotes
   |
41 |     | None)
   - type N = ('int'  # TC008 (fix removes comment currently)
   -     ' | None')
42 + type N = (int | None)
43 |
   |
note: This is an unsafe fix and may change runtime behavior

TC008 [*] Remove quotes from type alias
  --> TC008.py:48:14
   |
46 | class Baz:
47 |     a: TypeAlias = 'Baz'  # OK
48 |     type A = 'Baz'  # TC008
   |              ^^^^^
49 |
50 |     class Nested:
   |
help: Remove quotes
   |
47 |     a: TypeAlias = 'Baz'  # OK
   -     type A = 'Baz'  # TC008
48 +     type A = Baz  # TC008
49 |
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:52:18
   |
50 |     class Nested:
51 |         a: TypeAlias = 'Baz'  # OK
52 |         type A = 'Baz'  # TC008
   |                  ^^^^^
53 |
54 | # O should have parenthesis added
   |
help: Remove quotes
   |
51 |         a: TypeAlias = 'Baz'  # OK
   -         type A = 'Baz'  # TC008
52 +         type A = Baz  # TC008
53 |
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:55:16
   |
54 |   # O should have parenthesis added
55 |   o: TypeAlias = """int
   |  ________________^
56 | | | None"""
   | |_________^
57 |   type O = """int
58 |   | None"""
   |
help: Remove quotes
   |
54 | # O should have parenthesis added
   - o: TypeAlias = """int
   - | None"""
55 + o: TypeAlias = (int
56 + | None)
57 | type O = """int
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:57:10
   |
55 |   o: TypeAlias = """int
56 |   | None"""
57 |   type O = """int
   |  __________^
58 | | | None"""
   | |_________^
59 |
60 |   # P, Q, and R should not have parenthesis added
   |
help: Remove quotes
   |
56 | | None"""
   - type O = """int
   - | None"""
57 + type O = (int
58 + | None)
59 |
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:61:17
   |
60 |   # P, Q, and R should not have parenthesis added
61 |   p: TypeAlias = ("""int
   |  _________________^
62 | | | None""")
   | |_________^
63 |   type P = ("""int
64 |   | None""")
   |
help: Remove quotes
   |
60 | # P, Q, and R should not have parenthesis added
   - p: TypeAlias = ("""int
   - | None""")
61 + p: TypeAlias = (int
62 + | None)
63 | type P = ("""int
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:63:11
   |
61 |   p: TypeAlias = ("""int
62 |   | None""")
63 |   type P = ("""int
   |  ___________^
64 | | | None""")
   | |_________^
65 |
66 |   q: TypeAlias = """(int
   |
help: Remove quotes
   |
62 | | None""")
   - type P = ("""int
   - | None""")
63 + type P = (int
64 + | None)
65 |
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:66:16
   |
64 |   | None""")
65 |
66 |   q: TypeAlias = """(int
   |  ________________^
67 | | | None)"""
   | |__________^
68 |   type Q = """(int
69 |   | None)"""
   |
help: Remove quotes
   |
65 |
   - q: TypeAlias = """(int
   - | None)"""
66 + q: TypeAlias = (int
67 + | None)
68 | type Q = """(int
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:68:10
   |
66 |   q: TypeAlias = """(int
67 |   | None)"""
68 |   type Q = """(int
   |  __________^
69 | | | None)"""
   | |__________^
70 |
71 |   r: TypeAlias = """int | None"""
   |
help: Remove quotes
   |
67 | | None)"""
   - type Q = """(int
   - | None)"""
68 + type Q = (int
69 + | None)
70 |
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:71:16
   |
69 | | None)"""
70 |
71 | r: TypeAlias = """int | None"""
   |                ^^^^^^^^^^^^^^^^
72 | type R = """int | None"""
   |
help: Remove quotes
   |
70 |
   - r: TypeAlias = """int | None"""
71 + r: TypeAlias = int | None
72 | type R = """int | None"""
   |

TC008 [*] Remove quotes from type alias
  --> TC008.py:72:10
   |
71 | r: TypeAlias = """int | None"""
72 | type R = """int | None"""
   |          ^^^^^^^^^^^^^^^^
   |
help: Remove quotes
   |
71 | r: TypeAlias = """int | None"""
   - type R = """int | None"""
72 + type R = int | None
   |
