@@ -1899,7 +1899,7 @@ def _proto_hook(other):
18991899 annotations = getattr (base , '__annotations__' , {})
19001900 if (isinstance (annotations , collections .abc .Mapping ) and
19011901 attr in annotations and
1902- issubclass (other , Generic ) and other . _is_protocol ):
1902+ issubclass (other , Generic ) and getattr ( other , ' _is_protocol' , False ) ):
19031903 break
19041904 else :
19051905 return NotImplemented
@@ -1917,7 +1917,7 @@ def _proto_hook(other):
19171917 if not (base in (object , Generic ) or
19181918 base .__module__ in _PROTO_ALLOWLIST and
19191919 base .__name__ in _PROTO_ALLOWLIST [base .__module__ ] or
1920- issubclass (base , Generic ) and base . _is_protocol ):
1920+ issubclass (base , Generic ) and getattr ( base , ' _is_protocol' , False ) ):
19211921 raise TypeError ('Protocols can only inherit from other'
19221922 ' protocols, got %r' % base )
19231923 if cls .__init__ is Protocol .__init__ :
@@ -2064,7 +2064,7 @@ def close(self): ...
20642064 Warning: this will check only the presence of the required methods,
20652065 not their type signatures!
20662066 """
2067- if not issubclass (cls , Generic ) or not cls . _is_protocol :
2067+ if not issubclass (cls , Generic ) or not getattr ( cls , ' _is_protocol' , False ) :
20682068 raise TypeError ('@runtime_checkable can be only applied to protocol classes,'
20692069 ' got %r' % cls )
20702070 cls ._is_runtime_protocol = True
0 commit comments