---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI016.py:7:15: PYI016 [*] Duplicate union member `str`
  |
6 | # Should emit for duplicate field types.
7 | field2: str | str  # PYI016: Duplicate union member `str`
  |               ^^^ PYI016
8 |
9 | # Should emit for union types in arguments.
  |
  = help: Remove duplicate union member `str`

ℹ Safe fix
4 4 | field1: str
5 5 | 
6 6 | # Should emit for duplicate field types.
7   |-field2: str | str  # PYI016: Duplicate union member `str`
  7 |+field2: str  # PYI016: Duplicate union member `str`
8 8 | 
9 9 | # Should emit for union types in arguments.
10 10 | def func1(arg1: int | int):  # PYI016: Duplicate union member `int`

PYI016.py:10:23: PYI016 [*] Duplicate union member `int`
   |
 9 | # Should emit for union types in arguments.
10 | def func1(arg1: int | int):  # PYI016: Duplicate union member `int`
   |                       ^^^ PYI016
11 |     print(arg1)
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
7  7  | field2: str | str  # PYI016: Duplicate union member `str`
8  8  | 
9  9  | # Should emit for union types in arguments.
10    |-def func1(arg1: int | int):  # PYI016: Duplicate union member `int`
   10 |+def func1(arg1: int):  # PYI016: Duplicate union member `int`
11 11 |     print(arg1)
12 12 | 
13 13 | # Should emit for unions in return types.

PYI016.py:14:22: PYI016 [*] Duplicate union member `str`
   |
13 | # Should emit for unions in return types.
14 | def func2() -> str | str:  # PYI016: Duplicate union member `str`
   |                      ^^^ PYI016
15 |     return "my string"
   |
   = help: Remove duplicate union member `str`

ℹ Safe fix
11 11 |     print(arg1)
12 12 | 
13 13 | # Should emit for unions in return types.
14    |-def func2() -> str | str:  # PYI016: Duplicate union member `str`
   14 |+def func2() -> str:  # PYI016: Duplicate union member `str`
15 15 |     return "my string"
16 16 | 
17 17 | # Should emit in longer unions, even if not directly adjacent.

PYI016.py:18:15: PYI016 [*] Duplicate union member `str`
   |
17 | # Should emit in longer unions, even if not directly adjacent.
18 | field3: str | str | int  # PYI016: Duplicate union member `str`
   |               ^^^ PYI016
19 | field4: int | int | str  # PYI016: Duplicate union member `int`
20 | field5: str | int | str  # PYI016: Duplicate union member `str`
   |
   = help: Remove duplicate union member `str`

ℹ Safe fix
15 15 |     return "my string"
16 16 | 
17 17 | # Should emit in longer unions, even if not directly adjacent.
18    |-field3: str | str | int  # PYI016: Duplicate union member `str`
   18 |+field3: str | int  # PYI016: Duplicate union member `str`
19 19 | field4: int | int | str  # PYI016: Duplicate union member `int`
20 20 | field5: str | int | str  # PYI016: Duplicate union member `str`
21 21 | field6: int | bool | str | int  # PYI016: Duplicate union member `int`

PYI016.py:19:15: PYI016 [*] Duplicate union member `int`
   |
17 | # Should emit in longer unions, even if not directly adjacent.
18 | field3: str | str | int  # PYI016: Duplicate union member `str`
19 | field4: int | int | str  # PYI016: Duplicate union member `int`
   |               ^^^ PYI016
20 | field5: str | int | str  # PYI016: Duplicate union member `str`
21 | field6: int | bool | str | int  # PYI016: Duplicate union member `int`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
16 16 | 
17 17 | # Should emit in longer unions, even if not directly adjacent.
18 18 | field3: str | str | int  # PYI016: Duplicate union member `str`
19    |-field4: int | int | str  # PYI016: Duplicate union member `int`
   19 |+field4: int | str  # PYI016: Duplicate union member `int`
20 20 | field5: str | int | str  # PYI016: Duplicate union member `str`
21 21 | field6: int | bool | str | int  # PYI016: Duplicate union member `int`
22 22 | 

PYI016.py:20:21: PYI016 [*] Duplicate union member `str`
   |
18 | field3: str | str | int  # PYI016: Duplicate union member `str`
19 | field4: int | int | str  # PYI016: Duplicate union member `int`
20 | field5: str | int | str  # PYI016: Duplicate union member `str`
   |                     ^^^ PYI016
