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

ℹ Safe fix
12 12 | else:
13 13 |     Bar = Foo
14 14 | 
15    |-a: TypeAlias = 'int'  # TC008
   15 |+a: TypeAlias = int  # TC008
16 16 | b: TypeAlias = 'Dict'  # OK
17 17 | c: TypeAlias = 'Foo'   # TC008
18 18 | d: TypeAlias = 'Foo[str]'  # OK

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

ℹ Safe fix
14 14 | 
15 15 | a: TypeAlias = 'int'  # TC008
16 16 | b: TypeAlias = 'Dict'  # OK
17    |-c: TypeAlias = 'Foo'   # TC008
   17 |+c: TypeAlias = Foo   # TC008
18 18 | d: TypeAlias = 'Foo[str]'  # OK
19 19 | e: TypeAlias = 'Foo.bar'  # OK
20 20 | f: TypeAlias = 'Foo | None'  # TC008

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

ℹ Safe fix
17 17 | c: TypeAlias = 'Foo'   # TC008
18 18 | d: TypeAlias = 'Foo[str]'  # OK
19 19 | e: TypeAlias = 'Foo.bar'  # OK
20    |-f: TypeAlias = 'Foo | None'  # TC008
   20 |+f: TypeAlias = Foo | None  # TC008
21 21 | g: TypeAlias = 'OptStr'   # OK
22 22 | h: TypeAlias = 'Bar'   # TC008
23 23 | i: TypeAlias = Foo['str']   # TC008

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

ℹ Safe fix
19 19 | e: TypeAlias = 'Foo.bar'  # OK
20 20 | f: TypeAlias = 'Foo | None'  # TC008
21 21 | g: TypeAlias = 'OptStr'   # OK
22    |-h: TypeAlias = 'Bar'   # TC008
   22 |+h: TypeAlias = Bar   # TC008
23 23 | i: TypeAlias = Foo['str']   # TC008
24 24 | j: TypeAlias = 'Baz'   # OK
25 25 | k: TypeAlias = 'k | None'  # OK

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

ℹ Safe fix
20 20 | f: TypeAlias = 'Foo | None'  # TC008
21 21 | g: TypeAlias = 'OptStr'   # OK
22 22 | h: TypeAlias = 'Bar'   # TC008
23    |-i: TypeAlias = Foo['str']   # TC008
   23 |+i: TypeAlias = Foo[str]   # TC008
24 24 | j: TypeAlias = 'Baz'   # OK
25 25 | k: TypeAlias = 'k | None'  # OK
26 26 | l: TypeAlias = 'int' | None  # TC008 (because TC010 is not enabled)

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

ℹ Safe fix
23 23 | i: TypeAlias = Foo['str']   # TC008
24 24 | j: TypeAlias = 'Baz'   # OK
25 25 | k: TypeAlias = 'k | None'  # OK
26    |-l: TypeAlias = 'int' | None  # TC008 (because TC010 is not enabled)
   26 |+l: TypeAlias = int | None  # TC008 (because TC010 is not enabled)
