MCPcopy Index your code
hub / github.com/RustPython/RustPython / __subclasscheck__

Method __subclasscheck__

Lib/typing.py:2001–2025  ·  view source on GitHub ↗
(cls, other)

Source from the content-addressed store, hash-verified

1999 cls.__protocol_attrs__ = _get_protocol_attrs(cls)
2000
2001 def __subclasscheck__(cls, other):
2002 if cls is Protocol:
2003 return type.__subclasscheck__(cls, other)
2004 if (
2005 getattr(cls, '_is_protocol', False)
2006 and not _allow_reckless_class_checks()
2007 ):
2008 if not getattr(cls, '_is_runtime_protocol', False):
2009 _type_check_issubclass_arg_1(other)
2010 raise TypeError(
2011 "Instance and class checks can only be used with "
2012 "@runtime_checkable protocols"
2013 )
2014 if (
2015 # this attribute is set by @runtime_checkable:
2016 cls.__non_callable_proto_members__
2017 and cls.__dict__.get("__subclasshook__") is _proto_hook
2018 ):
2019 _type_check_issubclass_arg_1(other)
2020 non_method_attrs = sorted(cls.__non_callable_proto_members__)
2021 raise TypeError(
2022 "Protocols with non-method members don't support issubclass()."
2023 f" Non-method members: {str(non_method_attrs)[1:-1]}."
2024 )
2025 return _abc_subclasscheck(cls, other)
2026
2027 def __instancecheck__(cls, instance):
2028 # We need this method for situations where attributes are

Callers

nothing calls this directly

Calls 8

getattrFunction · 0.85
sortedFunction · 0.85
strFunction · 0.85
_abc_subclasscheckFunction · 0.85
__subclasscheck__Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected