Skip to content

Fix Python docstring escaping and namespace imports#157

Merged
hardbyte merged 5 commits into
mainfrom
brian/issue-156-python-docstring-escape
May 16, 2026
Merged

Fix Python docstring escaping and namespace imports#157
hardbyte merged 5 commits into
mainfrom
brian/issue-156-python-docstring-escape

Conversation

@hardbyte
Copy link
Copy Markdown
Contributor

@hardbyte hardbyte commented May 15, 2026

Summary

  • Escape embedded double quotes in generated Python docstrings so schema descriptions cannot break string literals.
  • Fix split Python namespace generation so child and peer namespace aliases are bound before generated model classes need them.
  • Defer Pydantic model rebuilds until package-level imports have loaded the generated modules.
  • Refresh the generated demo Python client and accepted snapshots affected by the deferred-model output.

Why

Generated Python clients could fail to import when schemas contained quote-heavy descriptions or when generated type hints crossed split namespace modules. The namespace issue shows up in larger clients where a model references a child or peer namespace before that namespace has been imported and rebound in the package.

Coverage

  • Regression coverage for docstring quote escaping.
  • Regression coverage for child namespace binding, peer namespace cycles, namespace aliases in generated references, builtin-shadowing namespace names such as input, and deferred model rebuilds.
  • Demo generated Python client snapshot plus Rust and Python snapshot updates to keep codegen drift checks honest.

Validation

  • GitHub Actions on ee6016f: Rust format, lint, and test; Python runtime tests; Python codegen smoke test; documentation examples; and documentation preview all passed. The docs deploy job is skipped as expected for this PR.
  • Local validation used while preparing the branch: cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, and importing the generated demo Python client.

Fixes #156.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

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

Updated automatically from commit 3512267

@hardbyte hardbyte marked this pull request as draft May 16, 2026 00:40
@hardbyte hardbyte changed the title Fix Python docstring quote escaping Fix Python docstring escaping and namespace imports May 16, 2026
@hardbyte hardbyte marked this pull request as ready for review May 16, 2026 02:22
@hardbyte hardbyte merged commit 2dda3c2 into main May 16, 2026
6 checks passed
@hardbyte hardbyte deleted the brian/issue-156-python-docstring-escape branch May 16, 2026 21:20
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 codegen: doc-comment ending in " produces invalid syntax

1 participant