21 | field6: int | bool | str | int  # PYI016: Duplicate union member `int`
   |
   = help: Remove duplicate union member `str`

ℹ Safe fix
17 17 | # Should emit in longer unions, even if not directly adjacent.
18 18 | field3: str | str | int  # PYI016: Duplicate union member `str`
19 19 | field4: int | int | str  # PYI016: Duplicate union member `int`
20    |-field5: str | int | str  # PYI016: Duplicate union member `str`
   20 |+field5: str | int  # PYI016: Duplicate union member `str`
21 21 | field6: int | bool | str | int  # PYI016: Duplicate union member `int`
22 22 | 
23 23 | # Shouldn't emit for non-type unions.

PYI016.py:21:28: PYI016 [*] Duplicate union member `int`
   |
19 | field4: int | int | str  # PYI016: Duplicate union member `int`
20 | field5: str | int | str  # PYI016: Duplicate union member `str`
21 | field6: int | bool | str | int  # PYI016: Duplicate union member `int`
   |                            ^^^ PYI016
22 |
23 | # Shouldn't emit for non-type unions.
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
18 18 | field3: str | str | int  # PYI016: Duplicate union member `str`
19 19 | field4: int | int | str  # PYI016: Duplicate union member `int`
20 20 | field5: str | int | str  # PYI016: Duplicate union member `str`
21    |-field6: int | bool | str | int  # PYI016: Duplicate union member `int`
   21 |+field6: int | bool | str  # PYI016: Duplicate union member `int`
22 22 | 
23 23 | # Shouldn't emit for non-type unions.
24 24 | field7 = str | str

PYI016.py:27:22: PYI016 [*] Duplicate union member `int`
   |
26 | # Should emit for strangely-bracketed unions.
27 | field8: int | (str | int)  # PYI016: Duplicate union member `int`
   |                      ^^^ PYI016
28 |
29 | # Should handle user brackets when fixing.
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
24 24 | field7 = str | str
25 25 | 
26 26 | # Should emit for strangely-bracketed unions.
27    |-field8: int | (str | int)  # PYI016: Duplicate union member `int`
   27 |+field8: int | str  # PYI016: Duplicate union member `int`
28 28 | 
29 29 | # Should handle user brackets when fixing.
30 30 | field9: int | (int | str)  # PYI016: Duplicate union member `int`

PYI016.py:30:16: PYI016 [*] Duplicate union member `int`
   |
29 | # Should handle user brackets when fixing.
30 | field9: int | (int | str)  # PYI016: Duplicate union member `int`
   |                ^^^ PYI016
31 | field10: (str | int) | str  # PYI016: Duplicate union member `str`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
27 27 | field8: int | (str | int)  # PYI016: Duplicate union member `int`
28 28 | 
29 29 | # Should handle user brackets when fixing.
30    |-field9: int | (int | str)  # PYI016: Duplicate union member `int`
   30 |+field9: int | str  # PYI016: Duplicate union member `int`
31 31 | field10: (str | int) | str  # PYI016: Duplicate union member `str`
32 32 | 
33 33 | # Should emit for nested unions.

PYI016.py:31:24: PYI016 [*] Duplicate union member `str`
   |
29 | # Should handle user brackets when fixing.
30 | field9: int | (int | str)  # PYI016: Duplicate union member `int`
31 | field10: (str | int) | str  # PYI016: Duplicate union member `str`
   |                        ^^^ PYI016
32 |
33 | # Should emit for nested unions.
   |
   = help: Remove duplicate union member `str`

ℹ Safe fix
28 28 | 
29 29 | # Should handle user brackets when fixing.
30 30 | field9: int | (int | str)  # PYI016: Duplicate union member `int`
31    |-field10: (str | int) | str  # PYI016: Duplicate union member `str`
   31 |+field10: str | int  # PYI016: Duplicate union member `str`
32 32 | 
33 33 | # Should emit for nested unions.
34 34 | field11: dict[int | int, str]

PYI016.py:34:21: PYI016 [*] Duplicate union member `int`
   |
33 | # Should emit for nested unions.
34 | field11: dict[int | int, str]
   |                     ^^^ PYI016
35 |
36 | # Should emit for unions with more than two cases
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
31 31 | field10: (str | int) | str  # PYI016: Duplicate union member `str`
32 32 | 
33 33 | # Should emit for nested unions.
34    |-field11: dict[int | int, str]
   34 |+field11: dict[int, str]
