Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Emit Python namespace modules#146

Merged
hardbyte merged 7 commits into
mainfrom
brian/python-real-submodules
May 11, 2026
Merged

Emit Python namespace modules#146
hardbyte merged 7 commits into
mainfrom
brian/python-real-submodules

Conversation

@hardbyte
Copy link
Copy Markdown
Contributor

@hardbyte hardbyte commented May 10, 2026

Summary

  • emit Python codegen as real schema-derived namespace packages (for the demo schema this is myapi/...) plus _client.py and _rebuild.py
  • keep generated.py as a flat compatibility facade over the real modules
  • move externally tagged enum parse/serialize helpers into reflectapi_runtime instead of duplicating helper definitions in generated files
  • update CLI/demo writing for nested generated files and refresh Python pytest expectations to current generated model shapes

Validation

  • cargo fmt
  • cargo check -p reflectapi-cli
  • cargo test -p reflectapi-demo write_python_client -- --nocapture
  • cargo test -p reflectapi-demo test_python_init_exports_client -- --nocapture
  • cargo test -p reflectapi-demo test_python_destutter_collision_falls_back_to_original_name -- --nocapture
  • PYTHONPATH=.:../../../reflectapi-python-runtime/src uv run pytest -q from reflectapi-demo/clients/python (199 passed, 16 skipped)
  • python3 -m compileall -q reflectapi-demo/clients/python reflectapi-python-runtime/src

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.

Once credits are available, reopen this pull request to trigger a review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82783f8f25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread reflectapi/src/codegen/python.rs Outdated
.filter(|sub| !sub.is_empty())
.map(|sub| safe_python_module_segment(&sub.name))
{
parts.push(format!("import {root}"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use relative imports inside the generated package

When the Python output directory is consumed as a package (it now emits __init__.py and docs describe package-style output), importing it via its parent directory executes _client.py, which emits absolute imports such as import myapi and from _rebuild import .... Those names only resolve if the generated package directory itself is placed on sys.path; with normal package usage (for example an output directory named api_client imported as import api_client), api_client.myapi and api_client._rebuild exist but top-level myapi/_rebuild do not, so the import fails before any client can be used. Generate package-internal imports with a leading dot (and adjust references accordingly) for files meant to live under the package.

Useful? React with 👍 / 👎.

@hardbyte hardbyte force-pushed the brian/python-real-submodules branch from e5106e9 to 7ab5c35 Compare May 11, 2026 00:54
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 11, 2026

📖 Documentation Preview: https://reflectapi-docs-preview-pr-146.partly.workers.dev

Updated automatically from commit eb02044

@hardbyte hardbyte merged commit 323805d into main May 11, 2026
5 checks passed
@hardbyte hardbyte deleted the brian/python-real-submodules branch May 11, 2026 01:44
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.

1 participant