Skip to main content
AST-based detection and source transformation for async call fixes. Targets: aact, ainstruct, aquery calls that return uncomputed ModelOutputThunk.

Functions

FUNC find_fixable_calls

find_fixable_calls(source: str, filepath: Path) -> list[FixLocation]
Analyze source code and return locations of calls that need fixing. Args:
  • source: Python source code to analyze.
  • filepath: Path used for error messages and AST filename metadata.
Returns:
  • List of FixLocation objects describing each call site that should be fixed.

FUNC fix_file

fix_file(filepath: Path, mode: _FixMode, dry_run: bool = False) -> list[FixLocation]
Fix a single file. Args:
  • filepath: Path to the Python file to fix.
  • mode: Fix strategy to apply.
  • dry_run: If True, return locations without modifying the file.
Returns:
  • List of FixLocation objects for each call site found (and optionally fixed).

FUNC fix_path

fix_path(path: Path, mode: _FixMode, dry_run: bool = False) -> FixResult
Fix a file or directory recursively. Args:
  • path: File or directory to process. Directories are scanned recursively for *.py files.
  • mode: Fix strategy to apply.
  • dry_run: If True, report locations without modifying files.
Returns:
  • Aggregated FixResult with all fix locations and summary counts.

Classes

CLASS FixLocation

Location of a single fix along with source position and call metadata. Args:
  • filepath: Path to the source file containing the call.
  • line: One-based line number of the call expression.
  • col_offset: Column offset of the call expression.
  • function_name: Mellea function that was called (“aact”, “ainstruct”, or “aquery”).
  • call_style: Whether the call is “functional” or “session”.
  • target_variable: MOT variable name from the assignment, if any.
  • context_variable: Name of the context variable, if any.

CLASS FixResult

Aggregated summary of all fixes applied across the scanned codebase. Args:
  • locations: Individual fix locations with call metadata.
  • total_fixes: Total number of fixes applied.
  • files_affected: Number of distinct files that were modified.