Skip to content

Commit ed8d8b1

Browse files
committed
PR feedback
1 parent a671dab commit ed8d8b1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/trio/_tests/type_tests/raisesgroup.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import sys
4-
from typing import Union
4+
from typing import Callable, Union
55

66
from trio.testing import Matcher, RaisesGroup
77
from typing_extensions import assert_type
@@ -44,8 +44,7 @@ def check_matches_with_different_exception_type() -> None:
4444
)
4545

4646
# 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
4948
if RaisesGroup(ValueError).matches(e):
5049
assert_type(e, ExceptionGroup[ValueError])
5150

@@ -221,3 +220,14 @@ def check_raisesgroup_overloads() -> None:
221220
def check_triple_nested_raisesgroup() -> None:
222221
with RaisesGroup(RaisesGroup(RaisesGroup(ValueError))) as e:
223222
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+
)

src/trio/testing/_raises_group.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ def __init__(
419419
allow_unwrapped: bool = False,
420420
flatten_subgroups: bool = False,
421421
match: str | Pattern[str] | None = None,
422-
# NOTE: I don't think the following argument type *should* work. But it does!
423422
check: (
424423
Callable[[BaseExceptionGroup[BaseExcT_1]], bool]
425424
| Callable[[ExceptionGroup[ExcT_1]], bool]

0 commit comments

Comments
 (0)