46
46
t
47
47
for t in types ._global_type_lookup
48
48
# We ignore TypeVar, because it is not a Generic type:
49
- if isinstance (t , types .typing_root_type ) and t != typing .TypeVar
49
+ if isinstance (t , types .typing_root_type )
50
+ and t != typing .TypeVar
51
+ and (sys .version_info [:2 ] <= (3 , 11 ) or t != typing .ByteString )
50
52
),
51
53
key = str ,
52
54
)
@@ -110,7 +112,11 @@ def test_typing_Type_Union(ex):
110
112
@given (data = st .data ())
111
113
def test_rare_types (data , typ ):
112
114
ex = data .draw (from_type (typ ))
113
- assert isinstance (ex , typ )
115
+ with warnings .catch_warnings ():
116
+ if sys .version_info [:2 ] >= (3 , 12 ):
117
+ warnings .simplefilter ("ignore" , DeprecationWarning )
118
+ # ByteString is deprecated in Python 3.12
119
+ assert isinstance (ex , typ )
114
120
115
121
116
122
class Elem :
@@ -752,7 +758,7 @@ def test_inference_on_generic_collections_abc_aliases(typ, data):
752
758
def test_bytestring_not_treated_as_generic_sequence (val ):
753
759
# Check that we don't fall into the specific problem from
754
760
# https://github.com/HypothesisWorks/hypothesis/issues/2257
755
- assert not isinstance (val , typing . ByteString )
761
+ assert not isinstance (val , bytes )
756
762
# Check it hasn't happened again from some other non-generic sequence type.
757
763
for x in val :
758
764
assert isinstance (x , set )
@@ -764,7 +770,7 @@ def test_bytestring_not_treated_as_generic_sequence(val):
764
770
def test_bytestring_is_valid_sequence_of_int_and_parent_classes (type_ ):
765
771
find_any (
766
772
st .from_type (typing .Sequence [type_ ]),
767
- lambda val : isinstance (val , typing . ByteString ),
773
+ lambda val : isinstance (val , bytes ),
768
774
)
769
775
770
776
0 commit comments