35 35 | 
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int  # Error

PYI016.py:37:16: PYI016 [*] Duplicate union member `int`
   |
36 | # Should emit for unions with more than two cases
37 | field12: int | int | int  # Error
   |                ^^^ PYI016
38 | field13: int | int | int | int  # Error
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
34 34 | field11: dict[int | int, str]
35 35 | 
36 36 | # Should emit for unions with more than two cases
37    |-field12: int | int | int  # Error
   37 |+field12: int  # Error
38 38 | field13: int | int | int | int  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent

PYI016.py:37:22: PYI016 [*] Duplicate union member `int`
   |
36 | # Should emit for unions with more than two cases
37 | field12: int | int | int  # Error
   |                      ^^^ PYI016
38 | field13: int | int | int | int  # Error
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
34 34 | field11: dict[int | int, str]
35 35 | 
36 36 | # Should emit for unions with more than two cases
37    |-field12: int | int | int  # Error
   37 |+field12: int  # Error
38 38 | field13: int | int | int | int  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent

PYI016.py:38:16: PYI016 [*] Duplicate union member `int`
   |
36 | # Should emit for unions with more than two cases
37 | field12: int | int | int  # Error
38 | field13: int | int | int | int  # Error
   |                ^^^ PYI016
39 |
40 | # Should emit for unions with more than two cases, even if not directly adjacent
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
35 35 | 
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int  # Error
38    |-field13: int | int | int | int  # Error
   38 |+field13: int  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
41 41 | field14: int | int | str | int  # Error

PYI016.py:38:22: PYI016 [*] Duplicate union member `int`
   |
36 | # Should emit for unions with more than two cases
37 | field12: int | int | int  # Error
38 | field13: int | int | int | int  # Error
   |                      ^^^ PYI016
39 |
40 | # Should emit for unions with more than two cases, even if not directly adjacent
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
35 35 | 
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int  # Error
38    |-field13: int | int | int | int  # Error
   38 |+field13: int  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
41 41 | field14: int | int | str | int  # Error

PYI016.py:38:28: PYI016 [*] Duplicate union member `int`
   |
36 | # Should emit for unions with more than two cases
37 | field12: int | int | int  # Error
38 | field13: int | int | int | int  # Error
   |                            ^^^ PYI016
39 |
40 | # Should emit for unions with more than two cases, even if not directly adjacent
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
35 35 | 
36 36 | # Should emit for unions with more than two cases
37 37 | field12: int | int | int  # Error
38    |-field13: int | int | int | int  # Error
   38 |+field13: int  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
41 41 | field14: int | int | str | int  # Error

PYI016.py:41:16: PYI016 [*] Duplicate union member `int`
   |
40 | # Should emit for unions with more than two cases, even if not directly adjacent
41 | field14: int | int | str | int  # Error
   |                ^^^ PYI016
42 |
43 | # Should emit for duplicate literal types; also covered by PYI030
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
38 38 | field13: int | int | int | int  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
41    |-field14: int | int | str | int  # Error
   41 |+field14: int | str  # Error
42 42 | 
43 43 | # Should emit for duplicate literal types; also covered by PYI030
44 44 | field15: typing.Literal[1] | typing.Literal[1]  # Error

PYI016.py:41:28: PYI016 [*] Duplicate union member `int`
   |
40 | # Should emit for unions with more than two cases, even if not directly adjacent
41 | field14: int | int | str | int  # Error
   |                            ^^^ PYI016
42 |
43 | # Should emit for duplicate literal types; also covered by PYI030
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
38 38 | field13: int | int | int | int  # Error
39 39 | 
40 40 | # Should emit for unions with more than two cases, even if not directly adjacent
41    |-field14: int | int | str | int  # Error
   41 |+field14: int | str  # Error
42 42 | 
43 43 | # Should emit for duplicate literal types; also covered by PYI030
44 44 | field15: typing.Literal[1] | typing.Literal[1]  # Error

