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

Function _instance_callable

Lib/unittest/mock.py:169–181  ·  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

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

Callers 2

__enter__Method · 0.85
create_autospecFunction · 0.85

Calls 3

isinstanceFunction · 0.85
getattrFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected