28
28
29
29
from hypothesis import strategies as st
30
30
from hypothesis .errors import InvalidArgument , ResolutionFailed
31
- from hypothesis .internal .compat import PYPY
31
+ from hypothesis .internal .compat import PYPY , BaseExceptionGroup , ExceptionGroup
32
32
from hypothesis .internal .conjecture .utils import many as conjecture_utils_many
33
33
from hypothesis .strategies ._internal .datetime import zoneinfo # type: ignore
34
34
from hypothesis .strategies ._internal .ipaddress import (
@@ -554,6 +554,16 @@ def _networks(bits):
554
554
UnicodeTranslateError : st .builds (
555
555
UnicodeTranslateError , st .text (), st .just (0 ), st .just (0 ), st .just ("reason" )
556
556
),
557
+ BaseExceptionGroup : st .builds (
558
+ BaseExceptionGroup ,
559
+ st .text (),
560
+ st .lists (st .from_type (BaseException ), min_size = 1 ),
561
+ ),
562
+ ExceptionGroup : st .builds (
563
+ ExceptionGroup ,
564
+ st .text (),
565
+ st .lists (st .from_type (Exception ), min_size = 1 ),
566
+ ),
557
567
enumerate : st .builds (enumerate , st .just (())),
558
568
filter : st .builds (filter , st .just (lambda _ : None ), st .just (())),
559
569
map : st .builds (map , st .just (lambda _ : None ), st .just (())),
@@ -569,21 +579,6 @@ def _networks(bits):
569
579
_global_type_lookup [zoneinfo .ZoneInfo ] = st .timezones ()
570
580
if PYPY :
571
581
_global_type_lookup [builtins .sequenceiterator ] = st .builds (iter , st .tuples ()) # type: ignore
572
- try :
573
- BaseExceptionGroup # type: ignore # noqa
574
- except NameError :
575
- pass
576
- else : # pragma: no cover
577
- _global_type_lookup [BaseExceptionGroup ] = st .builds ( # type: ignore
578
- BaseExceptionGroup , # type: ignore
579
- st .text (),
580
- st .lists (st .from_type (BaseException ), min_size = 1 ),
581
- )
582
- _global_type_lookup [ExceptionGroup ] = st .builds ( # type: ignore
583
- ExceptionGroup , # type: ignore
584
- st .text (),
585
- st .lists (st .from_type (Exception ), min_size = 1 ),
586
- )
587
582
588
583
589
584
_global_type_lookup [type ] = st .sampled_from (
0 commit comments