PYI016.py:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]`
   |
43 | # Should emit for duplicate literal types; also covered by PYI030
44 | field15: typing.Literal[1] | typing.Literal[1]  # Error
   |                              ^^^^^^^^^^^^^^^^^ PYI016
45 |
46 | # Shouldn't emit if in new parent type
   |
   = help: Remove duplicate union member `typing.Literal[1]`

ℹ Safe fix
41 41 | field14: int | int | str | int  # Error
42 42 | 
43 43 | # Should emit for duplicate literal types; also covered by PYI030
44    |-field15: typing.Literal[1] | typing.Literal[1]  # Error
   44 |+field15: typing.Literal[1]  # Error
45 45 | 
46 46 | # Shouldn't emit if in new parent type
47 47 | field16: int | dict[int, str]  # OK

PYI016.py:57:5: PYI016 [*] Duplicate union member `set[int]`
   |
55 |           int  # foo
56 |       ],
57 | /     set[
58 | |         int  # bar
59 | |     ],
   | |_____^ PYI016
60 |   ]  # Error, newline and comment will not be emitted in message
   |
   = help: Remove duplicate union member `set[int]`

ℹ Unsafe fix
50 50 | field17: dict[int, int]  # OK
51 51 | 
52 52 | # Should emit in cases with newlines
53    |-field18: typing.Union[
54    |-    set[
55    |-        int  # foo
56    |-    ],
57    |-    set[
58    |-        int  # bar
59    |-    ],
60    |-]  # Error, newline and comment will not be emitted in message
   53 |+field18: set[int]  # Error, newline and comment will not be emitted in message
61 54 | 
62 55 | # Should emit in cases with `typing.Union` instead of `|`
63 56 | field19: typing.Union[int, int]  # Error

PYI016.py:63:28: PYI016 [*] Duplicate union member `int`
   |
62 | # Should emit in cases with `typing.Union` instead of `|`
63 | field19: typing.Union[int, int]  # Error
   |                            ^^^ PYI016
64 |
65 | # Should emit in cases with nested `typing.Union`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
60 60 | ]  # Error, newline and comment will not be emitted in message
61 61 | 
62 62 | # Should emit in cases with `typing.Union` instead of `|`
63    |-field19: typing.Union[int, int]  # Error
   63 |+field19: int  # Error
64 64 | 
65 65 | # Should emit in cases with nested `typing.Union`
66 66 | field20: typing.Union[int, typing.Union[int, str]]  # Error

PYI016.py:66:41: PYI016 [*] Duplicate union member `int`
   |
65 | # Should emit in cases with nested `typing.Union`
66 | field20: typing.Union[int, typing.Union[int, str]]  # Error
   |                                         ^^^ PYI016
67 |
68 | # Should emit in cases with mixed `typing.Union` and `|`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
63 63 | field19: typing.Union[int, int]  # Error
64 64 | 
65 65 | # Should emit in cases with nested `typing.Union`
66    |-field20: typing.Union[int, typing.Union[int, str]]  # Error
   66 |+field20: typing.Union[int, str]  # Error
67 67 | 
68 68 | # Should emit in cases with mixed `typing.Union` and `|`
69 69 | field21: typing.Union[int, int | str]  # Error

PYI016.py:69:28: PYI016 [*] Duplicate union member `int`
   |
68 | # Should emit in cases with mixed `typing.Union` and `|`
69 | field21: typing.Union[int, int | str]  # Error
   |                            ^^^ PYI016
70 |
71 | # Should emit only once in cases with multiple nested `typing.Union`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
66 66 | field20: typing.Union[int, typing.Union[int, str]]  # Error
67 67 | 
68 68 | # Should emit in cases with mixed `typing.Union` and `|`
69    |-field21: typing.Union[int, int | str]  # Error
   69 |+field21: int | str  # Error
70 70 | 
71 71 | # Should emit only once in cases with multiple nested `typing.Union`
72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]]  # Error

PYI016.py:72:41: PYI016 [*] Duplicate union member `int`
   |
71 | # Should emit only once in cases with multiple nested `typing.Union`
72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]]  # Error
   |                                         ^^^ PYI016
73 |
74 | # Should emit in cases with newlines
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
69 69 | field21: typing.Union[int, int | str]  # Error
70 70 | 
71 71 | # Should emit only once in cases with multiple nested `typing.Union`
72    |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]]  # Error
   72 |+field22: int  # Error
73 73 | 
74 74 | # Should emit in cases with newlines
75 75 | field23: set[  # foo

PYI016.py:72:59: PYI016 [*] Duplicate union member `int`
   |
71 | # Should emit only once in cases with multiple nested `typing.Union`
72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]]  # Error
   |                                                           ^^^ PYI016
73 |
74 | # Should emit in cases with newlines
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
69 69 | field21: typing.Union[int, int | str]  # Error
70 70 | 
71 71 | # Should emit only once in cases with multiple nested `typing.Union`
72    |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]]  # Error
   72 |+field22: int  # Error
73 73 | 
74 74 | # Should emit in cases with newlines
75 75 | field23: set[  # foo

PYI016.py:72:64: PYI016 [*] Duplicate union member `int`
   |
71 | # Should emit only once in cases with multiple nested `typing.Union`
72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]]  # Error
   |                                                                ^^^ PYI016
73 |
74 | # Should emit in cases with newlines
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
69 69 | field21: typing.Union[int, int | str]  # Error
70 70 | 
71 71 | # Should emit only once in cases with multiple nested `typing.Union`
72    |-field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]]  # Error
   72 |+field22: int  # Error
73 73 | 
74 74 | # Should emit in cases with newlines
75 75 | field23: set[  # foo

PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]`
   |
