MCPcopy Index your code
hub / github.com/ipython/ipython / _get_wrapped

Function _get_wrapped

IPython/core/oinspect.py:299–315  ·  view source on GitHub ↗

Get the original object if wrapped in one or more @decorators Some objects automatically construct similar objects on any unrecognised attribute access (e.g. unittest.mock.call). To protect against infinite loops, this will arbitrarily cut off after 100 levels of obj.__wrapped__ att

(obj)

Source from the content-addressed store, hash-verified

297 isinstance(obj, _builtin_func_type) or isinstance(obj, _builtin_meth_type))
298
299def _get_wrapped(obj):
300 """Get the original object if wrapped in one or more @decorators
301
302 Some objects automatically construct similar objects on any unrecognised
303 attribute access (e.g. unittest.mock.call). To protect against infinite loops,
304 this will arbitrarily cut off after 100 levels of obj.__wrapped__
305 attribute access. --TK, Jan 2016
306 """
307 orig_obj = obj
308 i = 0
309 while safe_hasattr(obj, '__wrapped__'):
310 obj = obj.__wrapped__
311 i += 1
312 if i > 100:
313 # __wrapped__ is probably a lie, so return the thing we started with
314 return orig_obj
315 return obj
316
317def find_file(obj) -> Optional[str]:
318 """Find the absolute path to the file where an object was defined.

Callers 3

getsourceFunction · 0.85
find_fileFunction · 0.85
find_source_linesFunction · 0.85

Calls 1

safe_hasattrFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…