@@ -2924,13 +2924,10 @@ def test_runtime_checkable_generic_non_protocol(self):
2924
2924
@runtime_checkable
2925
2925
class Foo [T ]: ...
2926
2926
2927
- # TODO: RUSTPYTHON
2928
- @unittest .expectedFailure
2929
2927
def test_runtime_checkable_generic (self ):
2930
- # @runtime_checkable
2931
- # class Foo[T](Protocol):
2932
- # def meth(self) -> T: ...
2933
- # pass
2928
+ @runtime_checkable
2929
+ class Foo [T ](Protocol ):
2930
+ def meth (self ) -> T : ...
2934
2931
2935
2932
class Impl :
2936
2933
def meth (self ) -> int : ...
@@ -2945,9 +2942,9 @@ def method(self) -> int: ...
2945
2942
# TODO: RUSTPYTHON
2946
2943
@unittest .expectedFailure
2947
2944
def test_pep695_generics_can_be_runtime_checkable (self ):
2948
- # @runtime_checkable
2949
- # class HasX(Protocol):
2950
- # x: int
2945
+ @runtime_checkable
2946
+ class HasX (Protocol ):
2947
+ x : int
2951
2948
2952
2949
class Bar [T ]:
2953
2950
x : T
@@ -2987,22 +2984,20 @@ def f():
2987
2984
2988
2985
self .assertIsInstance (f , HasCallProtocol )
2989
2986
2990
- # TODO: RUSTPYTHON
2991
- @unittest .expectedFailure
2992
2987
def test_no_inheritance_from_nominal (self ):
2993
2988
class C : pass
2994
2989
2995
- # class BP(Protocol): pass
2990
+ class BP (Protocol ): pass
2996
2991
2997
- # with self.assertRaises(TypeError):
2998
- # class P(C, Protocol):
2999
- # pass
3000
- # with self.assertRaises(TypeError):
3001
- # class Q(Protocol, C):
3002
- # pass
3003
- # with self.assertRaises(TypeError):
3004
- # class R(BP, C, Protocol):
3005
- # pass
2992
+ with self .assertRaises (TypeError ):
2993
+ class P (C , Protocol ):
2994
+ pass
2995
+ with self .assertRaises (TypeError ):
2996
+ class Q (Protocol , C ):
2997
+ pass
2998
+ with self .assertRaises (TypeError ):
2999
+ class R (BP , C , Protocol ):
3000
+ pass
3006
3001
3007
3002
class D (BP , C ): pass
3008
3003
@@ -3014,7 +3009,7 @@ class E(C, BP): pass
3014
3009
# TODO: RUSTPYTHON
3015
3010
@unittest .expectedFailure
3016
3011
def test_no_instantiation (self ):
3017
- # class P(Protocol): pass
3012
+ class P (Protocol ): pass
3018
3013
3019
3014
with self .assertRaises (TypeError ):
3020
3015
P ()
@@ -3042,16 +3037,14 @@ class CG(PG[T]): pass
3042
3037
with self .assertRaises (TypeError ):
3043
3038
CG [int ](42 )
3044
3039
3045
- # TODO: RUSTPYTHON
3046
- @unittest .expectedFailure
3047
3040
def test_protocol_defining_init_does_not_get_overridden (self ):
3048
3041
# check that P.__init__ doesn't get clobbered
3049
3042
# see https://bugs.python.org/issue44807
3050
3043
3051
- # class P(Protocol):
3052
- # x: int
3053
- # def __init__(self, x: int) -> None:
3054
- # self.x = x
3044
+ class P (Protocol ):
3045
+ x : int
3046
+ def __init__ (self , x : int ) -> None :
3047
+ self .x = x
3055
3048
class C : pass
3056
3049
3057
3050
c = C ()
@@ -3478,9 +3471,9 @@ def __getattr__(self, attr):
3478
3471
# TODO: RUSTPYTHON
3479
3472
@unittest .expectedFailure
3480
3473
def test_no_weird_caching_with_issubclass_after_isinstance_pep695 (self ):
3481
- # @runtime_checkable
3482
- # class Spam[T](Protocol):
3483
- # x: T
3474
+ @runtime_checkable
3475
+ class Spam [T ](Protocol ):
3476
+ x : T
3484
3477
3485
3478
class Eggs [T ]:
3486
3479
def __init__ (self , x : T ) -> None :
0 commit comments