Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharsadhwani committed May 7, 2024
1 parent 40c75fb commit 784eb52
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 172 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Literal
import typing as t
import typing_extensions

x: Literal[True, False, True, False] # PYI062 twice here

Expand All @@ -10,8 +12,8 @@
Literal[1, 2, Literal[1, 2]] # twice
Literal[1, Literal[1], Literal[1]] # twice
Literal[1, Literal[2], Literal[2]] # once
Literal[1, Literal[2, Literal[1]]] # once
Literal[1, 1, 1] # twice
t.Literal[1, t.Literal[2, t.Literal[1]]] # once
typing_extensions.Literal[1, 1, 1] # twice

# Ensure issue is only raised once, even on nested literals
MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Literal
import typing as t
import typing_extensions

x: Literal[True, False, True, False] # PY062 twice here

Expand All @@ -10,8 +12,8 @@ Literal[1, Literal[1]] # once
Literal[1, 2, Literal[1, 2]] # twice
Literal[1, Literal[1], Literal[1]] # twice
Literal[1, Literal[2], Literal[2]] # once
Literal[1, Literal[2, Literal[1]]] # once
Literal[1, 1, 1] # twice
t.Literal[1, t.Literal[2, t.Literal[1]]] # once
typing_extensions.Literal[1, 1, 1] # twice

# Ensure issue is only raised once, even on nested literals
MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062
Expand Down
Original file line number Diff line number Diff line change
@@ -1,138 +1,138 @@
---
source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs
---
PYI062.py:3:25: PYI062 Duplicate literal member `True`
PYI062.py:5:25: PYI062 Duplicate literal member `True`
|
1 | from typing import Literal
2 |
3 | x: Literal[True, False, True, False] # PYI062 twice here
| ^^^^ PYI062
4 |
5 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1
|

PYI062.py:3:31: PYI062 Duplicate literal member `False`
|
1 | from typing import Literal
2 |
3 | x: Literal[True, False, True, False] # PYI062 twice here
| ^^^^^ PYI062
3 | import typing_extensions
4 |
5 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1
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
|

PYI062.py:5:45: PYI062 Duplicate literal member `1`
PYI062.py:5:31: PYI062 Duplicate literal member `False`
|
3 | x: Literal[True, False, True, False] # PYI062 twice here
3 | import typing_extensions
4 |
5 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1
| ^ PYI062
5 | x: Literal[True, False, True, False] # PYI062 twice here
| ^^^^^ PYI062
6 |
7 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal
7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1
|

PYI062.py:7:33: PYI062 Duplicate literal member `{1, 3, 5}`
PYI062.py:7:45: PYI062 Duplicate literal member `1`
|
5 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1
5 | x: Literal[True, False, True, False] # PYI062 twice here
6 |
7 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal
| ^^^^^^^ PYI062
7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1
| ^ PYI062
8 |
9 | Literal[1, Literal[1]] # once
9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal
|

PYI062.py:9:20: PYI062 Duplicate literal member `1`
PYI062.py:9:33: PYI062 Duplicate literal member `{1, 3, 5}`
|
7 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal
7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1
8 |
9 | Literal[1, Literal[1]] # once
9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal
| ^^^^^^^ PYI062
10 |
11 | Literal[1, Literal[1]] # once
|

PYI062.py: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
10 | Literal[1, 2, Literal[1, 2]] # twice
11 | Literal[1, Literal[1], Literal[1]] # twice
12 | Literal[1, 2, Literal[1, 2]] # twice
13 | Literal[1, Literal[1], Literal[1]] # twice
|

PYI062.py:10:23: PYI062 Duplicate literal member `1`
PYI062.py:12:23: PYI062 Duplicate literal member `1`
|
9 | Literal[1, Literal[1]] # once
10 | Literal[1, 2, Literal[1, 2]] # twice
11 | Literal[1, Literal[1]] # once
12 | Literal[1, 2, Literal[1, 2]] # twice
| ^ PYI062
11 | Literal[1, Literal[1], Literal[1]] # twice
12 | Literal[1, Literal[2], Literal[2]] # once
13 | Literal[1, Literal[1], Literal[1]] # twice
14 | Literal[1, Literal[2], Literal[2]] # once
|

