From b03bedcbaf64b8f1679fde2ae6fb5598fe2f2d87 Mon Sep 17 00:00:00 2001 From: Andrew Youn <52907065+ay0503@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:59:46 -0500 Subject: [PATCH] Add additional tests for immutable/mutable type cases and tuple vs. list iterators. --- test-data/unit/check-expressions.test | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test-data/unit/check-expressions.test b/test-data/unit/check-expressions.test index 2a20b3f77add..58ae97d68224 100644 --- a/test-data/unit/check-expressions.test +++ b/test-data/unit/check-expressions.test @@ -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]] \ No newline at end of file +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]]