Skip to content

refactor: rewrite stub sync script to use mypy stubgen#189

Open
Ruari-Phipps wants to merge 7 commits into
mainfrom
ruari/fix/fix_integration_init
Open

refactor: rewrite stub sync script to use mypy stubgen#189
Ruari-Phipps wants to merge 7 commits into
mainfrom
ruari/fix/fix_integration_init

Conversation

@Ruari-Phipps

Copy link
Copy Markdown
Collaborator

Summary

Replace the custom AST-based stub generator with mypy's stubgen + post-processing, and regenerate all stubs.

Motivation

The custom script (~600 lines) reimplemented stub generation with edge cases around dataclass __init__ synthesis, import pruning, TYPE_CHECKING blocks, and depth-aware relative imports. stubgen handles all of this correctly out of the box.

Changes

  • Rewrite scripts/sync_runtime_stubs.py to shell out to stubgen and post-process output (~170 lines)
  • Post-processing: relativize runtime./utils. imports, add copyright + noqa header, drop internal modules, replace Incomplete with Any
  • Regenerate all stubs from current runtime source
  • Fix integrations __init__.py to include re-exports

Usage: python scripts/sync_runtime_stubs.py --runtime-path /path/to/genai_lambda_runtime/python/runtime

Test strategy

  • Added/updated unit tests
  • Manual CLI testing (poly <command>)
  • Tested against a live Agent Studio project
  • N/A (docs, config, or trivial change)

Checklist

  • ruff check . and ruff format --check . pass
  • pytest passes (682/682)
  • No breaking changes to the poly CLI interface (or migration path documented)
  • Commit messages follow conventional commits

Ruari-Phipps and others added 2 commits June 15, 2026 10:41
Replace ~600 lines of custom AST parsing with stubgen + post-processing.
The script now shells out to `stubgen` and applies import relativization,
header injection, and internal module filtering.

Regenerate all stubs from current runtime source.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Ruari-Phipps Ruari-Phipps requested a review from a team June 15, 2026 09:56
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Ruari-Phipps Ruari-Phipps requested a review from bplevin36 June 15, 2026 16:57
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Base (main) PR Change
70.0% 70.0% +0.0% ✅

Changed file coverage

File Coverage Change
poly/utils.py 61.6% +1.5% ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant