fix: update Python SDK schemas for UCP release 2026-01-23#21
Conversation
Change-Id: I7400c7bd870e3505d5b8c9a9e179d305c65bb3dc
Change-Id: I4583f94619b072eb7aff0fc28f040d0b2fd30de3
Change-Id: Ib7d74192095677f98a79906f5ed2d69dc16e1520
Change-Id: I2e70bdaf468ef7663b6c8e7542f2acf822d9df06
Change-Id: Id33ccc029b86af2486c82dc85d8bb12b3c55c680
Change-Id: Ia518ec52de6906da7262f7a76704a676a6318c40
Change-Id: I113bf00366152f552140a0f6410f738813c44007
Change-Id: I8413a4ad2e3886df6684ff7f654faa2ed2a95043
Change-Id: I63be54dcfc253861c05a9143483fd73a98f2c232
Change-Id: If59a9d92e40d71bc9d69d171b7020310ee9e26a1
Change-Id: I79bccca52f3a1d9d721c6a6f10d128f544411840
Change-Id: I0ac8995f2d15caa97ce57e9a1be574f012d5b9f2
* update SDK to 2026-01-23 * add init at the base level * update README * add request specific classes * fix schema generation * fix schema generation * Update pyproject.toml * update pre-processing to correctly handle self-reference * fix * sync * address comments Change-Id: I7400c7bd870e3505d5b8c9a9e179d305c65bb3dc * add win32 specific check for paths Change-Id: I4583f94619b072eb7aff0fc28f040d0b2fd30de3 * remove preprocessing Change-Id: Ib7d74192095677f98a79906f5ed2d69dc16e1520 * update readme Change-Id: I2e70bdaf468ef7663b6c8e7542f2acf822d9df06 * re-run of generate_models.sh Change-Id: Id33ccc029b86af2486c82dc85d8bb12b3c55c680 * move ruff config Change-Id: Ia518ec52de6906da7262f7a76704a676a6318c40 * delete temp files Change-Id: I113bf00366152f552140a0f6410f738813c44007 * add LICENSE reference Change-Id: I8413a4ad2e3886df6684ff7f654faa2ed2a95043 * add preprocessing to handle request type class generation Change-Id: I63be54dcfc253861c05a9143483fd73a98f2c232 * change naming convention Change-Id: If59a9d92e40d71bc9d69d171b7020310ee9e26a1 * update preprocessing to include more request types Change-Id: I79bccca52f3a1d9d721c6a6f10d128f544411840 * delete ucp Change-Id: I0ac8995f2d15caa97ce57e9a1be574f012d5b9f2
Change-Id: I50829c0f09a4e05bfcbd7ec53286a63f09e28cea
Change-Id: I769a18ba3fe14325911c4194da12f3f97ece46ea
Change-Id: Ie9d5ab50422b82efbf558cdd179ed3485cfde60f
Change-Id: I6d267035aa48aa5460c31a3764eab5a460026510
Change-Id: Ie4dd0293179c4387863dd4e66f51dde8443dd9b3
Change-Id: I07006baf7aa7cd08b2ab723589b9373379e03d31
Change-Id: I66ced7ef4174da92816eb6cb50338a55ea68f67a
Change-Id: I5b8706c16740edca1b1c3a2b72ea5125b34ae0b5
Change-Id: Ia8d329b4b737a45a2a05fab59fc4c9e3c2a52efe
Change-Id: Ib54ea5de5be7ff65cf06ff14d0f90cd328636f6c
Change-Id: Id43fd21393ce74d863eca3407a967bb1d01e950d
Change-Id: Ia88b6b2c128a57a4499e3eb0fa5437ddbaaf535a
Change-Id: I2dc40c7312c2dd22fc3d03d426b7c5359938611c
Change-Id: I438b93b4adb693018f43428bf8e658bb5809ab74
Change-Id: I7112ad7d531eee33ea48de1c2871b0b92afe5e02
- Break monolithic `merge_all_of_to_node` down into smaller helper functions. - Simplify `generate_variants` by extracting single variant creation logic. - Introduce explicit ValueError when `entity_definition` is missing from `ucp.json`. - Refactor `fix_metadata_structure` into a purely functional `normalize_metadata_schemas`. - Addressed comments on PR 16.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the Universal Commerce Protocol (UCP) Python SDK's schema generation process. It introduces a robust preprocessing step that normalizes complex JSON schemas, flattens inheritance, and creates operation-specific model variants, resulting in a more streamlined and maintainable codebase. The changes also update the model generation script to support versioning and align project configurations with modern Python development standards. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new schema preprocessing script (preprocess_schemas.py) and refactors the model generation workflow. Key changes include updates to generate_models.sh for improved UCP repository cloning, schema preprocessing, and post-generation formatting with ruff. The README.md installation instructions have been simplified, and pyproject.toml has been updated to reflect new ruff configurations and project metadata. Numerous generated model files have been updated or removed to align with the new schema processing and Pydantic v2 compatibility. Review feedback suggests addressing a potential error masking issue in the generate_models.sh script's ruff check command, clarifying installation instructions in README.md, and explicitly specifying UTF-8 encoding in preprocess_schemas.py for JSON file operations to enhance robustness.
- Run pre-commit to fix trailing whitespaces and formatting. - Replace bare print statements in preprocess script with sys logging to fix ruff T201.
4195ab7 to
4825532
Compare
- Pass exit codes during code generation by removing masked error trap. - Fix README.md instructions for navigating before setup. - Add explicit utf-8 encodings when opening JSON files.
Overview
The
python-sdkwas previously stuck on the older2026-01-11release. This Pull Request updates the SDK tooling and regenerates the Pydantic models to ensure full compatibility with the (currently latest) Universal Commerce Protocol release: UCP 2026-01-23 Specification.Detailed Changes
Documentation & Developer Experience
ruff formatoutput pipeline insidegenerate_models.shto prevent masking terminal lint failures with silentgrepfallback logic.Schema Pre-Processor Architecture (
preprocess_schemas.py)This PR significantly rewrites the schema pre-processor logic to improve maintainability and generate safer representations used by
datamodel-codegen. Key updates include:merge_all_of_to_nodefunction into modular helper functions (_process_all_of_item,_apply_merged_state) reducing unsafe variable mutations and nested conditions.fix_metadata_structureinto a purely functionalnormalize_metadata_schemaswhich performs mutations exclusively in memory instead of committing midway disk writes.ValueErrorrather than silently swallowing issues ifentity_definitionmappings are inadvertently empty.generate_variantsroutine by splitting out operation iterations (e.g.,createvsupdate) into_create_single_variantbuilders.Lints & Formats
ruffCompliance Fixes: Resolved Python stylistic debt surfaced bypre-commit, including fixing trailing whitespace limits, adjusting EOF sequences, and convertingopen()calls toPath().open(encoding="utf-8")(PTH123). Also removed built-inprinttracing points with generic I/O stream writes (sys.stdout/sys.stderr) to comply with code-quality metrics.ucp_prop), Pydantic models likePlatformSchema,BusinessSchema, andResponseCheckoutSchemafinally generate correctly to extendBaseclasses natively rather than rendering as disconnected blobs.