Return code object for given function.
(obj: object, trycall: bool = True)
| 134 | |
| 135 | |
| 136 | def 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 | |
| 149 | def deindent(lines: Iterable[str]) -> list[str]: |
no outgoing calls
no test coverage detected