MCPcopy
hub / github.com/pytest-dev/pytest / getrawcode

Function getrawcode

src/_pytest/_code/source.py:136–146  ·  view source on GitHub ↗

Return code object for given function.

(obj: object, trycall: bool = True)

Source from the content-addressed store, hash-verified

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

Callers 3

from_functionMethod · 0.90
_evaluateMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected