---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI051.py:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str`
  |
2 | from typing import Literal, TypeAlias, Union
3 | 
4 | A: str | Literal["foo"]
  |                  ^^^^^ PYI051
5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str]
6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]]
  |

PYI051.py:5:37: PYI051 `Literal[b"bar"]` is redundant in a union with `bytes`
  |
4 | A: str | Literal["foo"]
5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str]
  |                                     ^^^^^^ PYI051
6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]]
7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int]
  |

PYI051.py:5:45: PYI051 `Literal[b"foo"]` is redundant in a union with `bytes`
  |
4 | A: str | Literal["foo"]
5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str]
  |                                             ^^^^^^ PYI051
6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]]
7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int]
  |

PYI051.py:6:37: PYI051 `Literal[5]` is redundant in a union with `int`
  |
4 | A: str | Literal["foo"]
5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str]
6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]]
  |                                     ^ PYI051
7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int]
  |

PYI051.py:6:67: PYI051 `Literal["foo"]` is redundant in a union with `str`
  |
4 | A: str | Literal["foo"]
5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str]
6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]]
  |                                                                   ^^^^^ PYI051
7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int]
  |

PYI051.py:7:37: PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes`
  |
5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str]
6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]]
7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int]
  |                                     ^^^^^^^^^^^^ PYI051
8 | 
9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ...
  |

PYI051.py:7:51: PYI051 `Literal[42]` is redundant in a union with `int`
  |
5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str]
6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]]
7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int]
  |                                                   ^^ PYI051
8 | 
9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ...
  |

PYI051.py:9:31: PYI051 `Literal[1J]` is redundant in a union with `complex`
   |
 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int]
 8 | 
 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ...
   |                               ^^ PYI051
10 | 
11 | # OK
   |

PYI051.py:9:53: PYI051 `Literal[3.14]` is redundant in a union with `float`
   |
 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int]
 8 | 
 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ...
   |                                                     ^^^^ PYI051
10 | 
11 | # OK
   |


