---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---
RUF020 [*] `Union[Never, T]` is equivalent to `T`
 --> RUF020.py:3:7
  |
1 | from typing import Never, NoReturn, Union
2 |
3 | Union[Never, int]
  |       ^^^^^
4 | Union[NoReturn, int]
5 | Never | int
  |
help: Remove `Never`
  |
2 |
  - Union[Never, int]
3 + int
4 | Union[NoReturn, int]
  |

RUF020 [*] `Union[NoReturn, T]` is equivalent to `T`
 --> RUF020.py:4:7
  |
3 | Union[Never, int]
4 | Union[NoReturn, int]
  |       ^^^^^^^^
5 | Never | int
6 | NoReturn | int
  |
help: Remove `NoReturn`
  |
3 | Union[Never, int]
  - Union[NoReturn, int]
4 + int
5 | Never | int
  |

RUF020 [*] `Never | T` is equivalent to `T`
 --> RUF020.py:5:1
  |
3 | Union[Never, int]
4 | Union[NoReturn, int]
5 | Never | int
  | ^^^^^
6 | NoReturn | int
7 | Union[Union[Never, int], Union[NoReturn, int]]
  |
help: Remove `Never`
  |
4 | Union[NoReturn, int]
  - Never | int
5 + int
6 | NoReturn | int
  |

RUF020 [*] `NoReturn | T` is equivalent to `T`
 --> RUF020.py:6:1
  |
4 | Union[NoReturn, int]
5 | Never | int
6 | NoReturn | int
  | ^^^^^^^^
7 | Union[Union[Never, int], Union[NoReturn, int]]
8 | Union[NoReturn, int, float]
  |
help: Remove `NoReturn`
  |
5 | Never | int
  - NoReturn | int
6 + int
7 | Union[Union[Never, int], Union[NoReturn, int]]
  |

RUF020 [*] `Union[Never, T]` is equivalent to `T`
 --> RUF020.py:7:13
  |
5 | Never | int
6 | NoReturn | int
7 | Union[Union[Never, int], Union[NoReturn, int]]
  |             ^^^^^
8 | Union[NoReturn, int, float]
  |
help: Remove `Never`
  |
6 | NoReturn | int
  - Union[Union[Never, int], Union[NoReturn, int]]
7 + Union[int, Union[NoReturn, int]]
8 | Union[NoReturn, int, float]
  |

RUF020 [*] `Union[NoReturn, T]` is equivalent to `T`
 --> RUF020.py:7:32
  |
5 | Never | int
6 | NoReturn | int
7 | Union[Union[Never, int], Union[NoReturn, int]]
  |                                ^^^^^^^^
8 | Union[NoReturn, int, float]
  |
help: Remove `NoReturn`
  |
6 | NoReturn | int
  - Union[Union[Never, int], Union[NoReturn, int]]
7 + Union[Union[Never, int], int]
8 | Union[NoReturn, int, float]
  |

RUF020 [*] `Union[NoReturn, T]` is equivalent to `T`
 --> RUF020.py:8:7
  |
6 | NoReturn | int
7 | Union[Union[Never, int], Union[NoReturn, int]]
8 | Union[NoReturn, int, float]
  |       ^^^^^^^^
  |
help: Remove `NoReturn`
  |
7 | Union[Union[Never, int], Union[NoReturn, int]]
  - Union[NoReturn, int, float]
8 + Union[int, float]
9 |
  |

RUF020 `Never | T` is equivalent to `T`
  --> RUF020.py:12:11
   |
11 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567
12 | x: None | Never | None
   |           ^^^^^
13 | y: (None | Never) | None
14 | z: None | (Never | None)
   |
help: Remove `Never`

RUF020 `Never | T` is equivalent to `T`
  --> RUF020.py:13:12
   |
11 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567
12 | x: None | Never | None
13 | y: (None | Never) | None
   |            ^^^^^
14 | z: None | (Never | None)
   |
help: Remove `Never`

RUF020 `Never | T` is equivalent to `T`
  --> RUF020.py:14:12
   |
12 | x: None | Never | None
13 | y: (None | Never) | None
14 | z: None | (Never | None)
   |            ^^^^^
15 |
16 | a: int | Never | None
   |
help: Remove `Never`

RUF020 `Never | T` is equivalent to `T`
  --> RUF020.py:16:10
   |
14 | z: None | (Never | None)
15 |
16 | a: int | Never | None
   |          ^^^^^
17 | b: Never | Never | None
   |
help: Remove `Never`

RUF020 `Never | T` is equivalent to `T`
  --> RUF020.py:17:4
   |
16 | a: int | Never | None
17 | b: Never | Never | None
   |    ^^^^^
   |
help: Remove `Never`

RUF020 `Never | T` is equivalent to `T`
  --> RUF020.py:17:12
   |
16 | a: int | Never | None
17 | b: Never | Never | None
   |            ^^^^^
   |
help: Remove `Never`

RUF020 [*] `Never | T` is equivalent to `T`
  --> RUF020.py:21:9
   |
20 | def func() -> (
21 |         Never  # text
   |         ^^^^^
22 |         | # text
23 |         int
   |
help: Remove `Never`
   |
20 | def func() -> (
   -         Never  # text
   -         | # text
21 |         int
   |
note: This is an unsafe fix and may change runtime behavior

RUF020 [*] `Union[Never, T]` is equivalent to `T`
  --> RUF020.py:32:5
   |
31 | x: Union[
32 |     Never,
   |     ^^^^^
33 |     Literal["LongLiteralNumberOne"]
34 |     | Literal["LongLiteralNumberTwo"]
   |
help: Remove `Never`
   |
30 |
   - x: Union[
   -     Never,
   -     Literal["LongLiteralNumberOne"]
31 + x: (Literal["LongLiteralNumberOne"]
32 |     | Literal["LongLiteralNumberTwo"]
   -     | Literal["LongLiteralNumberThree"]
   - ]
33 +     | Literal["LongLiteralNumberThree"])
   |