74 | # Should emit in cases with newlines
75 | field23: set[  # foo
76 |     int] | set[int]
   |            ^^^^^^^^ PYI016
77 |
78 | # Should emit twice (once for each `int` in the nested union, both of which are
   |
   = help: Remove duplicate union member `set[int]`

ℹ Unsafe fix
72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]]  # Error
73 73 | 
74 74 | # Should emit in cases with newlines
75    |-field23: set[  # foo
76    |-    int] | set[int]
   75 |+field23: set[int]
77 76 | 
78 77 | # Should emit twice (once for each `int` in the nested union, both of which are
79 78 | # duplicates of the outer `int`), but not three times (which would indicate that

PYI016.py:81:41: PYI016 [*] Duplicate union member `int`
   |
79 | # duplicates of the outer `int`), but not three times (which would indicate that
80 | # we incorrectly re-checked the nested union).
81 | field24: typing.Union[int, typing.Union[int, int]]  # PYI016: Duplicate union member `int`
   |                                         ^^^ PYI016
82 |
83 | # Should emit twice (once for each `int` in the nested union, both of which are
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
78 78 | # Should emit twice (once for each `int` in the nested union, both of which are
79 79 | # duplicates of the outer `int`), but not three times (which would indicate that
80 80 | # we incorrectly re-checked the nested union).
81    |-field24: typing.Union[int, typing.Union[int, int]]  # PYI016: Duplicate union member `int`
   81 |+field24: int  # PYI016: Duplicate union member `int`
82 82 | 
83 83 | # Should emit twice (once for each `int` in the nested union, both of which are
84 84 | # duplicates of the outer `int`), but not three times (which would indicate that

PYI016.py:81:46: PYI016 [*] Duplicate union member `int`
   |
79 | # duplicates of the outer `int`), but not three times (which would indicate that
80 | # we incorrectly re-checked the nested union).
81 | field24: typing.Union[int, typing.Union[int, int]]  # PYI016: Duplicate union member `int`
   |                                              ^^^ PYI016
82 |
83 | # Should emit twice (once for each `int` in the nested union, both of which are
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
78 78 | # Should emit twice (once for each `int` in the nested union, both of which are
79 79 | # duplicates of the outer `int`), but not three times (which would indicate that
80 80 | # we incorrectly re-checked the nested union).
81    |-field24: typing.Union[int, typing.Union[int, int]]  # PYI016: Duplicate union member `int`
   81 |+field24: int  # PYI016: Duplicate union member `int`
82 82 | 
83 83 | # Should emit twice (once for each `int` in the nested union, both of which are
84 84 | # duplicates of the outer `int`), but not three times (which would indicate that

PYI016.py:86:28: PYI016 [*] Duplicate union member `int`
   |
84 | # duplicates of the outer `int`), but not three times (which would indicate that
85 | # we incorrectly re-checked the nested union).
86 | field25: typing.Union[int, int | int]  # PYI016: Duplicate union member `int`
   |                            ^^^ PYI016
87 |
88 | # Should emit in cases with nested `typing.Union`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
83 83 | # Should emit twice (once for each `int` in the nested union, both of which are
84 84 | # duplicates of the outer `int`), but not three times (which would indicate that
85 85 | # we incorrectly re-checked the nested union).
86    |-field25: typing.Union[int, int | int]  # PYI016: Duplicate union member `int`
   86 |+field25: int  # PYI016: Duplicate union member `int`
87 87 | 
88 88 | # Should emit in cases with nested `typing.Union`
89 89 | field26: typing.Union[typing.Union[int, int]]  # PYI016: Duplicate union member `int`

PYI016.py:86:34: PYI016 [*] Duplicate union member `int`
   |
