Skip to content

Commit 15f0d6f

Browse files
added testTernaryOperatorWithDefault
1 parent e7f95f8 commit 15f0d6f

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
@@ -2463,3 +2463,21 @@ x + T # E: Unsupported left operand type for + ("int")
24632463
T() # E: "TypeVar" not callable
24642464
[builtins fixtures/tuple.pyi]
24652465
[typing fixtures/typing-full.pyi]
2466+
2467+
[case testTernaryOperatorWithDefault]
2468+
# flags: --python-version 3.13
2469+
# gh-18817
2470+
2471+
class Ok[T, E = None]:
2472+
def __init__(self, value: T) -> None:
2473+
self._value = value
2474+
2475+
class Err[E, T = None]:
2476+
def __init__(self, value: E) -> None:
2477+
self._value = value
2478+
2479+
type Result[T, E] = Ok[T, E] | Err[E, T]
2480+
2481+
class Bar[U]:
2482+
def foo(data: U, cond: bool) -> Result[U, str]:
2483+
return Ok(data) if cond else Err("Error")

0 commit comments

Comments
 (0)