---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`.
 --> PYI055.py:4:4
  |
2 | from typing import Union
3 |
4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex]
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 | t: type[int] | type[str] | type[float]
6 | u: builtins.type[int] | type[str] | builtins.type[complex]
  |
help: Combine multiple `type` members
  |
3 |
  - s: builtins.type[int] | builtins.type[str] | builtins.type[complex]
4 + s: type[int | str | complex]
5 | t: type[int] | type[str] | type[float]
  |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | float]`.
 --> PYI055.py:5:4
  |
4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex]
5 | t: type[int] | type[str] | type[float]
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 | u: builtins.type[int] | type[str] | builtins.type[complex]
7 | v: Union[type[float], type[complex]]
  |
help: Combine multiple `type` members
  |
4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex]
  - t: type[int] | type[str] | type[float]
5 + t: type[int | str | float]
6 | u: builtins.type[int] | type[str] | builtins.type[complex]
  |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`.
 --> PYI055.py:6:4
  |
4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex]
5 | t: type[int] | type[str] | type[float]
6 | u: builtins.type[int] | type[str] | builtins.type[complex]
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 | v: Union[type[float], type[complex]]
8 | w: Union[type[float | int], type[complex]]
  |
help: Combine multiple `type` members
  |
5 | t: type[int] | type[str] | type[float]
  - u: builtins.type[int] | type[str] | builtins.type[complex]
6 + u: type[int | str | complex]
7 | v: Union[type[float], type[complex]]
  |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float, complex]]`.
 --> PYI055.py:7:4
  |
5 | t: type[int] | type[str] | type[float]
6 | u: builtins.type[int] | type[str] | builtins.type[complex]
7 | v: Union[type[float], type[complex]]
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 | w: Union[type[float | int], type[complex]]
9 | x: Union[Union[type[Union[float, int]], type[complex]]]
  |
help: Combine multiple `type` members
  |
6 | u: builtins.type[int] | type[str] | builtins.type[complex]
  - v: Union[type[float], type[complex]]
7 + v: type[Union[float, complex]]
8 | w: Union[type[float | int], type[complex]]
  |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float | int, complex]]`.
  --> PYI055.py:8:4
   |
 6 | u: builtins.type[int] | type[str] | builtins.type[complex]
 7 | v: Union[type[float], type[complex]]
 8 | w: Union[type[float | int], type[complex]]
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 9 | x: Union[Union[type[Union[float, int]], type[complex]]]
10 | y: Union[Union[Union[type[float | int], type[complex]]]]
   |
help: Combine multiple `type` members
  |
7 | v: Union[type[float], type[complex]]
  - w: Union[type[float | int], type[complex]]
8 + w: type[Union[float | int, complex]]
9 | x: Union[Union[type[Union[float, int]], type[complex]]]
  |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[Union[float, int], complex]]`.
  --> PYI055.py:9:4
   |
 7 | v: Union[type[float], type[complex]]
 8 | w: Union[type[float | int], type[complex]]
 9 | x: Union[Union[type[Union[float, int]], type[complex]]]
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 | y: Union[Union[Union[type[float | int], type[complex]]]]
11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]]
   |
help: Combine multiple `type` members
   |
8  | w: Union[type[float | int], type[complex]]
   - x: Union[Union[type[Union[float, int]], type[complex]]]
9  + x: type[Union[Union[float, int], complex]]
10 | y: Union[Union[Union[type[float | int], type[complex]]]]
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float | int, complex]]`.
  --> PYI055.py:10:4
   |
 8 | w: Union[type[float | int], type[complex]]
 9 | x: Union[Union[type[Union[float, int]], type[complex]]]
10 | y: Union[Union[Union[type[float | int], type[complex]]]]
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]]
   |
help: Combine multiple `type` members
   |
9  | x: Union[Union[type[Union[float, int]], type[complex]]]
   - y: Union[Union[Union[type[float | int], type[complex]]]]
10 + y: type[Union[float | int, complex]]
11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]]
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[complex, Union[float, int]]]`.
  --> PYI055.py:11:4
   |
 9 | x: Union[Union[type[Union[float, int]], type[complex]]]
10 | y: Union[Union[Union[type[float | int], type[complex]]]]
11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]]
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Combine multiple `type` members
   |
10 | y: Union[Union[Union[type[float | int], type[complex]]]]
   - z: Union[type[complex], Union[Union[type[Union[float, int]]]]]
11 + z: type[Union[complex, Union[float, int]]]
12 |
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | float]`.
  --> PYI055.py:14:15
   |
14 | def func(arg: type[int] | str | type[float]) -> None:
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 |     ...
   |
help: Combine multiple `type` members
   |
13 |
   - def func(arg: type[int] | str | type[float]) -> None:
14 + def func(arg: type[int | float] | str) -> None:
15 |     ...
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`.
  --> PYI055.py:29:7
   |