84 | # duplicates of the outer `int`), but not three times (which would indicate that
85 | # we incorrectly re-checked the nested union).
86 | field25: typing.Union[int, int | int]  # PYI016: Duplicate union member `int`
   |                                  ^^^ PYI016
87 |
88 | # Should emit in cases with nested `typing.Union`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
83 83 | # Should emit twice (once for each `int` in the nested union, both of which are
84 84 | # duplicates of the outer `int`), but not three times (which would indicate that
85 85 | # we incorrectly re-checked the nested union).
86    |-field25: typing.Union[int, int | int]  # PYI016: Duplicate union member `int`
   86 |+field25: int  # PYI016: Duplicate union member `int`
87 87 | 
88 88 | # Should emit in cases with nested `typing.Union`
89 89 | field26: typing.Union[typing.Union[int, int]]  # PYI016: Duplicate union member `int`

PYI016.py:89:41: PYI016 [*] Duplicate union member `int`
   |
88 | # Should emit in cases with nested `typing.Union`
89 | field26: typing.Union[typing.Union[int, int]]  # PYI016: Duplicate union member `int`
   |                                         ^^^ PYI016
90 |
91 | # Should emit in cases with nested `typing.Union`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
86 86 | field25: typing.Union[int, int | int]  # PYI016: Duplicate union member `int`
87 87 | 
88 88 | # Should emit in cases with nested `typing.Union`
89    |-field26: typing.Union[typing.Union[int, int]]  # PYI016: Duplicate union member `int`
   89 |+field26: int  # PYI016: Duplicate union member `int`
90 90 | 
91 91 | # Should emit in cases with nested `typing.Union`
92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]]  # PYI016: Duplicate union member `int`

PYI016.py:92:54: PYI016 [*] Duplicate union member `int`
   |
91 | # Should emit in cases with nested `typing.Union`
92 | field27: typing.Union[typing.Union[typing.Union[int, int]]]  # PYI016: Duplicate union member `int`
   |                                                      ^^^ PYI016
93 |
94 | # Should emit in cases with mixed `typing.Union` and `|`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
89 89 | field26: typing.Union[typing.Union[int, int]]  # PYI016: Duplicate union member `int`
90 90 | 
91 91 | # Should emit in cases with nested `typing.Union`
92    |-field27: typing.Union[typing.Union[typing.Union[int, int]]]  # PYI016: Duplicate union member `int`
   92 |+field27: int  # PYI016: Duplicate union member `int`
93 93 | 
94 94 | # Should emit in cases with mixed `typing.Union` and `|`
95 95 | field28: typing.Union[int | int]  # Error

PYI016.py:95:29: PYI016 [*] Duplicate union member `int`
   |
94 | # Should emit in cases with mixed `typing.Union` and `|`
95 | field28: typing.Union[int | int]  # Error
   |                             ^^^ PYI016
96 |
97 | # Should emit twice in cases with multiple nested `typing.Union`
   |
   = help: Remove duplicate union member `int`

ℹ Safe fix
92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]]  # PYI016: Duplicate union member `int`
93 93 | 
94 94 | # Should emit in cases with mixed `typing.Union` and `|`
95    |-field28: typing.Union[int | int]  # Error
   95 |+field28: int  # Error
96 96 | 
97 97 | # Should emit twice in cases with multiple nested `typing.Union`
98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]]  # Error

PYI016.py:98:54: PYI016 [*] Duplicate union member `int`
    |
 97 | # Should emit twice in cases with multiple nested `typing.Union`
 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]]  # Error
    |                                                      ^^^ PYI016
 99 |
100 | # Should emit once in cases with multiple nested `typing.Union`
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
95 95 | field28: typing.Union[int | int]  # Error
96 96 | 
97 97 | # Should emit twice in cases with multiple nested `typing.Union`
98    |-field29: typing.Union[int, typing.Union[typing.Union[int, int]]]  # Error
   98 |+field29: int  # Error
99 99 | 
100 100 | # Should emit once in cases with multiple nested `typing.Union`
101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]]  # Error

PYI016.py:98:59: PYI016 [*] Duplicate union member `int`
    |
 97 | # Should emit twice in cases with multiple nested `typing.Union`
 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]]  # Error
    |                                                           ^^^ PYI016
 99 |
