---
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.pyi: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.pyi: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.pyi: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[Union[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.pyi: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[Union[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[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.pyi:8:4
   |
 6 | u: builtins.type[int] | type[str] | builtins.type[complex]
 7 | v: Union[type[float], type[complex]]
 8 | w: Union[type[Union[float, int]], type[complex]]
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 9 | x: Union[Union[type[Union[float, int]], type[complex]]]
10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]]
   |
help: Combine multiple `type` members
  |
7 | v: Union[type[float], type[complex]]
  - w: Union[type[Union[float, int]], type[complex]]
8 + w: type[Union[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.pyi:9:4
   |
 7 | v: Union[type[float], type[complex]]
 8 | w: Union[type[Union[float, int]], type[complex]]
 9 | x: Union[Union[type[Union[float, int]], type[complex]]]
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]]
11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]]
   |
help: Combine multiple `type` members
   |
8  | w: Union[type[Union[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[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.pyi:10:4
   |
 8 | w: Union[type[Union[float, int]], type[complex]]
 9 | x: Union[Union[type[Union[float, int]], type[complex]]]
10 | y: Union[Union[Union[type[Union[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[Union[float, int]], type[complex]]]]
10 + y: type[Union[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.pyi:11:4
   |
 9 | x: Union[Union[type[Union[float, int]], type[complex]]]
10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]]
11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]]
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 |
13 | def func(arg: type[int] | str | type[float]) -> None: ...
   |
help: Combine multiple `type` members
   |
10 | y: Union[Union[Union[type[Union[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.pyi:13:15
   |
11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]]
12 |
13 | def func(arg: type[int] | str | type[float]) -> None: ...
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14 |
15 | # OK
   |
help: Combine multiple `type` members
   |
12 |
   - def func(arg: type[int] | str | type[float]) -> None: ...
13 + def func(arg: type[int | float] | str) -> None: ...
14 |
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`.
  --> PYI055.pyi:23:7
   |
22 | # PYI055
23 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24 |
25 | def func():
   |
help: Combine multiple `type` members
   |
22 | # PYI055
   - item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker
23 + item: type[requests_mock.Mocker | httpretty] = requests_mock.Mocker
24 |
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty | str]`.
  --> PYI055.pyi:27:11
   |
25 | def func():
26 |     # PYI055
27 |     item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28 |     item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
29 |     item3: Union[  # comment
   |
help: Combine multiple `type` members
   |
26 |     # PYI055
   -     item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
27 +     item: type[requests_mock.Mocker | httpretty | str] = requests_mock.Mocker
28 |     item2: 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.pyi:28:12
   |
26 |     # PYI055
27 |     item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
28 |     item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29 |     item3: Union[  # comment
30 |         type[requests_mock.Mocker], # another comment
   |
help: Combine multiple `type` members
   |
27 |     item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
   -     item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
28 +     item2: type[Union[requests_mock.Mocker, httpretty, str]] = requests_mock.Mocker
29 |     item3: Union[  # comment
   |

PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`.
  --> PYI055.pyi:29:12
   |
27 |       item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker
28 |       item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
29 |       item3: Union[  # comment
   |  ____________^
30 | |         type[requests_mock.Mocker], # another comment
31 | |         type[httpretty], type[str]] = requests_mock.Mocker
   | |___________________________________^
   |
help: Combine multiple `type` members
   |
28 |     item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker
   -     item3: Union[  # comment
   -         type[requests_mock.Mocker], # another comment
   -         type[httpretty], type[str]] = requests_mock.Mocker
29 +     item3: type[Union[requests_mock.Mocker, httpretty, str]] = requests_mock.Mocker
30 |
   |
note: This is an unsafe fix and may change runtime behavior