PYI062.py:10:26: PYI062 Duplicate literal member `2`
PYI062.py:12:26: PYI062 Duplicate literal member `2`
|
9 | Literal[1, Literal[1]] # once
10 | Literal[1, 2, Literal[1, 2]] # twice
11 | Literal[1, Literal[1]] # once
12 | Literal[1, 2, Literal[1, 2]] # twice
| ^ PYI062
11 | Literal[1, Literal[1], Literal[1]] # twice
12 | Literal[1, Literal[2], Literal[2]] # once
13 | Literal[1, Literal[1], Literal[1]] # twice
14 | Literal[1, Literal[2], Literal[2]] # once
|

PYI062.py:11:20: PYI062 Duplicate literal member `1`
PYI062.py:13:20: PYI062 Duplicate literal member `1`
|
9 | Literal[1, Literal[1]] # once
10 | Literal[1, 2, Literal[1, 2]] # twice
11 | Literal[1, Literal[1], Literal[1]] # twice
11 | Literal[1, Literal[1]] # once
12 | Literal[1, 2, Literal[1, 2]] # twice
13 | Literal[1, Literal[1], Literal[1]] # twice
| ^ PYI062
12 | Literal[1, Literal[2], Literal[2]] # once
13 | Literal[1, Literal[2, Literal[1]]] # once
14 | Literal[1, Literal[2], Literal[2]] # once
15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once
|

PYI062.py:11:32: PYI062 Duplicate literal member `1`
PYI062.py:13:32: PYI062 Duplicate literal member `1`
|
9 | Literal[1, Literal[1]] # once
10 | Literal[1, 2, Literal[1, 2]] # twice
11 | Literal[1, Literal[1], Literal[1]] # twice
11 | Literal[1, Literal[1]] # once
12 | Literal[1, 2, Literal[1, 2]] # twice
13 | Literal[1, Literal[1], Literal[1]] # twice
| ^ PYI062
12 | Literal[1, Literal[2], Literal[2]] # once
13 | Literal[1, Literal[2, Literal[1]]] # once
14 | Literal[1, Literal[2], Literal[2]] # once
15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once
|

PYI062.py:12:32: PYI062 Duplicate literal member `2`
PYI062.py:14:32: PYI062 Duplicate literal member `2`
|
10 | Literal[1, 2, Literal[1, 2]] # twice
11 | Literal[1, Literal[1], Literal[1]] # twice
12 | Literal[1, Literal[2], Literal[2]] # 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
| ^ PYI062
13 | Literal[1, Literal[2, Literal[1]]] # once
14 | Literal[1, 1, 1] # twice
15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once
16 | typing_extensions.Literal[1, 1, 1] # twice
|

PYI062.py:13:31: PYI062 Duplicate literal member `1`
PYI062.py:15:37: PYI062 Duplicate literal member `1`
|
11 | Literal[1, Literal[1], Literal[1]] # twice
12 | Literal[1, Literal[2], Literal[2]] # once
13 | Literal[1, Literal[2, Literal[1]]] # once
| ^ PYI062
14 | Literal[1, 1, 1] # 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
| ^ PYI062
16 | typing_extensions.Literal[1, 1, 1] # twice
|

PYI062.py:14:12: PYI062 Duplicate literal member `1`
PYI062.py:16:30: PYI062 Duplicate literal member `1`
|
12 | Literal[1, Literal[2], Literal[2]] # once
13 | Literal[1, Literal[2, Literal[1]]] # once
14 | Literal[1, 1, 1] # twice
| ^ PYI062
15 |
16 | # Ensure issue is only raised once, even on nested literals
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 |
18 | # Ensure issue is only raised once, even on nested literals
|

PYI062.py:14:15: PYI062 Duplicate literal member `1`
PYI062.py:16:33: PYI062 Duplicate literal member `1`
|
12 | Literal[1, Literal[2], Literal[2]] # once
13 | Literal[1, Literal[2, Literal[1]]] # once
14 | Literal[1, 1, 1] # twice
| ^ PYI062
15 |
16 | # Ensure issue is only raised once, even on nested literals
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 |
18 | # Ensure issue is only raised once, even on nested literals
|

PYI062.py:17:46: PYI062 Duplicate literal member `True`
PYI062.py:19:46: PYI062 Duplicate literal member `True`
|
16 | # Ensure issue is only raised once, even on nested literals
17 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062
18 | # Ensure issue is only raised once, even on nested literals
19 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062
| ^^^^ PYI062
18 |
19 | n: Literal["No", "duplicates", "here", 1, "1"]
20 |
21 | n: Literal["No", "duplicates", "here", 1, "1"]
|
Loading

0 comments on commit 784eb52

Please sign in to comment.