---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI030.pyi:9:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
 8 | # Should emit for duplicate field types.
 9 | field2: Literal[1] | Literal[2]  # Error
   |         ^^^^^^^^^^^^^^^^^^^^^^^ PYI030
10 |
11 | # Should emit for union types in arguments.
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
6  6  | field1: Literal[1]  # OK
7  7  | 
8  8  | # Should emit for duplicate field types.
9     |-field2: Literal[1] | Literal[2]  # Error
   9  |+field2: Literal[1, 2]  # Error
10 10 | 
11 11 | # Should emit for union types in arguments.
12 12 | def func1(arg1: Literal[1] | Literal[2]):  # Error

PYI030.pyi:12:17: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
11 | # Should emit for union types in arguments.
12 | def func1(arg1: Literal[1] | Literal[2]):  # Error
   |                 ^^^^^^^^^^^^^^^^^^^^^^^ PYI030
13 |     print(arg1)
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
9  9  | field2: Literal[1] | Literal[2]  # Error
10 10 | 
11 11 | # Should emit for union types in arguments.
12    |-def func1(arg1: Literal[1] | Literal[2]):  # Error
   12 |+def func1(arg1: Literal[1, 2]):  # Error
13 13 |     print(arg1)
14 14 | 
15 15 | 

PYI030.pyi:17:16: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
16 | # Should emit for unions in return types.
17 | def func2() -> Literal[1] | Literal[2]:  # Error
   |                ^^^^^^^^^^^^^^^^^^^^^^^ PYI030
18 |     return "my Literal[1]ing"
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
14 14 | 
15 15 | 
16 16 | # Should emit for unions in return types.
17    |-def func2() -> Literal[1] | Literal[2]:  # Error
   17 |+def func2() -> Literal[1, 2]:  # Error
18 18 |     return "my Literal[1]ing"
19 19 | 
20 20 | 

PYI030.pyi:22:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
21 | # Should emit in longer unions, even if not directly adjacent.
22 | field3: Literal[1] | Literal[2] | str  # Error
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
23 | field4: str | Literal[1] | Literal[2]  # Error
24 | field5: Literal[1] | str | Literal[2]  # Error
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
19 19 | 
20 20 | 
21 21 | # Should emit in longer unions, even if not directly adjacent.
22    |-field3: Literal[1] | Literal[2] | str  # Error
   22 |+field3: Literal[1, 2] | str  # Error
23 23 | field4: str | Literal[1] | Literal[2]  # Error
24 24 | field5: Literal[1] | str | Literal[2]  # Error
25 25 | field6: Literal[1] | bool | Literal[2] | str  # Error

PYI030.pyi:23:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
21 | # Should emit in longer unions, even if not directly adjacent.
22 | field3: Literal[1] | Literal[2] | str  # Error
23 | field4: str | Literal[1] | Literal[2]  # Error
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
24 | field5: Literal[1] | str | Literal[2]  # Error
25 | field6: Literal[1] | bool | Literal[2] | str  # Error
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
20 20 | 
21 21 | # Should emit in longer unions, even if not directly adjacent.
22 22 | field3: Literal[1] | Literal[2] | str  # Error
23    |-field4: str | Literal[1] | Literal[2]  # Error
   23 |+field4: Literal[1, 2] | str  # Error
24 24 | field5: Literal[1] | str | Literal[2]  # Error
25 25 | field6: Literal[1] | bool | Literal[2] | str  # Error
26 26 | 

PYI030.pyi:24:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
22 | field3: Literal[1] | Literal[2] | str  # Error
23 | field4: str | Literal[1] | Literal[2]  # Error
24 | field5: Literal[1] | str | Literal[2]  # Error
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
25 | field6: Literal[1] | bool | Literal[2] | str  # Error
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
21 21 | # Should emit in longer unions, even if not directly adjacent.
22 22 | field3: Literal[1] | Literal[2] | str  # Error
23 23 | field4: str | Literal[1] | Literal[2]  # Error
24    |-field5: Literal[1] | str | Literal[2]  # Error
   24 |+field5: Literal[1, 2] | str  # Error
25 25 | field6: Literal[1] | bool | Literal[2] | str  # Error
26 26 | 
27 27 | # Should emit for non-type unions.

PYI030.pyi:25:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
23 | field4: str | Literal[1] | Literal[2]  # Error
24 | field5: Literal[1] | str | Literal[2]  # Error
25 | field6: Literal[1] | bool | Literal[2] | str  # Error
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
26 |
27 | # Should emit for non-type unions.
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
22 22 | field3: Literal[1] | Literal[2] | str  # Error
23 23 | field4: str | Literal[1] | Literal[2]  # Error
24 24 | field5: Literal[1] | str | Literal[2]  # Error
25    |-field6: Literal[1] | bool | Literal[2] | str  # Error
   25 |+field6: Literal[1, 2] | bool | str  # Error
