Skip to content

Commit

Permalink
Add additional tests for immutable/mutable type cases and tuple vs. l…
Browse files Browse the repository at this point in the history
…ist iterators.
  • Loading branch information
ay0503 committed Dec 6, 2024
1 parent e5893cf commit b03bedc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test-data/unit/check-expressions.test
Original file line number Diff line number Diff line change
Expand Up @@ -2453,9 +2453,22 @@ T() # E: "TypeVar" not callable
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]

[case testListComprehensionWithUnionTypeGenerator]
[case testListComprehensionWithTupleUnionTypeGenerator]
class A: pass
class B: pass
a = A()
b = B()
l3: list[A | B] = [x for x in [a, b]]
l3: list[A | B] = [x for x in (a, b)]
l3: list[A | B] = [x for x in [a, b]]

[case testListComprehensionWithListUnionTypeGenerator]
a = A()
b = "foo"
l3: list[A | str] = [x for x in (a, b)]
l3: list[A | str] = [x for x in [a, b]]

[case testListComprehensionWithImmutableTypeUnionTypeGenerator]
a = 3.0
b = 3
l3: list[float | int] = [x for x in (a, b)]
l3: list[float | int] = [x for x in [a, b]]

0 comments on commit b03bedc

Please sign in to comment.