refactor: rewrite stub sync script to use mypy stubgen#189
Open
Ruari-Phipps wants to merge 7 commits into
Open
refactor: rewrite stub sync script to use mypy stubgen#189Ruari-Phipps wants to merge 7 commits into
Ruari-Phipps wants to merge 7 commits into
Conversation
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>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
Coverage Report
Changed file coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_CHECKINGblocks, and depth-aware relative imports.stubgenhandles all of this correctly out of the box.Changes
scripts/sync_runtime_stubs.pyto shell out tostubgenand post-process output (~170 lines)runtime./utils.imports, add copyright + noqa header, drop internal modules, replaceIncompletewithAny__init__.pyto include re-exportsUsage:
python scripts/sync_runtime_stubs.py --runtime-path /path/to/genai_lambda_runtime/python/runtimeTest strategy
poly <command>)Checklist
ruff check .andruff format --check .passpytestpasses (682/682)polyCLI interface (or migration path documented)