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

Function _instance_callable

Lib/unittest/mock.py:170–182  ·  view source on GitHub ↗

Given an object, return True if the object is callable. For classes, return True if instances would be callable.

(obj)

Source from the content-addressed store, hash-verified

168
169
170def _instance_callable(obj):
171 """Given an object, return True if the object is callable.
172 For classes, return True if instances would be callable."""
173 if not isinstance(obj, type):
174 # already an instance
175 return getattr(obj, '__call__', None) is not None
176
177 # *could* be broken by a class overriding __mro__ or __dict__ via
178 # a metaclass
179 for base in (obj,) + obj.__mro__:
180 if base.__dict__.get('__call__') is not None:
181 return True
182 return False
183
184
185def _set_signature(mock, original, instance=False):

Callers 2

__enter__Method · 0.85
create_autospecFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…