100 | # Should emit once in cases with multiple nested `typing.Union`
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
95 95 | field28: typing.Union[int | int]  # Error
96 96 | 
97 97 | # Should emit twice in cases with multiple nested `typing.Union`
98    |-field29: typing.Union[int, typing.Union[typing.Union[int, int]]]  # Error
   98 |+field29: int  # Error
99 99 | 
100 100 | # Should emit once in cases with multiple nested `typing.Union`
101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]]  # Error

PYI016.py:101:54: PYI016 [*] Duplicate union member `int`
    |
100 | # Should emit once in cases with multiple nested `typing.Union`
101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]]  # Error
    |                                                      ^^^ PYI016
102 |
103 | # Should emit once, and fix to `typing.Union[float, int]`
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
98  98  | field29: typing.Union[int, typing.Union[typing.Union[int, int]]]  # Error
99  99  | 
100 100 | # Should emit once in cases with multiple nested `typing.Union`
101     |-field30: typing.Union[int, typing.Union[typing.Union[int, str]]]  # Error
    101 |+field30: typing.Union[int, str]  # Error
102 102 | 
103 103 | # Should emit once, and fix to `typing.Union[float, int]`
104 104 | field31: typing.Union[float, typing.Union[int | int]]  # Error

PYI016.py:104:49: PYI016 [*] Duplicate union member `int`
    |
103 | # Should emit once, and fix to `typing.Union[float, int]`
104 | field31: typing.Union[float, typing.Union[int | int]]  # Error
    |                                                 ^^^ PYI016
105 |
106 | # Should emit once, and fix to `typing.Union[float, int]`
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]]  # Error
102 102 | 
103 103 | # Should emit once, and fix to `typing.Union[float, int]`
104     |-field31: typing.Union[float, typing.Union[int | int]]  # Error
    104 |+field31: float | int  # Error
105 105 | 
106 106 | # Should emit once, and fix to `typing.Union[float, int]`
107 107 | field32: typing.Union[float, typing.Union[int | int | int]]  # Error

PYI016.py:107:49: PYI016 [*] Duplicate union member `int`
    |
106 | # Should emit once, and fix to `typing.Union[float, int]`
107 | field32: typing.Union[float, typing.Union[int | int | int]]  # Error
    |                                                 ^^^ PYI016
108 |
109 | # Test case for mixed union type fix
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
104 104 | field31: typing.Union[float, typing.Union[int | int]]  # Error
105 105 | 
106 106 | # Should emit once, and fix to `typing.Union[float, int]`
107     |-field32: typing.Union[float, typing.Union[int | int | int]]  # Error
    107 |+field32: float | int  # Error
108 108 | 
109 109 | # Test case for mixed union type fix
110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error

PYI016.py:107:55: PYI016 [*] Duplicate union member `int`
    |
106 | # Should emit once, and fix to `typing.Union[float, int]`
107 | field32: typing.Union[float, typing.Union[int | int | int]]  # Error
    |                                                       ^^^ PYI016
108 |
109 | # Test case for mixed union type fix
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
104 104 | field31: typing.Union[float, typing.Union[int | int]]  # Error
105 105 | 
106 106 | # Should emit once, and fix to `typing.Union[float, int]`
107     |-field32: typing.Union[float, typing.Union[int | int | int]]  # Error
    107 |+field32: float | int  # Error
108 108 | 
109 109 | # Test case for mixed union type fix
110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error

PYI016.py:110:42: PYI016 [*] Duplicate union member `int`
    |
109 | # Test case for mixed union type fix
110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error
    |                                          ^^^ PYI016
111 |
112 | # Test case for mixed union type
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
107 107 | field32: typing.Union[float, typing.Union[int | int | int]]  # Error
108 108 | 
109 109 | # Test case for mixed union type fix
110     |-field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error
    110 |+field33: int # Error
111 111 | 
112 112 | # Test case for mixed union type
113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]]  # Error

PYI016.py:110:62: PYI016 [*] Duplicate union member `int`
    |
109 | # Test case for mixed union type fix
110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error
    |                                                              ^^^ PYI016
111 |
112 | # Test case for mixed union type
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
107 107 | field32: typing.Union[float, typing.Union[int | int | int]]  # Error
108 108 | 
109 109 | # Test case for mixed union type fix
110     |-field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error
    110 |+field33: int # Error
111 111 | 
112 112 | # Test case for mixed union type
113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]]  # Error

PYI016.py:110:68: PYI016 [*] Duplicate union member `int`
    |
