MCPcopy Create free account
hub / github.com/pytest-dev/pytest / getrawcode

Function getrawcode

src/_pytest/_code/source.py:129–139  ·  view source on GitHub ↗

Return code object for given function.

(obj: object, trycall: bool = True)

Source from the content-addressed store, hash-verified

127
128
129def getrawcode(obj: object, trycall: bool = True) -> types.CodeType:
130 """Return code object for given function."""
131 try:
132 return obj.__code__ # type: ignore[attr-defined,no-any-return]
133 except AttributeError:
134 pass
135 if trycall:
136 call = getattr(obj, "__call__", None)
137 if call and not isinstance(obj, type):
138 return getrawcode(call, trycall=False)
139 raise TypeError(f"could not get code object for {obj!r}")
140
141
142def deindent(lines: Iterable[str]) -> List[str]:

Callers 2

from_functionMethod · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected