Skip to content

Native types cli integration - #866

Merged
stobrien89 merged 5 commits into
developfrom
native-types-cli-integration
Oct 29, 2026
Merged

stobrien89 merged 5 commits into
developfrom
native-types-cli-integration

Conversation

@stobrien89

Copy link
Copy Markdown
Collaborator

Issue #, if available:
#797

Description

Completes the native standalone types pipeline by wiring schema and lazy model generation into smithy-python generate types.

  • Adds types-specific CLI settings and selection.
  • Generates package metadata, initializers, and typing markers.
  • Publishes output through the file manifest.
  • Adds CLI tests and a versioned codegen-output-py snapshot.

This PR is stacked on #863.

Follow-up work

  • Partition large generated schema and model modules.
  • Migrate standalone types artifacts from the Java generator.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@stobrien89
stobrien89 added this pull request to stack #864 October 24, 2026 17:45
@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch from 44b38e6 to 58549c6 Compare October 24, 2026 17:48
@stobrien89
stobrien89 requested a balanced review from Copilot October 24, 2026 17:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Accepted import package names can produce invalid distribution metadata, leaving generated packages unbuildable.

1 open issue
What changed in this PR

Completes the native standalone types CLI pipeline, building on lazy model generation in #863 and advancing the Python generator migration in #797.

Changes:

  • Connects types-specific CLI settings to selection, schema generation, and lazy model generation.
  • Generates package metadata, initializers, and typing markers, then publishes through the file manifest.
  • Adds CLI coverage and updates the versioned output snapshot.
File Description
scripts/​codegen-output-py/​generate.py Generates the snapshot through the CLI.
packages/​smithy-python/​tests/​unit/​test_selection.py Updates selection tests for working types generation.
packages/​smithy-python/​tests/​unit/​test_cli.py Tests package output, settings, and validation.
packages/​smithy-python/​src/​smithy_python/​types.py Assembles complete standalone types packages.
packages/​smithy-python/​src/​smithy_python/​cli.py Adds types options and invokes generation.
packages/​smithy-python/​README.md Documents available types generation.
codegen-output-py/​types/​src/​example_types/​py.typed Marks the generated package as typed.
codegen-output-py/​types/​src/​example_types/​_private/​__init__.py Initializes the private package.
codegen-output-py/​types/​src/​example_types/​__init__.py Exposes the generated package version.
codegen-output-py/​types/​README.md Adds generated package documentation.
codegen-output-py/​types/​pyproject.toml Adds build metadata and tooling settings.
codegen-output-py/​types/​.smithy-python-manifest.json Tracks the additional generated files.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Accepted package descriptions containing U+007F produce invalid TOML metadata, preventing the generated package from being built.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Invalid package versions pass CLI validation and produce metadata that prevents the generated package from being built or installed.

1 open issue
1 resolved since last review

Review effort: Balanced

@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch 2 times, most recently from df06c4c to c93800f Compare October 24, 2026 18:39
@stobrien89
stobrien89 requested a balanced review from Copilot October 24, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review identified no blocking issues in the CLI integration, package generation, or snapshot updates; project tests were not executed.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@stobrien89
stobrien89 marked this pull request as ready for review October 24, 2026 18:49
@stobrien89
stobrien89 requested a review from a team as a code owner October 24, 2026 18:49
@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch from c93800f to 3a125c1 Compare October 25, 2026 17:38
@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch from 3a125c1 to 73d6de9 Compare October 25, 2026 19:04
@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch from b3bef1e to 5220488 Compare October 25, 2026 23:16
@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch from 5220488 to 230257e Compare October 26, 2026 12:36
kuhe
kuhe previously approved these changes Oct 26, 2026
@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch from 230257e to cb5f272 Compare October 27, 2026 14:50
@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch 3 times, most recently from a02e67f to b3b28a8 Compare October 28, 2026 12:54
Base automatically changed from native-model-codegen to develop October 28, 2026 14:28
* add lazy model generation

* test streaming blob model generation

* support event stream unions in model generation

* exclude eventstream members from generated structs

* filter event stream members from generated stubs

* filter event streams from generated typecheck fixtures
@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch from b3b28a8 to 3dfcbe7 Compare October 28, 2026 14:29
kuhe
kuhe previously approved these changes Oct 28, 2026
@@ -0,0 +1 @@
from __future__ import annotations

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only need this in one or two files. I don't think it should be getting added unconditionally. Maybe we should just be responsible for adding it where we need it for now? Then add some smart detection in the future?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is coming from PythonWriter. I’ll make it opt-in and only add it to files that need deferred annotations

@jonathan343 jonathan343 Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need it anymore now that we load models lazily. Can we remove the future_annotations option all together (and references to it from designs)? I'd rather add it later if we ever do need it as opposed to carrying this option around we never use. Or it's just something we should write as generated code the way we should another import

Comment thread codegen-output-py/types/pyproject.toml Outdated
Comment on lines +28 to +34
reportPrivateUsage = false
reportUnusedFunction = false
reportUnusedVariable = false
reportUnnecessaryComparison = false
reportUnusedClass = false
enableExperimentalFeatures = true
exclude = ["**/models.py"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[not blocking] I know these are probably inherited from the java generator, but do you know why they're needed here? A few of these like AreportUnusedFunction and reportUnnecessaryComparison seem weird. I also don't get exclude = ["**/models.py"].

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked these individually and they aren’t needed. the models.py exclusion is hiding a computed __all__ warning, so I’ll fix that and remove the inherited settings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need enableExperimentalFeatures = true later. So we can either keep that one now or add it later when it comes up. I don't think it's something we can forget to do, its something we'll need to do so later seems fine

Comment thread packages/smithy-python/pyproject.toml Outdated
]
dependencies = []
dependencies = [
"packaging",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel good about taking a dependency on packaging just for an error and version validation (e.g. from packaging.version import InvalidVersion, Version). Is this something we can do with a regex or something?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. I’ll validate the version format with a conservative regex and drop the dependency instead of supporting every possible PEP 440 form

help="Smithy selector used to narrow generated declaration roots.",
)
types.add_argument(
"--generate-inputs-and-outputs",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - Thoughts on using something like --include-operation-io instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--include-operation-io reads better to me. I’ll rename it

jonathan343
jonathan343 previously approved these changes Oct 28, 2026

@jonathan343 jonathan343 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I'd like to see future_annotations removed, but not blocking.

@stobrien89
stobrien89 force-pushed the native-types-cli-integration branch from 4f01769 to 573ffa8 Compare October 28, 2026 23:17
@stobrien89
stobrien89 merged commit 8b6572c into develop Oct 29, 2026
11 checks passed
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.

4 participants