---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI062 [*] Duplicate literal member `True`
 --> PYI062.pyi:5:25
  |
3 | import typing_extensions
4 |
5 | x: Literal[True, False, True, False]  # PYI062 twice here
  |                         ^^^^
6 |
7 | y: Literal[1, print("hello"), 3, Literal[4, 1]]  # PYI062 on the last 1
  |
help: Remove duplicates
  |
4 |
  - x: Literal[True, False, True, False]  # PYI062 twice here
5 + x: Literal[True, False]  # PYI062 twice here
6 |
  |

PYI062 [*] Duplicate literal member `False`
 --> PYI062.pyi:5:31
  |
3 | import typing_extensions
4 |
5 | x: Literal[True, False, True, False]  # PYI062 twice here
  |                               ^^^^^
6 |
7 | y: Literal[1, print("hello"), 3, Literal[4, 1]]  # PYI062 on the last 1
  |
help: Remove duplicates
  |
4 |
  - x: Literal[True, False, True, False]  # PYI062 twice here
5 + x: Literal[True, False]  # PYI062 twice here
6 |
  |

PYI062 [*] Duplicate literal member `1`
 --> PYI062.pyi:7:45
  |
5 | x: Literal[True, False, True, False]  # PYI062 twice here
6 |
7 | y: Literal[1, print("hello"), 3, Literal[4, 1]]  # PYI062 on the last 1
  |                                             ^
8 |
9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
  |
help: Remove duplicates
  |
6 |
  - y: Literal[1, print("hello"), 3, Literal[4, 1]]  # PYI062 on the last 1
7 + y: Literal[1, print("hello"), 3, 4]  # PYI062 on the last 1
8 |
  |

PYI062 [*] Duplicate literal member `{1, 3, 5}`
  --> PYI062.pyi:9:33
   |
 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]]  # PYI062 on the last 1
 8 |
 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
   |                                 ^^^^^^^
10 |
11 | Literal[1, Literal[1]]  # once
   |
help: Remove duplicates
   |
8  |
   - z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
9  + z: Literal[{1, 3, 5}, "foobar"]  # PYI062 on the set literal
10 |
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:11:20
   |
 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
10 |
11 | Literal[1, Literal[1]]  # once
   |                    ^
12 | Literal[1, 2, Literal[1, 2]]  # twice
13 | Literal[1, Literal[1], Literal[1]]  # twice
   |
help: Remove duplicates
   |
10 |
   - Literal[1, Literal[1]]  # once
11 + Literal[1]  # once
12 | Literal[1, 2, Literal[1, 2]]  # twice
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:12:23
   |
11 | Literal[1, Literal[1]]  # once
12 | Literal[1, 2, Literal[1, 2]]  # twice
   |                       ^
13 | Literal[1, Literal[1], Literal[1]]  # twice
14 | Literal[1, Literal[2], Literal[2]]  # once
   |
help: Remove duplicates
   |
11 | Literal[1, Literal[1]]  # once
   - Literal[1, 2, Literal[1, 2]]  # twice
12 + Literal[1, 2]  # twice
13 | Literal[1, Literal[1], Literal[1]]  # twice
   |

PYI062 [*] Duplicate literal member `2`
  --> PYI062.pyi:12:26
   |
11 | Literal[1, Literal[1]]  # once
12 | Literal[1, 2, Literal[1, 2]]  # twice
   |                          ^
13 | Literal[1, Literal[1], Literal[1]]  # twice
14 | Literal[1, Literal[2], Literal[2]]  # once
   |
help: Remove duplicates
   |
11 | Literal[1, Literal[1]]  # once
   - Literal[1, 2, Literal[1, 2]]  # twice
12 + Literal[1, 2]  # twice
13 | Literal[1, Literal[1], Literal[1]]  # twice
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:13:20
   |
11 | Literal[1, Literal[1]]  # once
12 | Literal[1, 2, Literal[1, 2]]  # twice
13 | Literal[1, Literal[1], Literal[1]]  # twice
   |                    ^
14 | Literal[1, Literal[2], Literal[2]]  # once
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
   |
help: Remove duplicates
   |
12 | Literal[1, 2, Literal[1, 2]]  # twice
   - Literal[1, Literal[1], Literal[1]]  # twice
13 + Literal[1]  # twice
14 | Literal[1, Literal[2], Literal[2]]  # once
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:13:32
   |
11 | Literal[1, Literal[1]]  # once
12 | Literal[1, 2, Literal[1, 2]]  # twice
13 | Literal[1, Literal[1], Literal[1]]  # twice
   |                                ^