27 27 | m: TypeAlias = ('int'  # TC008
28 28 |     | None)
29 29 | n: TypeAlias = ('int'  # TC008 (fix removes comment currently)

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

ℹ Safe fix
24 24 | j: TypeAlias = 'Baz'   # OK
25 25 | k: TypeAlias = 'k | None'  # OK
26 26 | l: TypeAlias = 'int' | None  # TC008 (because TC010 is not enabled)
27    |-m: TypeAlias = ('int'  # TC008
   27 |+m: TypeAlias = (int  # TC008
28 28 |     | None)
29 29 | n: TypeAlias = ('int'  # TC008 (fix removes comment currently)
30 30 |     ' | None')

TC008.py:29:17: TC008 [*] Remove quotes from type alias
   |
27 |   m: TypeAlias = ('int'  # TC008
28 |       | None)
29 |   n: TypeAlias = ('int'  # TC008 (fix removes comment currently)
   |  _________________^
30 | |     ' | None')
   | |_____________^ TC008
31 |
32 |   type B = 'Dict'  # TC008
   |
   = help: Remove quotes

ℹ Unsafe fix
26 26 | l: TypeAlias = 'int' | None  # TC008 (because TC010 is not enabled)
27 27 | m: TypeAlias = ('int'  # TC008
28 28 |     | None)
29    |-n: TypeAlias = ('int'  # TC008 (fix removes comment currently)
30    |-    ' | None')
   29 |+n: TypeAlias = (int | None)
31 30 | 
32 31 | type B = 'Dict'  # TC008
33 32 | type D = 'Foo[str]'  # TC008

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

ℹ Safe fix
29 29 | n: TypeAlias = ('int'  # TC008 (fix removes comment currently)
30 30 |     ' | None')
31 31 | 
32    |-type B = 'Dict'  # TC008
   32 |+type B = Dict  # TC008
33 33 | type D = 'Foo[str]'  # TC008
34 34 | type E = 'Foo.bar'  # TC008
35 35 | type G = 'OptStr'  # TC008

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

ℹ Safe fix
30 30 |     ' | None')
31 31 | 
32 32 | type B = 'Dict'  # TC008
33    |-type D = 'Foo[str]'  # TC008
   33 |+type D = Foo[str]  # TC008
34 34 | type E = 'Foo.bar'  # TC008
35 35 | type G = 'OptStr'  # TC008
36 36 | type I = Foo['str']  # TC008

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

ℹ Safe fix
31 31 | 
32 32 | type B = 'Dict'  # TC008
33 33 | type D = 'Foo[str]'  # TC008
34    |-type E = 'Foo.bar'  # TC008
   34 |+type E = Foo.bar  # TC008
35 35 | type G = 'OptStr'  # TC008
36 36 | type I = Foo['str']  # TC008
37 37 | type J = 'Baz'  # TC008

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

ℹ Safe fix
32 32 | type B = 'Dict'  # TC008
33 33 | type D = 'Foo[str]'  # TC008
34 34 | type E = 'Foo.bar'  # TC008
35    |-type G = 'OptStr'  # TC008
   35 |+type G = OptStr  # TC008
36 36 | type I = Foo['str']  # TC008
37 37 | type J = 'Baz'  # TC008
38 38 | type K = 'K | None'  # TC008

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

ℹ Safe fix
33 33 | type D = 'Foo[str]'  # TC008
34 34 | type E = 'Foo.bar'  # TC008
35 35 | type G = 'OptStr'  # TC008
36    |-type I = Foo['str']  # TC008
   36 |+type I = Foo[str]  # TC008
37 37 | type J = 'Baz'  # TC008
38 38 | type K = 'K | None'  # TC008
39 39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)

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

ℹ Safe fix
34 34 | type E = 'Foo.bar'  # TC008
35 35 | type G = 'OptStr'  # TC008
36 36 | type I = Foo['str']  # TC008
37    |-type J = 'Baz'  # TC008
   37 |+type J = Baz  # TC008
38 38 | type K = 'K | None'  # TC008
39 39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
40 40 | type M = ('int'  # TC008

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

ℹ Safe fix
35 35 | type G = 'OptStr'  # TC008
36 36 | type I = Foo['str']  # TC008
37 37 | type J = 'Baz'  # TC008
38    |-type K = 'K | None'  # TC008
   38 |+type K = K | None  # TC008
39 39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
40 40 | type M = ('int'  # TC008
41 41 |     | None)

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

ℹ Safe fix
36 36 | type I = Foo['str']  # TC008
37 37 | type J = 'Baz'  # TC008
38 38 | type K = 'K | None'  # TC008
39    |-type L = 'int' | None  # TC008 (because TC010 is not enabled)
   39 |+type L = int | None  # TC008 (because TC010 is not enabled)
40 40 | type M = ('int'  # TC008
41 41 |     | None)
42 42 | type N = ('int'  # TC008 (fix removes comment currently)

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

ℹ Safe fix
37 37 | type J = 'Baz'  # TC008
38 38 | type K = 'K | None'  # TC008
39 39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
40    |-type M = ('int'  # TC008
   40 |+type M = (int  # TC008
41 41 |     | None)
42 42 | type N = ('int'  # TC008 (fix removes comment currently)
43 43 |     ' | None')

TC008.py:42:11: TC008 [*] Remove quotes from type alias
   |
40 |   type M = ('int'  # TC008
41 |       | None)
42 |   type N = ('int'  # TC008 (fix removes comment currently)
   |  ___________^
43 | |     ' | None')
   | |_____________^ TC008
   |
   = help: Remove quotes

ℹ Unsafe fix
39 39 | type L = 'int' | None  # TC008 (because TC010 is not enabled)
40 40 | type M = ('int'  # TC008
41 41 |     | None)
42    |-type N = ('int'  # TC008 (fix removes comment currently)
43    |-    ' | None')
   42 |+type N = (int | None)
44 43 | 
45 44 | 
46 45 | class Baz:

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

ℹ Safe fix
45 45 | 
46 46 | class Baz:
47 47 |     a: TypeAlias = 'Baz'  # OK
48    |-    type A = 'Baz'  # TC008
   48 |+    type A = Baz  # TC008
49 49 | 
50 50 |     class Nested:
51 51 |         a: TypeAlias = 'Baz'  # OK

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

ℹ Safe fix
49 49 | 
50 50 |     class Nested:
51 51 |         a: TypeAlias = 'Baz'  # OK
52    |-        type A = 'Baz'  # TC008
   52 |+        type A = Baz  # TC008
53 53 | 
54 54 | # O should have parenthesis added
55 55 | o: TypeAlias = """int

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

ℹ Safe fix
52 52 |         type A = 'Baz'  # TC008
53 53 | 
54 54 | # O should have parenthesis added
55    |-o: TypeAlias = """int
56    |-| None"""
   55 |+o: TypeAlias = (int
   56 |+| None)
57 57 | type O = """int
58 58 | | None"""
59 59 | 

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

ℹ Safe fix
54 54 | # O should have parenthesis added
55 55 | o: TypeAlias = """int
56 56 | | None"""
57    |-type O = """int
58    |-| None"""
   57 |+type O = (int
   58 |+| None)
59 59 | 
60 60 | # P, Q, and R should not have parenthesis added
61 61 | p: TypeAlias = ("""int

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

ℹ Safe fix
58 58 | | None"""
59 59 | 
60 60 | # P, Q, and R should not have parenthesis added
61    |-p: TypeAlias = ("""int
62    |-| None""")
   61 |+p: TypeAlias = (int
   62 |+| None)
63 63 | type P = ("""int
64 64 | | None""")
65 65 | 

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

ℹ Safe fix
60 60 | # P, Q, and R should not have parenthesis added
61 61 | p: TypeAlias = ("""int
62 62 | | None""")
63    |-type P = ("""int
64    |-| None""")
   63 |+type P = (int
   64 |+| None)
65 65 | 
66 66 | q: TypeAlias = """(int
67 67 | | None)"""

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

ℹ Safe fix
63 63 | type P = ("""int
64 64 | | None""")
65 65 | 
66    |-q: TypeAlias = """(int
67    |-| None)"""
   66 |+q: TypeAlias = (int
   67 |+| None)
68 68 | type Q = """(int
69 69 | | None)"""
70 70 | 

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

ℹ Safe fix
65 65 | 
66 66 | q: TypeAlias = """(int
67 67 | | None)"""
68    |-type Q = """(int
69    |-| None)"""
   68 |+type Q = (int
   69 |+| None)
70 70 | 
71 71 | r: TypeAlias = """int | None"""
72 72 | type R = """int | None"""

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

ℹ Safe fix
68 68 | type Q = """(int
69 69 | | None)"""
70 70 | 
71    |-r: TypeAlias = """int | None"""
   71 |+r: TypeAlias = int | None
72 72 | type R = """int | None"""

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

ℹ Safe fix
69 69 | | None)"""
70 70 | 
71 71 | r: TypeAlias = """int | None"""
72    |-type R = """int | None"""
   72 |+type R = int | None
