API reference
python:arxjit:arxjit.extract_source
function extract_source
extract_source(fn: PyFunc) -> ExtractedSource
Source: packages/arxjit/src/arxjit/source.py:338
Declared as: python:arxjit:arxjit.source.extract_source
Extract and parse the source of a decorated function.
Retrieves the source block with inspect.getsourcelines (which follows wrapped, so a JitFunction resolves to the function it wraps) and parses it with ast.parse. An indented block is parsed inside a synthetic "if True:" wrapper rather than dedented, so the text is never modified and every node keeps real file lines and columns. The decorators are dropped from the returned node and source; async definitions are extracted here and left for the validation stage to accept or reject.
Parameters
- fn — Type: PyFunc; The Python function to extract.
Returns
Type: ExtractedSource
Raises
- SourceExtractionError: "If the source cannot be retrieved (REPL- or exec-defined functions, C builtins, self-referential wrappers, or a corrupted or since-modified source file), cannot be parsed (including source containing null bytes), or is not a single function definition (for example a lambda)."