Skip to content

fix(python): update extension checkout imports#119

Closed
ShuoRen-TT wants to merge 2 commits into
Universal-Commerce-Protocol:mainfrom
ShuoRen-TT:agent/fix-python-server-ap2-import
Closed

fix(python): update extension checkout imports#119
ShuoRen-TT wants to merge 2 commits into
Universal-Commerce-Protocol:mainfrom
ShuoRen-TT:agent/fix-python-server-ap2-import

Conversation

@ShuoRen-TT

Copy link
Copy Markdown
Contributor

Summary

Fixes #118.

The Python Flower Shop server now imports composed extension Checkout models from the SDK's generated namespace paths under dev.ucp.shopping, matching the current python-sdk output after Universal-Commerce-Protocol/python-sdk#48.

What changed

  • Updated AP2, buyer consent, discount, and fulfillment Checkout imports in rest/python/server/models.py.
  • Updated the same imports in rest/python/server/integration_test.py.
  • Added server_import_test.py to smoke-test importing server.py with the current SDK models.

Why

Current samples main imports Checkout from top-level extension packages such as ucp_sdk.models.schemas.shopping.ap2_mandate. After python-sdk#48, those top-level modules no longer export the composed Checkout; the classes live under ...dev.ucp.shopping. Fresh setup following the README therefore fails before the server starts.

Validation

  • Reproduced the original ImportError before the change.
  • uv run --directory rest/python/server python - <<'PY' ... import server ... PY
  • uv run --directory rest/python/server pytest server_import_test.py
  • uv run --directory rest/python/server ruff format --check models.py integration_test.py server_import_test.py
  • uv run --directory rest/python/server ruff check models.py integration_test.py server_import_test.py
  • uv run --directory rest/python/server python -m py_compile models.py integration_test.py server_import_test.py server.py
  • Initialized the Flower Shop sample DB and verified the server starts and GET /.well-known/ucp returns 200 on port 8183.
  • Relevant pre-commit hooks passed: ruff, ruff-format, trailing-whitespace, end-of-file-fixer, check-added-large-files, detect-private-key, codespell.

Note: full uvx pre-commit run --files ... could not complete because the Prettier hook failed while installing npm dependency tiny-levenshtein@^1.1.0, unrelated to these Python files.

@ShuoRen-TT
ShuoRen-TT marked this pull request as ready for review July 7, 2026 17:42
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Jul 7, 2026
@ShuoRen-TT

Copy link
Copy Markdown
Contributor Author

Hi maintainers, this PR is ready for review.

It fixes #118 by updating the Python sample server to import the generated extension Checkout models from the current SDK namespace. This should also unblock the conformance CI failure currently seen in Universal-Commerce-Protocol/conformance#47.

Local validation is listed in the PR body, including server import, ruff, py_compile, and a real Flower Shop server startup check.

@damaz91 damaz91 added status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Jul 10, 2026
@damaz91

damaz91 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Thanks for flagging this. We fixed the Python SDK in Universal-Commerce-Protocol/python-sdk#29 - the server should be able to start now, please verify and feel free to reopen if that still doesn't work. Thanks again!

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.

Python server won't start when following the README: samples main is incompatible with python-sdk main (ap2_mandate.Checkout removed in sdk #48)

2 participants