|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | import sys
|
4 |
| -from typing import Union |
| 4 | +from typing import Callable, Union |
5 | 5 |
|
6 | 6 | from trio.testing import Matcher, RaisesGroup
|
7 | 7 | from typing_extensions import assert_type
|
@@ -44,8 +44,7 @@ def check_matches_with_different_exception_type() -> None:
|
44 | 44 | )
|
45 | 45 |
|
46 | 46 | # note: it might be tempting to have this warn.
|
47 |
| - # however, note that we should not warn if e: BaseException |
48 |
| - # .... therefore this needs to pass as there is no distinction |
| 47 | + # however, that isn't possible with current typing |
49 | 48 | if RaisesGroup(ValueError).matches(e):
|
50 | 49 | assert_type(e, ExceptionGroup[ValueError])
|
51 | 50 |
|
@@ -221,3 +220,14 @@ def check_raisesgroup_overloads() -> None:
|
221 | 220 | def check_triple_nested_raisesgroup() -> None:
|
222 | 221 | with RaisesGroup(RaisesGroup(RaisesGroup(ValueError))) as e:
|
223 | 222 | assert_type(e.value, ExceptionGroup[ExceptionGroup[ExceptionGroup[ValueError]]])
|
| 223 | + |
| 224 | + |
| 225 | +def check_check_typing() -> None: |
| 226 | + assert_type( # type: ignore |
| 227 | + RaisesGroup(ValueError).check, |
| 228 | + Union[ |
| 229 | + Callable[[BaseExceptionGroup[ValueError]], None], |
| 230 | + Callable[[ExceptionGroup[ValueError]], None], |
| 231 | + None, |
| 232 | + ], |
| 233 | + ) |
0 commit comments