Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Simplify and optimise
  • Loading branch information
AlexWaygood committed Apr 2, 2023
commit 6ba97e71b14c86ce703fc38feacb3cff48b4785a
6 changes: 3 additions & 3 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2036,11 +2036,11 @@ def __instancecheck__(cls, instance):
return True

if is_protocol_cls:
sentinel = object()
getattr_static = _lazy_load_getattr_static()
for attr in protocol_attrs:
val = getattr_static(instance, attr, sentinel)
if val is sentinel:
try:
val = getattr_static(instance, attr)
except AttributeError:
break
if callable(getattr(cls, attr, None)) and val is None:
break
Expand Down