109 | # Test case for mixed union type fix
110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error
    |                                                                    ^^^ PYI016
111 |
112 | # Test case for mixed union type
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
107 107 | field32: typing.Union[float, typing.Union[int | int | int]]  # Error
108 108 | 
109 109 | # Test case for mixed union type fix
110     |-field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error
    110 |+field33: int # Error
111 111 | 
112 112 | # Test case for mixed union type
113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]]  # Error

PYI016.py:113:61: PYI016 [*] Duplicate union member `list[int]`
    |
112 | # Test case for mixed union type
113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]]  # Error
    |                                                             ^^^^^^^^^ PYI016
114 |
115 | field35: "int | str | int"  # Error
    |
    = help: Remove duplicate union member `list[int]`

ℹ Safe fix
110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error
111 111 | 
112 112 | # Test case for mixed union type
113     |-field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]]  # Error
    113 |+field34: typing.Union[list[int], str, bytes]  # Error
114 114 | 
115 115 | field35: "int | str | int"  # Error
116 116 | 

PYI016.py:115:23: PYI016 [*] Duplicate union member `int`
    |
113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]]  # Error
114 |
115 | field35: "int | str | int"  # Error
    |                       ^^^ PYI016
    |
    = help: Remove duplicate union member `int`

ℹ Safe fix
112 112 | # Test case for mixed union type
113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]]  # Error
114 114 | 
115     |-field35: "int | str | int"  # Error
    115 |+field35: "int | str"  # Error
116 116 | 
117 117 | 
118 118 | 

PYI016.py:134:45: PYI016 [*] Duplicate union member `typing.Optional[int]`
    |
132 | field40: typing.Union[typing.Optional[int], None]
133 | field41: typing.Optional[typing.Union[int, None]]
134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]]
    |                                             ^^^^^^^^^^^^^^^^^^^^ PYI016
135 | field43: typing.Optional[int] | None
136 | field44: typing.Optional[int | None]
    |
    = help: Remove duplicate union member `typing.Optional[int]`

ℹ Safe fix
131 131 | # equivalent to int | None
132 132 | field40: typing.Union[typing.Optional[int], None]
133 133 | field41: typing.Optional[typing.Union[int, None]]
134     |-field42: typing.Union[typing.Optional[int], typing.Optional[int]]
    134 |+field42: typing.Optional[int]
135 135 | field43: typing.Optional[int] | None
136 136 | field44: typing.Optional[int | None]
137 137 | field45: typing.Optional[int] | typing.Optional[int]

PYI016.py:137:33: PYI016 [*] Duplicate union member `typing.Optional[int]`
    |
135 | field43: typing.Optional[int] | None
136 | field44: typing.Optional[int | None]
137 | field45: typing.Optional[int] | typing.Optional[int]
    |                                 ^^^^^^^^^^^^^^^^^^^^ PYI016
138 | # equivalent to int | dict | None
139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]]
    |
    = help: Remove duplicate union member `typing.Optional[int]`

ℹ Safe fix
134 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]]
135 135 | field43: typing.Optional[int] | None
136 136 | field44: typing.Optional[int | None]
137     |-field45: typing.Optional[int] | typing.Optional[int]
    137 |+field45: typing.Optional[int]
138 138 | # equivalent to int | dict | None
139 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]]
140 140 | field47: typing.Optional[int] | typing.Optional[dict]

PYI016.py:143:61: PYI016 [*] Duplicate union member `complex`
    |
142 | # avoid reporting twice
143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex]
    |                                                             ^^^^^^^ PYI016
144 | field49: typing.Optional[complex | complex] | complex
    |
    = help: Remove duplicate union member `complex`

ℹ Safe fix
140 140 | field47: typing.Optional[int] | typing.Optional[dict]
141 141 | 
142 142 | # avoid reporting twice
143     |-field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex]
    143 |+field48: typing.Union[typing.Optional[complex], complex]
144 144 | field49: typing.Optional[complex | complex] | complex

PYI016.py:144:36: PYI016 [*] Duplicate union member `complex`
    |
142 | # avoid reporting twice
143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex]
144 | field49: typing.Optional[complex | complex] | complex
    |                                    ^^^^^^^ PYI016
    |
    = help: Remove duplicate union member `complex`

ℹ Safe fix
141 141 | 
142 142 | # avoid reporting twice
143 143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex]
144     |-field49: typing.Optional[complex | complex] | complex
    144 |+field49: typing.Optional[complex] | complex
