Emit Python namespace modules#146
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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".
| .filter(|sub| !sub.is_empty()) | ||
| .map(|sub| safe_python_module_segment(&sub.name)) | ||
| { | ||
| parts.push(format!("import {root}")); |
There was a problem hiding this comment.
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 👍 / 👎.
e5106e9 to
7ab5c35
Compare
|
📖 Documentation Preview: https://reflectapi-docs-preview-pr-146.partly.workers.dev Updated automatically from commit eb02044 |
Summary
myapi/...) plus_client.pyand_rebuild.pygenerated.pyas a flat compatibility facade over the real modulesreflectapi_runtimeinstead of duplicating helper definitions in generated filesValidation
cargo fmtcargo check -p reflectapi-clicargo test -p reflectapi-demo write_python_client -- --nocapturecargo test -p reflectapi-demo test_python_init_exports_client -- --nocapturecargo test -p reflectapi-demo test_python_destutter_collision_falls_back_to_original_name -- --nocapturePYTHONPATH=.:../../../reflectapi-python-runtime/src uv run pytest -qfromreflectapi-demo/clients/python(199 passed, 16 skipped)python3 -m compileall -q reflectapi-demo/clients/python reflectapi-python-runtime/src