Skip to content

Commit cf0346f

Browse files
added testTernaryOperatorWithDefault
1 parent 92eb83c commit cf0346f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test-data/unit/check-expressions.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,3 +2492,21 @@ x + T # E: Unsupported left operand type for + ("int")
24922492
T() # E: "TypeVar" not callable
24932493
[builtins fixtures/tuple.pyi]
24942494
[typing fixtures/typing-full.pyi]
2495+
2496+
[case testTernaryOperatorWithDefault]
2497+
# flags: --python-version 3.13
2498+
# gh-18817
2499+
2500+
class Ok[T, E = None]:
2501+
def __init__(self, value: T) -> None:
2502+
self._value = value
2503+
2504+
class Err[E, T = None]:
2505+
def __init__(self, value: E) -> None:
2506+
self._value = value
2507+
2508+
type Result[T, E] = Ok[T, E] | Err[E, T]
2509+
2510+
class Bar[U]:
2511+
def foo(data: U, cond: bool) -> Result[U, str]:
2512+
return Ok(data) if cond else Err("Error")

0 commit comments

Comments
 (0)