26 26 | 
27 27 | # Should emit for non-type unions.
28 28 | field7 = Literal[1] | Literal[2]  # Error

PYI030.pyi:28:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
27 | # Should emit for non-type unions.
28 | field7 = Literal[1] | Literal[2]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^ PYI030
29 |
30 | # Should emit for parenthesized unions.
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
25 25 | field6: Literal[1] | bool | Literal[2] | str  # Error
26 26 | 
27 27 | # Should emit for non-type unions.
28    |-field7 = Literal[1] | Literal[2]  # Error
   28 |+field7 = Literal[1, 2]  # Error
29 29 | 
30 30 | # Should emit for parenthesized unions.
31 31 | field8: Literal[1] | (Literal[2] | str)  # Error

PYI030.pyi:31:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
30 | # Should emit for parenthesized unions.
31 | field8: Literal[1] | (Literal[2] | str)  # Error
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
32 |
33 | # Should handle user parentheses when fixing.
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
28 28 | field7 = Literal[1] | Literal[2]  # Error
29 29 | 
30 30 | # Should emit for parenthesized unions.
31    |-field8: Literal[1] | (Literal[2] | str)  # Error
   31 |+field8: Literal[1, 2] | str  # Error
32 32 | 
33 33 | # Should handle user parentheses when fixing.
34 34 | field9: Literal[1] | (Literal[2] | str)  # Error

PYI030.pyi:34:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
33 | # Should handle user parentheses when fixing.
34 | field9: Literal[1] | (Literal[2] | str)  # Error
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
35 | field10: (Literal[1] | str) | Literal[2]  # Error
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
31 31 | field8: Literal[1] | (Literal[2] | str)  # Error
32 32 | 
33 33 | # Should handle user parentheses when fixing.
34    |-field9: Literal[1] | (Literal[2] | str)  # Error
   34 |+field9: Literal[1, 2] | str  # Error
35 35 | field10: (Literal[1] | str) | Literal[2]  # Error
36 36 | 
37 37 | # Should emit for union in generic parent type.

PYI030.pyi:35:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
33 | # Should handle user parentheses when fixing.
34 | field9: Literal[1] | (Literal[2] | str)  # Error
35 | field10: (Literal[1] | str) | Literal[2]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
36 |
37 | # Should emit for union in generic parent type.
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
32 32 | 
33 33 | # Should handle user parentheses when fixing.
34 34 | field9: Literal[1] | (Literal[2] | str)  # Error
35    |-field10: (Literal[1] | str) | Literal[2]  # Error
   35 |+field10: Literal[1, 2] | str  # Error
36 36 | 
37 37 | # Should emit for union in generic parent type.
38 38 | field11: dict[Literal[1] | Literal[2], str]  # Error

PYI030.pyi:38:15: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
37 | # Should emit for union in generic parent type.
38 | field11: dict[Literal[1] | Literal[2], str]  # Error
   |               ^^^^^^^^^^^^^^^^^^^^^^^ PYI030
39 |
40 | # Should emit for unions with more than two cases
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
35 35 | field10: (Literal[1] | str) | Literal[2]  # Error
36 36 | 
37 37 | # Should emit for union in generic parent type.
38    |-field11: dict[Literal[1] | Literal[2], str]  # Error
   38 |+field11: dict[Literal[1, 2], str]  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases
41 41 | field12: Literal[1] | Literal[2] | Literal[3]  # Error

PYI030.pyi:41:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]`
   |
40 | # Should emit for unions with more than two cases
41 | field12: Literal[1] | Literal[2] | Literal[3]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4]  # Error
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
38 38 | field11: dict[Literal[1] | Literal[2], str]  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases
41    |-field12: Literal[1] | Literal[2] | Literal[3]  # Error
   41 |+field12: Literal[1, 2, 3]  # Error
42 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4]  # Error
43 43 | 
44 44 | # Should emit for unions with more than two cases, even if not directly adjacent

PYI030.pyi:42:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]`
   |
40 | # Should emit for unions with more than two cases
41 | field12: Literal[1] | Literal[2] | Literal[3]  # Error
42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
43 |
44 | # Should emit for unions with more than two cases, even if not directly adjacent
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
39 39 | 
40 40 | # Should emit for unions with more than two cases
41 41 | field12: Literal[1] | Literal[2] | Literal[3]  # Error
42    |-field13: Literal[1] | Literal[2] | Literal[3] | Literal[4]  # Error
   42 |+field13: Literal[1, 2, 3, 4]  # Error
43 43 | 
44 44 | # Should emit for unions with more than two cases, even if not directly adjacent
45 45 | field14: Literal[1] | Literal[2] | str | Literal[3]  # Error

