Return code object for given function.
(obj: object, trycall: bool = True)
| 127 | |
| 128 | |
| 129 | def 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 | |
| 142 | def deindent(lines: Iterable[str]) -> List[str]: |
no outgoing calls
no test coverage detected