Fix Python codegen synthetic permission approval names#1652
Open
abhinavgautam01 wants to merge 2 commits into
Open
Fix Python codegen synthetic permission approval names#1652abhinavgautam01 wants to merge 2 commits into
abhinavgautam01 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the Python codegen post-processing to remove unused “synthetic” Quicktype-emitted @dataclass classes so they no longer appear in the generated module exports.
Changes:
- Added a post-processing pass to delete unreferenced synthetic
@dataclassblocks from generated Python. - Wired the new pass into the Python codegen pipeline using the schema’s known definition names.
- Added a Python regression test and updated the generated
rpc.pyoutput accordingly.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/codegen/python.ts | Adds removeUnusedSyntheticPythonDataclasses() and applies it during final Python code post-processing. |
| python/test_codegen_type_names.py | Adds a regression test asserting a known synthetic type is not exported while real types remain exported. |
| python/copilot/generated/rpc.py | Regenerated output removing the unused synthetic dataclass and its __all__ export entry. |
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
Fixes Python codegen emitting an unintended quicktype-synthesized permission approval class name,
PermissionDecisionApproveForIonApproval, caused by structural merging of similar permission approval schemas.The generator now removes unreferenced synthetic dataclasses after union post-processing, preserving the intended schema-named union aliases such as
PermissionDecisionApproveForSessionApprovalandPermissionDecisionApproveForLocationApproval.Fixes #1125.
Changes
python/copilot/generated/rpc.pyTests
npm run generate:pythonpython3 -m pytest python/test_codegen_type_names.pyPATH=/Users/gautam/.nvm/versions/node/v22.14.0/bin:$PATH python3 -m pytest python/test_*.pygit diff --check