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

ℹ Safe fix
2 2 | import typing as t
3 3 | import typing_extensions
4 4 | 
5   |-x: Literal[True, False, True, False]  # PYI062 twice here
  5 |+x: Literal[True, False]  # PYI062 twice here
6 6 | 
7 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]]  # PYI062 on the last 1
8 8 | 

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

ℹ Safe fix
2 2 | import typing as t
3 3 | import typing_extensions
4 4 | 
5   |-x: Literal[True, False, True, False]  # PYI062 twice here
  5 |+x: Literal[True, False]  # PYI062 twice here
6 6 | 
7 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]]  # PYI062 on the last 1
8 8 | 

PYI062.pyi:7:45: PYI062 [*] Duplicate literal member `1`
  |
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
  |                                             ^ PYI062
8 | 
9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
  |
  = help: Remove duplicates

ℹ Safe fix
4 4 | 
5 5 | x: Literal[True, False, True, False]  # PYI062 twice here
6 6 | 
7   |-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 8 | 
9 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
10 10 | 

PYI062.pyi:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}`
   |
 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
   |                                 ^^^^^^^ PYI062
10 | 
11 | Literal[1, Literal[1]]  # once
   |
   = help: Remove duplicates

ℹ Safe fix
6  6  | 
7  7  | y: Literal[1, print("hello"), 3, Literal[4, 1]]  # PYI062 on the last 1
8  8  | 
9     |-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 10 | 
11 11 | Literal[1, Literal[1]]  # once
12 12 | Literal[1, 2, Literal[1, 2]]  # twice

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

ℹ Safe fix
8  8  | 
9  9  | z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
10 10 | 
11    |-Literal[1, Literal[1]]  # once
   11 |+Literal[1]  # once
12 12 | Literal[1, 2, Literal[1, 2]]  # twice
13 13 | Literal[1, Literal[1], Literal[1]]  # twice
14 14 | Literal[1, Literal[2], Literal[2]]  # once

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

ℹ Safe fix
9  9  | z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
10 10 | 
11 11 | Literal[1, Literal[1]]  # once
12    |-Literal[1, 2, Literal[1, 2]]  # twice
   12 |+Literal[1, 2]  # twice
13 13 | Literal[1, Literal[1], Literal[1]]  # twice
14 14 | Literal[1, Literal[2], Literal[2]]  # once
15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once

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

ℹ Safe fix
9  9  | z: Literal[{1, 3, 5}, "foobar", {1,3,5}]  # PYI062 on the set literal
10 10 | 
11 11 | Literal[1, Literal[1]]  # once
12    |-Literal[1, 2, Literal[1, 2]]  # twice
   12 |+Literal[1, 2]  # twice
13 13 | Literal[1, Literal[1], Literal[1]]  # twice
14 14 | Literal[1, Literal[2], Literal[2]]  # once
15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once

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

ℹ Safe fix
10 10 | 
11 11 | Literal[1, Literal[1]]  # once
12 12 | Literal[1, 2, Literal[1, 2]]  # twice
13    |-Literal[1, Literal[1], Literal[1]]  # twice
   13 |+Literal[1]  # twice
14 14 | Literal[1, Literal[2], Literal[2]]  # once
15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16 16 | typing_extensions.Literal[1, 1, 1]  # twice

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

ℹ Safe fix
10 10 | 
11 11 | Literal[1, Literal[1]]  # once
12 12 | Literal[1, 2, Literal[1, 2]]  # twice
13    |-Literal[1, Literal[1], Literal[1]]  # twice
   13 |+Literal[1]  # twice
14 14 | Literal[1, Literal[2], Literal[2]]  # once
15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16 16 | typing_extensions.Literal[1, 1, 1]  # twice

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

ℹ Safe fix
11 11 | Literal[1, Literal[1]]  # once
12 12 | Literal[1, 2, Literal[1, 2]]  # twice
13 13 | Literal[1, Literal[1], Literal[1]]  # twice
14    |-Literal[1, Literal[2], Literal[2]]  # once
   14 |+Literal[1, 2]  # once
15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16 16 | typing_extensions.Literal[1, 1, 1]  # twice
17 17 | Literal[

PYI062.pyi:15:37: PYI062 [*] Duplicate literal member `1`
   |
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
   |                                     ^ PYI062
16 | typing_extensions.Literal[1, 1, 1]  # twice
17 | Literal[
   |
   = help: Remove duplicates

ℹ Safe fix
12 12 | Literal[1, 2, Literal[1, 2]]  # twice
13 13 | Literal[1, Literal[1], Literal[1]]  # twice
14 14 | Literal[1, Literal[2], Literal[2]]  # once
15    |-t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
   15 |+t.Literal[1, 2]  # once
16 16 | typing_extensions.Literal[1, 1, 1]  # twice
17 17 | Literal[
18 18 |     1, # comment

PYI062.pyi:16:30: PYI062 [*] Duplicate literal member `1`
   |
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
   |                              ^ PYI062
17 | Literal[
18 |     1, # comment
   |
   = help: Remove duplicates

ℹ Safe fix
13 13 | Literal[1, Literal[1], Literal[1]]  # twice
14 14 | Literal[1, Literal[2], Literal[2]]  # once
15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16    |-typing_extensions.Literal[1, 1, 1]  # twice
   16 |+typing_extensions.Literal[1]  # twice
17 17 | Literal[
18 18 |     1, # comment
19 19 |     Literal[ # another comment

PYI062.pyi:16:33: PYI062 [*] Duplicate literal member `1`
   |
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
   |                                 ^ PYI062
17 | Literal[
18 |     1, # comment
   |
   = help: Remove duplicates

ℹ Safe fix
13 13 | Literal[1, Literal[1], Literal[1]]  # twice
14 14 | Literal[1, Literal[2], Literal[2]]  # once
15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16    |-typing_extensions.Literal[1, 1, 1]  # twice
   16 |+typing_extensions.Literal[1]  # twice
17 17 | Literal[
18 18 |     1, # comment
19 19 |     Literal[ # another comment

PYI062.pyi:20:9: PYI062 [*] Duplicate literal member `1`
   |
18 |     1, # comment
19 |     Literal[ # another comment
20 |         1
   |         ^ PYI062
21 |     ]
22 | ]  # once
   |
   = help: Remove duplicates

ℹ Unsafe fix
14 14 | Literal[1, Literal[2], Literal[2]]  # once
15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]]  # once
16 16 | typing_extensions.Literal[1, 1, 1]  # twice
17    |-Literal[
18    |-    1, # comment
19    |-    Literal[ # another comment
20    |-        1
21    |-    ]
22    |-]  # once
   17 |+Literal[1]  # once
23 18 | 
24 19 | # Ensure issue is only raised once, even on nested literals
25 20 | MyType = Literal["foo", Literal[True, False, True], "bar"]  # PYI062

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

ℹ Safe fix
22 22 | ]  # once
23 23 | 
24 24 | # Ensure issue is only raised once, even on nested literals
25    |-MyType = Literal["foo", Literal[True, False, True], "bar"]  # PYI062
   25 |+MyType = Literal["foo", True, False, "bar"]  # PYI062
26 26 | 
27 27 | n: Literal["No", "duplicates", "here", 1, "1"]
28 28 | 

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

ℹ Safe fix
29 29 | 
30 30 | # nested literals, all equivalent to `Literal[1]`
31 31 | Literal[Literal[1]]  # no duplicate
32    |-Literal[Literal[Literal[1], Literal[1]]]  # once
   32 |+Literal[1]  # once
33 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]]  # once

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

ℹ Safe fix
30 30 | # nested literals, all equivalent to `Literal[1]`
31 31 | Literal[Literal[1]]  # no duplicate
32 32 | Literal[Literal[Literal[1], Literal[1]]]  # once
33    |-Literal[Literal[1], Literal[Literal[Literal[1]]]]  # once
   33 |+Literal[1]  # once
