MCPcopy Index your code
hub / github.com/python/cpython / __instancecheck__

Method __instancecheck__

Lib/_py_abc.py:92–106  ·  view source on GitHub ↗

Override for isinstance(instance, cls).

(cls, instance)

Source from the content-addressed store, hash-verified

90 cls._abc_negative_cache.clear()
91
92 def __instancecheck__(cls, instance):
93 """Override for isinstance(instance, cls)."""
94 # Inline the cache checking
95 subclass = instance.__class__
96 if subclass in cls._abc_cache:
97 return True
98 subtype = type(instance)
99 if subtype is subclass:
100 if (cls._abc_negative_cache_version ==
101 ABCMeta._abc_invalidation_counter and
102 subclass in cls._abc_negative_cache):
103 return False
104 # Fall back to the subclass check.
105 return cls.__subclasscheck__(subclass)
106 return any(cls.__subclasscheck__(c) for c in (subclass, subtype))
107
108 def __subclasscheck__(cls, subclass):
109 """Override for issubclass(subclass, cls)."""

Callers

nothing calls this directly

Calls 2

anyFunction · 0.70
__subclasscheck__Method · 0.45

Tested by

no test coverage detected