PYI030.pyi:45:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]`
   |
44 | # Should emit for unions with more than two cases, even if not directly adjacent
45 | field14: Literal[1] | Literal[2] | str | Literal[3]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
46 |
47 | # Should emit for unions with mixed literal internal types
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
42 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4]  # Error
43 43 | 
44 44 | # Should emit for unions with more than two cases, even if not directly adjacent
45    |-field14: Literal[1] | Literal[2] | str | Literal[3]  # Error
   45 |+field14: Literal[1, 2, 3] | str  # Error
46 46 | 
47 47 | # Should emit for unions with mixed literal internal types
48 48 | field15: Literal[1] | Literal["foo"] | Literal[True]  # Error

PYI030.pyi:48:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, "foo", True]`
   |
47 | # Should emit for unions with mixed literal internal types
48 | field15: Literal[1] | Literal["foo"] | Literal[True]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
49 |
50 | # Shouldn't emit for duplicate field types with same value; covered by Y016
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
45 45 | field14: Literal[1] | Literal[2] | str | Literal[3]  # Error
46 46 | 
47 47 | # Should emit for unions with mixed literal internal types
48    |-field15: Literal[1] | Literal["foo"] | Literal[True]  # Error
   48 |+field15: Literal[1, "foo", True]  # Error
49 49 | 
50 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016
51 51 | field16: Literal[1] | Literal[1]  # OK

PYI030.pyi:51:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 1]`
   |
50 | # Shouldn't emit for duplicate field types with same value; covered by Y016
51 | field16: Literal[1] | Literal[1]  # OK
   |          ^^^^^^^^^^^^^^^^^^^^^^^ PYI030
52 |
53 | # Shouldn't emit if in new parent type
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
48 48 | field15: Literal[1] | Literal["foo"] | Literal[True]  # Error
49 49 | 
50 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016
51    |-field16: Literal[1] | Literal[1]  # OK
   51 |+field16: Literal[1, 1]  # OK
52 52 | 
53 53 | # Shouldn't emit if in new parent type
54 54 | field17: Literal[1] | dict[Literal[2], str]  # OK

PYI030.pyi:60:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
59 | # Should respect name of literal type used
60 | field19: typing.Literal[1] | typing.Literal[2]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
61 |
62 | # Should emit in cases with newlines
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
57 57 | field18: dict[Literal[1], Literal[2]]  # OK
58 58 | 
59 59 | # Should respect name of literal type used
60    |-field19: typing.Literal[1] | typing.Literal[2]  # Error
   60 |+field19: typing.Literal[1, 2]  # Error
61 61 | 
62 62 | # Should emit in cases with newlines
63 63 | field20: typing.Union[

PYI030.pyi:63:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
62 |   # Should emit in cases with newlines
63 |   field20: typing.Union[
   |  __________^
64 | |     Literal[
65 | |         1  # test
66 | |     ],
67 | |     Literal[2],
68 | | ]  # Error, newline and comment will not be emitted in message
   | |_^ PYI030
69 |
70 |   # Should handle multiple unions with multiple members
   |
   = help: Replace with a single `Literal`

ℹ Unsafe fix
60 60 | field19: typing.Literal[1] | typing.Literal[2]  # Error
61 61 | 
62 62 | # Should emit in cases with newlines
63    |-field20: typing.Union[
64    |-    Literal[
65    |-        1  # test
66    |-    ],
67    |-    Literal[2],
68    |-]  # Error, newline and comment will not be emitted in message
   63 |+field20: Literal[1, 2]  # Error, newline and comment will not be emitted in message
69 64 | 
70 65 | # Should handle multiple unions with multiple members
71 66 | field21: Literal[1, 2] | Literal[3, 4]  # Error

PYI030.pyi:71:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]`
   |
70 | # Should handle multiple unions with multiple members
71 | field21: Literal[1, 2] | Literal[3, 4]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
72 |
73 | # Should emit in cases with `typing.Union` instead of `|`
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
68 68 | ]  # Error, newline and comment will not be emitted in message
69 69 | 
70 70 | # Should handle multiple unions with multiple members
71    |-field21: Literal[1, 2] | Literal[3, 4]  # Error
   71 |+field21: Literal[1, 2, 3, 4]  # Error
72 72 | 
73 73 | # Should emit in cases with `typing.Union` instead of `|`
74 74 | field22: typing.Union[Literal[1], Literal[2]]  # Error

PYI030.pyi:74:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
73 | # Should emit in cases with `typing.Union` instead of `|`
74 | field22: typing.Union[Literal[1], Literal[2]]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
75 |
76 | # Should emit in cases with `typing_extensions.Literal`
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
71 71 | field21: Literal[1, 2] | Literal[3, 4]  # Error
72 72 | 
73 73 | # Should emit in cases with `typing.Union` instead of `|`
74    |-field22: typing.Union[Literal[1], Literal[2]]  # Error
   74 |+field22: Literal[1, 2]  # Error