14 | Literal[1, Literal[2], Literal[2]]  # once
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
   |
help: Remove duplicates
   |
12 | Literal[1, 2, Literal[1, 2]]  # twice
   - Literal[1, Literal[1], Literal[1]]  # twice
13 + Literal[1]  # twice
14 | Literal[1, Literal[2], Literal[2]]  # once
   |

PYI062 [*] Duplicate literal member `2`
  --> PYI062.pyi:14:32
   |
12 | Literal[1, 2, Literal[1, 2]]  # twice
13 | Literal[1, Literal[1], Literal[1]]  # twice
14 | Literal[1, Literal[2], Literal[2]]  # once
   |                                ^
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16 | typing_extensions.Literal[1, 1, 1]  # twice
   |
help: Remove duplicates
   |
13 | Literal[1, Literal[1], Literal[1]]  # twice
   - Literal[1, Literal[2], Literal[2]]  # once
14 + Literal[1, 2]  # once
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:15:37
   |
13 | Literal[1, Literal[1], Literal[1]]  # twice
14 | Literal[1, Literal[2], Literal[2]]  # once
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
   |                                     ^
16 | typing_extensions.Literal[1, 1, 1]  # twice
17 | Literal[
   |
help: Remove duplicates
   |
14 | Literal[1, Literal[2], Literal[2]]  # once
   - t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
15 + t.Literal[1, 2]  # once
16 | typing_extensions.Literal[1, 1, 1]  # twice
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:16:30
   |
14 | Literal[1, Literal[2], Literal[2]]  # once
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16 | typing_extensions.Literal[1, 1, 1]  # twice
   |                              ^
17 | Literal[
18 |     1, # comment
   |
help: Remove duplicates
   |
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
   - typing_extensions.Literal[1, 1, 1]  # twice
16 + typing_extensions.Literal[1]  # twice
17 | Literal[
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:16:33
   |
14 | Literal[1, Literal[2], Literal[2]]  # once
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16 | typing_extensions.Literal[1, 1, 1]  # twice
   |                                 ^
17 | Literal[
18 |     1, # comment
   |
help: Remove duplicates
   |
15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
   - typing_extensions.Literal[1, 1, 1]  # twice
16 + typing_extensions.Literal[1]  # twice
17 | Literal[
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:20:9
   |
18 |     1, # comment
19 |     Literal[ # another comment
20 |         1
   |         ^
21 |     ]
22 | ]  # once
   |
help: Remove duplicates
   |
16 | typing_extensions.Literal[1, 1, 1]  # twice
   - Literal[
   -     1, # comment
   -     Literal[ # another comment
   -         1
   -     ]
   - ]  # once
17 + Literal[1]  # once
18 |
   |
note: This is an unsafe fix and may change runtime behavior

PYI062 [*] Duplicate literal member `True`
  --> PYI062.pyi:25:46
   |
24 | # Ensure issue is only raised once, even on nested literals
25 | MyType = Literal["foo", Literal[True, False, True], "bar"]  # PYI062
   |                                              ^^^^
26 |
27 | n: Literal["No", "duplicates", "here", 1, "1"]
   |
help: Remove duplicates
   |
24 | # Ensure issue is only raised once, even on nested literals
   - MyType = Literal["foo", Literal[True, False, True], "bar"]  # PYI062
25 + MyType = Literal["foo", True, False, "bar"]  # PYI062
26 |
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:32:37
   |
30 | # nested literals, all equivalent to `Literal[1]`
31 | Literal[Literal[1]]  # no duplicate
32 | Literal[Literal[Literal[1], Literal[1]]]  # once
   |                                     ^
33 | Literal[Literal[1], Literal[Literal[Literal[1]]]]  # once
   |
help: Remove duplicates
   |
31 | Literal[Literal[1]]  # no duplicate
   - Literal[Literal[Literal[1], Literal[1]]]  # once
32 + Literal[1]  # once
33 | Literal[Literal[1], Literal[Literal[Literal[1]]]]  # once
   |

PYI062 [*] Duplicate literal member `1`
  --> PYI062.pyi:33:45
   |
31 | Literal[Literal[1]]  # no duplicate
32 | Literal[Literal[Literal[1], Literal[1]]]  # once
33 | Literal[Literal[1], Literal[Literal[Literal[1]]]]  # once
   |                                             ^
   |
help: Remove duplicates
   |
32 | Literal[Literal[Literal[1], Literal[1]]]  # once
   - Literal[Literal[1], Literal[Literal[Literal[1]]]]  # once
33 + Literal[1]  # once
   |
