Skip to content

Commit f7af3f7

Browse files
updated test
1 parent 57c542c commit f7af3f7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
from typing_extensions import assert_type
1+
from typing_extensions import Literal, assert_type
2+
23

34
# Note: type checkers / linters are free to point out that the set difference
45
# below is redundant. But typeshed should allow it, as its job is to describe
56
# what is legal in Python, not what is sensible.
6-
x: set[str] = {"foo", "bar"}
7-
assert_type(x - {123}, set[str])
7+
# For instance, set[Literal] - set[str] should be legal.
8+
def test_set_difference(x: set[Literal["foo", "bar"]], y: set[str], z: set[int]) -> None:
9+
assert_type(x - y, set[Literal["foo", "bar"]])
10+
assert_type(y - x, set[str])
11+
assert_type(x - z, set[Literal["foo", "bar"]])
12+
assert_type(z - x, set[int])
13+
assert_type(y - z, set[str])
14+
assert_type(z - y, set[int])

0 commit comments

Comments
 (0)