| [case testTryStarSimple] |
| try: |
| pass |
| except* Exception as e: |
| reveal_type(e) # N: Revealed type is "builtins.ExceptionGroup[builtins.Exception]" |
| [builtins fixtures/exception.pyi] |
| |
| [case testTryStarMultiple] |
| try: |
| pass |
| except* Exception as e: |
| reveal_type(e) # N: Revealed type is "builtins.ExceptionGroup[builtins.Exception]" |
| except* RuntimeError as e: |
| reveal_type(e) # N: Revealed type is "builtins.ExceptionGroup[builtins.RuntimeError]" |
| [builtins fixtures/exception.pyi] |
| |
| [case testTryStarBase] |
| try: |
| pass |
| except* BaseException as e: |
| reveal_type(e) # N: Revealed type is "builtins.BaseExceptionGroup[builtins.BaseException]" |
| [builtins fixtures/exception.pyi] |
| |
| [case testTryStarTuple] |
| class Custom(Exception): ... |
| |
| try: |
| pass |
| except* (RuntimeError, Custom) as e: |
| reveal_type(e) # N: Revealed type is "builtins.ExceptionGroup[Union[builtins.RuntimeError, __main__.Custom]]" |
| [builtins fixtures/exception.pyi] |
| |
| [case testTryStarInvalidType] |
| class Bad: ... |
| try: |
| pass |
| except* (RuntimeError, Bad) as e: # E: Exception type must be derived from BaseException (or be a tuple of exception classes) |
| reveal_type(e) # N: Revealed type is "builtins.ExceptionGroup[Any]" |
| [builtins fixtures/exception.pyi] |
| |
| [case testTryStarGroupInvalid] |
| try: |
| pass |
| except* ExceptionGroup as e: # E: Exception type in except* cannot derive from BaseExceptionGroup |
| reveal_type(e) # N: Revealed type is "builtins.ExceptionGroup[Any]" |
| [builtins fixtures/exception.pyi] |
| |
| [case testTryStarGroupInvalidTuple] |
| try: |
| pass |
| except* (RuntimeError, ExceptionGroup) as e: # E: Exception type in except* cannot derive from BaseExceptionGroup |
| reveal_type(e) # N: Revealed type is "builtins.ExceptionGroup[Union[builtins.RuntimeError, Any]]" |
| [builtins fixtures/exception.pyi] |
| |
| [case testBasicTypeVarTupleGeneric] |
| from typing import Generic, TypeVarTuple, Unpack |
| |
| Ts = TypeVarTuple("Ts") |
| |
| class Variadic(Generic[Unpack[Ts]]): |
| ... |
| |
| variadic: Variadic[int, str] |
| reveal_type(variadic) # N: Revealed type is "__main__.Variadic[builtins.int, builtins.str]" |
| [builtins fixtures/tuple.pyi] |
| |
| [case testAsyncGeneratorWithinComprehension] |
| # flags: --python-version 3.11 |
| from typing import Any, Generator, List |
| |
| async def asynciter(iterable): |
| for x in iterable: |
| yield x |
| |
| async def coro() -> Generator[List[Any], None, None]: |
| return ([i async for i in asynciter([0,j])] for j in [3, 5]) |
| reveal_type(coro) # N: Revealed type is "def () -> typing.Coroutine[Any, Any, typing.Generator[builtins.list[Any], None, None]]" |
| [builtins fixtures/async_await.pyi] |
| [typing fixtures/typing-async.pyi] |