Repository navigation
add lazy model generation - #863
stobrien89 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
5 open issues
sys.stdlib_module_namesis only available on newer Python versions (introduced in Python 3.10).… · New Import grouping depends onstdlib_module_names, which can differ across Python versions/builds,… · New These tests hard-requirepyrightto be installed and runnable aspython -m pyright. If the test… · New Similarly, this test hard-requiresruffto be installed aspython -m ruffand assumes a stable… · New This assertion is tightly coupled to the multi-line parenthesizedfrom ... import (...)… · New
What changed in this PR
Adds native generation for lazy runtime Smithy models (models.py) alongside full typing stubs (models.pyi), and updates import rendering to produce grouped/combined imports to support the new generated modules.
Changes:
- Add
ModelGeneratorto emit lazy runtime model modules and.pyistubs, including validation of reserved member names. - Update
PythonWriterto render grouped/combined imports and adjust formatting for stub files. - Extend
smithy-coreModelRegistryto support full shape-id target mappings for unambiguous renamed/cross-namespace target resolution.
| File | Description |
|---|---|
| packages/smithy-python/tests/unit/test_writer.py | Updates import-format assertions and adds coverage for grouped/combined imports. |
| packages/smithy-python/tests/unit/test_models.py | Adds end-to-end tests for generated runtime/stub models, plus Ruff/Pyright validation. |
| packages/smithy-python/src/smithy_python/writer.py | Implements grouped/combined import rendering and stub-specific spacing. |
| packages/smithy-python/src/smithy_python/models.py | Introduces model/stub generation for lazy runtime models. |
| packages/smithy-python/src/smithy_python/generation.py | Extends ModelPlan to include registry metadata used by lazy model generation. |
| packages/smithy-python/src/smithy_python/files.py | Marks .pyi writers as stubs to adjust formatting behavior. |
| packages/smithy-python/.changes/next-release/smithy-python-feature-model-generation.json | Adds changelog entry for model generation feature. |
| packages/smithy-core/tests/unit/test_dynamic_models.py | Adds tests for copied name maps and full shape-id target resolution. |
| packages/smithy-core/src/smithy_core/_dynamic_models.py | Adds target_names support and improves rename handling during build/target resolution. |
| packages/smithy-core/.changes/next-release/smithy-core-enhancement-model-target-names.json | Adds changelog entry for ModelRegistry target-name enhancement. |
Review effort: Lite
f2d7c81 to
3b5aa19
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved runtime/stub mismatches, public-name collisions, and class-cache replacement can break generated model APIs and serialization.
6 open issues
Preserve canonical class identity across alias lookups · New Prevent synthetic ServiceError name collisions · New Prevent generated models from shadowing runtime helpers · New Handle explicit input and output traits in stub classification · New Align stub and runtime member naming rules · New Support Unit union members consistently at runtime · New
5 resolved since last review
sys.stdlib_module_namesis only available on newer Python versions (introduced in Python 3.10).… This assertion is tightly coupled to the multi-line parenthesizedfrom ... import (...)… Similarly, this test hard-requiresruffto be installed aspython -m ruffand assumes a stable… These tests hard-requirepyrightto be installed and runnable aspython -m pyright. If the test… Import grouping depends onstdlib_module_names, which can differ across Python versions/builds,…
Review effort: Balanced
3b5aa19 to
191a6c8
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved naming regressions, generated-name collisions, and runtime/stub mismatches can break valid models and existing generated clients.
5 open issues
Preserve leading underscores for digit-prefixed member names · New Reserve runtime serialization method names from model members · New Escape modeled Unit to avoid collision with prelude Unit · New Preserve reserved-name escaping before uppercasing enum members · New Align unknown variant stub methods with runtime implementation · New
6 resolved since last review
Support Unit union members consistently at runtime Align stub and runtime member naming rules Handle explicit input and output traits in stub classification Prevent generated models from shadowing runtime helpers Prevent synthetic ServiceError name collisions Preserve canonical class identity across alias lookups
Review effort: Balanced
191a6c8 to
4e3f735
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
No open issues 🎉
5 resolved since last review
Escape modeled Unit to avoid collision with prelude Unit Reserve runtime serialization method names from model members Preserve leading underscores for digit-prefixed member names Align unknown variant stub methods with runtime implementation Preserve reserved-name escaping before uppercasing enum members
Review effort: Lite
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
Emitting docstrings as a single JSON-escaped string literal can easily produce very long physical… · New Within each section, module iteration relies on insertion order (sections[section].items()).… · New The88line-length cutoff is a hard-coded formatting policy that can drift from the repo’s… · New This assertion is now broad enough to allow false positives (e.g., matching an unrelated substring… · New
Review effort: Lite
There was a problem hiding this comment.
🟡 Changes recommended
Renamed union lookups regress for existing callers, and generated error stubs disagree with runtime message signatures and nullability.
2 open issues
4 resolved since last review
The88line-length cutoff is a hard-coded formatting policy that can drift from the repo’s… Within each section, module iteration relies on insertion order (sections[section].items()).… Emitting docstrings as a single JSON-escaped string literal can easily produce very long physical… This assertion is now broad enough to allow false positives (e.g., matching an unrelated substring…
Review effort: Balanced
4e3f735 to
2151b65
Compare
2151b65 to
836183c
Compare
6e1728f to
d2537c1
Compare
d2537c1 to
e04aef1
Compare
e04aef1 to
552a7fb
Compare
9499993 to
ca5d954
Compare
ca5d954 to
769018f
Compare
769018f to
d0838b2
Compare
d0838b2 to
5f8e76f
Compare
5f8e76f to
97a11c2
Compare



Issue #, if available:
#797
Description
Adds native generation of lazy runtime models and typed model stubs for standalone types packages.
This PR is stacked on #857.
Changes
models.pyandmodels.pyi.dir(), and pickling.Follow-up work
typesCLI pipeline.Compatibility
Existing
ModelRegistrycallers remain supported. New runtime arguments are optional and backward compatible.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.