75 75 | 
76 76 | # Should emit in cases with `typing_extensions.Literal`
77 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2]  # Error

PYI030.pyi:77:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
76 | # Should emit in cases with `typing_extensions.Literal`
77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
78 |
79 | # Should emit in cases with nested `typing.Union`
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
74 74 | field22: typing.Union[Literal[1], Literal[2]]  # Error
75 75 | 
76 76 | # Should emit in cases with `typing_extensions.Literal`
77    |-field23: typing_extensions.Literal[1] | typing_extensions.Literal[2]  # Error
   77 |+field23: typing_extensions.Literal[1, 2]  # Error
78 78 | 
79 79 | # Should emit in cases with nested `typing.Union`
80 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]]  # Error

PYI030.pyi:80:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
79 | # Should emit in cases with nested `typing.Union`
80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
81 |
82 | # Should emit in cases with mixed `typing.Union` and `|`
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
77 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2]  # Error
78 78 | 
79 79 | # Should emit in cases with nested `typing.Union`
80    |-field24: typing.Union[Literal[1], typing.Union[Literal[2], str]]  # Error
   80 |+field24: typing.Union[Literal[1, 2], str]  # Error
81 81 | 
82 82 | # Should emit in cases with mixed `typing.Union` and `|`
83 83 | field25: typing.Union[Literal[1], Literal[2] | str]  # Error

PYI030.pyi:83:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]`
   |
82 | # Should emit in cases with mixed `typing.Union` and `|`
83 | field25: typing.Union[Literal[1], Literal[2] | str]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
84 |
85 | # Should emit only once in cases with multiple nested `typing.Union`
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
80 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]]  # Error
81 81 | 
82 82 | # Should emit in cases with mixed `typing.Union` and `|`
83    |-field25: typing.Union[Literal[1], Literal[2] | str]  # Error
   83 |+field25: typing.Union[Literal[1, 2], str]  # Error
84 84 | 
85 85 | # Should emit only once in cases with multiple nested `typing.Union`
86 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]]  # Error

PYI030.pyi:86:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]`
   |
85 | # Should emit only once in cases with multiple nested `typing.Union`
86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
87 |
88 | # Should use the first literal subscript attribute when fixing
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
83 83 | field25: typing.Union[Literal[1], Literal[2] | str]  # Error
84 84 | 
85 85 | # Should emit only once in cases with multiple nested `typing.Union`
86    |-field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]]  # Error
   86 |+field24: Literal[1, 2, 3, 4]  # Error
87 87 | 
88 88 | # Should use the first literal subscript attribute when fixing
89 89 | field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str]  # Error

PYI030.pyi:89:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]`
   |
88 | # Should use the first literal subscript attribute when fixing
89 | field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str]  # Error
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030
90 |
91 | # Should use unsafe fix when comments are deleted
   |
   = help: Replace with a single `Literal`

ℹ Safe fix
86 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]]  # Error
87 87 | 
88 88 | # Should use the first literal subscript attribute when fixing
89    |-field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str]  # Error
   89 |+field25: typing.Union[typing_extensions.Literal[1, 2, 3, 4], str]  # Error
90 90 | 
91 91 | # Should use unsafe fix when comments are deleted
92 92 | field26: (

PYI030.pyi:94:5: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]`
   |
92 |   field26: (
93 |       # First comment
94 | /     Literal["a", "b"]
95 | |     # Second comment
96 | |     | Literal["c", "d"]
   | |_______________________^ PYI030
97 |   )
98 |   field27: (
   |
   = help: Replace with a single `Literal`

ℹ Unsafe fix
91 91 | # Should use unsafe fix when comments are deleted
92 92 | field26: (
93 93 |     # First comment
94    |-    Literal["a", "b"]
95    |-    # Second comment
96    |-    | Literal["c", "d"]
   94 |+    Literal["a", "b", "c", "d"]
97 95 | )
98 96 | field27: (
99 97 |     Literal["a", "b"]  # First comment

PYI030.pyi:99:5: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]`
    |
 97 |   )
 98 |   field27: (
 99 | /     Literal["a", "b"]  # First comment
100 | |     | Literal["c", "d"]  # Second comment
    | |_______________________^ PYI030
101 |   )
    |
    = help: Replace with a single `Literal`

ℹ Unsafe fix
96  96  |     | Literal["c", "d"]
97  97  | )
98  98  | field27: (
99      |-    Literal["a", "b"]  # First comment
100     |-    | Literal["c", "d"]  # Second comment
    99  |+    Literal["a", "b", "c", "d"]  # Second comment
101 100 | )