28 | # OK
29 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Combine multiple `type` members
   |
28 | # OK
   - item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker
29 + item: type[requests_mock.Mocker | httpretty] = requests_mock.Mocker
30 |
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty | str]`.
  --> PYI055.py:34:8
   |
32 | def func():
33 |     # PYI055
34 |     x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35 |     y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
36 |     z: Union[  # comment
   |
help: Combine multiple `type` members
   |
33 |     # PYI055
   -     x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
34 +     x: type[requests_mock.Mocker | httpretty | str] = requests_mock.Mocker
35 |     y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`.
  --> PYI055.py:35:8
   |
33 |     # PYI055
34 |     x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
35 |     y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36 |     z: Union[  # comment
37 |         type[requests_mock.Mocker], # another comment
   |
help: Combine multiple `type` members
   |
34 |     x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
   -     y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
35 +     y: type[Union[requests_mock.Mocker, httpretty, str]] = requests_mock.Mocker
36 |     z: Union[  # comment
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`.
  --> PYI055.py:36:8
   |
34 |       x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
35 |       y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
36 |       z: Union[  # comment
   |  ________^
37 | |         type[requests_mock.Mocker], # another comment
38 | |         type[httpretty], type[str]] = requests_mock.Mocker
   | |___________________________________^
   |
help: Combine multiple `type` members
   |
35 |     y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
   -     z: Union[  # comment
   -         type[requests_mock.Mocker], # another comment
   -         type[httpretty], type[str]] = requests_mock.Mocker
36 +     z: type[Union[requests_mock.Mocker, httpretty, str]] = requests_mock.Mocker
37 |
   |
note: This is an unsafe fix and may change runtime behavior

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`.
  --> PYI055.py:45:8
   |
44 |     # PYI055
45 |     x: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Combine multiple `type` members
   |
44 |     # PYI055
   -     x: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
45 +     x: type[Union[requests_mock.Mocker, httpretty, str]] = requests_mock.Mocker
46 |
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`.
  --> PYI055.py:50:9
   |
48 | def convert_union(union: UnionType) -> _T | None:
49 |     converters: tuple[
50 |         type[_T] | type[Converter[_T]] | Converter[_T] | Callable[[str], _T], ...  # PYI055
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51 |     ] = union.__args__
52 |     ...
   |
help: Combine multiple `type` members
   |
49 |     converters: tuple[
   -         type[_T] | type[Converter[_T]] | Converter[_T] | Callable[[str], _T], ...  # PYI055
50 +         type[_T | Converter[_T]] | Converter[_T] | Callable[[str], _T], ...  # PYI055
51 |     ] = union.__args__
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`.
  --> PYI055.py:56:9
   |
54 | def convert_union(union: UnionType) -> _T | None:
55 |     converters: tuple[
56 |         Union[type[_T] | type[Converter[_T]] | Converter[_T] | Callable[[str], _T]], ...  # PYI055
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57 |     ] = union.__args__
58 |     ...
   |
help: Combine multiple `type` members
   |
55 |     converters: tuple[
   -         Union[type[_T] | type[Converter[_T]] | Converter[_T] | Callable[[str], _T]], ...  # PYI055
56 +         type[_T | Converter[_T]] | Converter[_T] | Callable[[str], _T], ...  # PYI055
57 |     ] = union.__args__
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`.
  --> PYI055.py:62:9
   |
60 | def convert_union(union: UnionType) -> _T | None:
61 |     converters: tuple[
62 |         Union[type[_T] | type[Converter[_T]]] | Converter[_T] | Callable[[str], _T], ...  # PYI055
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63 |     ] = union.__args__
64 |     ...
   |
help: Combine multiple `type` members
   |
61 |     converters: tuple[
   -         Union[type[_T] | type[Converter[_T]]] | Converter[_T] | Callable[[str], _T], ...  # PYI055
62 +         type[_T | Converter[_T]] | Converter[_T] | Callable[[str], _T], ...  # PYI055
63 |     ] = union.__args__
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`.
  --> PYI055.py:68:9
   |
66 | def convert_union(union: UnionType) -> _T | None:
67 |     converters: tuple[
68 |         Union[type[_T] | type[Converter[_T]] | str] | Converter[_T] | Callable[[str], _T], ...  # PYI055
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69 |     ] = union.__args__
70 |     ...
   |
help: Combine multiple `type` members
   |
67 |     converters: tuple[
   -         Union[type[_T] | type[Converter[_T]] | str] | Converter[_T] | Callable[[str], _T], ...  # PYI055
68 +         type[_T | Converter[_T]] | str | Converter[_T] | Callable[[str], _T], ...  # PYI055
69 |     ] = union.__args__
   |
