Skip to content

feat(bindings/python): generate Capability from core - #9123

Merged
Xuanwo merged 1 commit into
apache:mainfrom
chitralverma:feat/generate-python-capability
Nov 27, 2026
Merged

Xuanwo merged 1 commit into
apache:mainfrom
chitralverma:feat/generate-python-capability

Conversation

@chitralverma

@chitralverma chitralverma commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #9122.

Rationale for this change

The Python Capability was copied from core by hand and had fallen behind: it exposed 50 of the 98 core fields, with reworded docs. Java (#8644) and .NET (#8146) already generate Capability from core through dev/src/generate/capability.rs. This PR does the same for Python.

What changes are included in this PR?

  • dev/src/generate/python.rs + dev/src/generate/python/capability_rs.j2: generate -l python now renders bindings/python/src/capability.rs (the struct and Capability::new) from core/core/src/types/capability.rs, using core's doc comments.
  • bindings/python/python/opendal/capability.pyi: regenerated with just stub-gen.
  • bindings/python/ruff.toml: ignore E501 for the generated capability.pyi, the same as the existing rule for the generated config.py, because core docs are copied verbatim.
  • .github/workflows/ci_bindings_python.yml: also run the Python binding CI when dev/src/generate/** changes.
  • Class docs note that the flags describe the underlying operator, so a flag can be true even when the binding has no matching method (for example restore).

The existing check_generated job in ci_odev.yml already runs generate -l python and cargo fmt, then fails on diff, and ci_bindings_python.yml regenerates the stubs and fails on diff, so future drift from core gets caught.

Are there any user-facing changes?

Yes, additions only. Operator.capability() now exposes all 98 core fields, 48 more than before (for example compose*, restore*, *_with_if_version_match, stat_with_override_*, list_with_glob, read_with_checksum, write_with_checksum). The 50 existing properties keep their names and types. Field docstrings now match core's wording.

Breaking changes

AI Usage Statement

  • Harness: Jcode | Model: Claude Opus 5.5 | Effort: medium | Role: Implemented the generator and template, regenerated stubs, ran the Python tests (memory service), and drafted the issue and this description. I reviewed the changes.
  • Harness: Claude Code (via T3 Code) | Model: Claude Opus 5.5 | Effort: high | Role: Rebased onto main, regenerated capability.rs and the stubs for the core fields added since (read_with_checksum, write_with_checksum), squashed the branch, and synced this description. Ran the generators, just stub-gen, just lint, just test-typing, and the Python tests against the memory service locally.

@Xuanwo

Xuanwo commented Nov 26, 2026

Copy link
Copy Markdown
Member

Please complete the Jcode entry in the PR description with the model and reasoning effort used. If Jcode did not expose an effort setting, please say so. AI Usage Statement requirements

I checked the Python stubs at 93740882: all 50 existing properties retain their names and types, and the generator adds 46. One optional clarification for the Capability class docstring: these flags describe the underlying OpenDAL operator. For example, cap.restore can be true even though the Python binding has no restore() method.

AI-generated review comment.

@chitralverma

Copy link
Copy Markdown
Contributor Author

I checked the Python stubs at 93740882

this is done and updates have been made.

@github-actions github-actions Bot added bindings/python releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:XL This PR changes 500-999 lines, ignoring generated files. labels Nov 26, 2026
Render bindings/python/src/capability.rs from core/core/src/types/capability.rs
via the shared dev/src/generate/capability.rs parser, so the Python binding
exposes every core capability field with its core docs. The .pyi stub is
derived by just stub-gen. The class docs note that the flags describe the
underlying operator, so a flag can be true without a matching Python method.

Run the Python binding CI when generators under dev/src/generate change.

Part of apache#9122.

Signed-off-by: Chitral Verma <chitralverma@gmail.com>
@chitralverma
chitralverma force-pushed the feat/generate-python-capability branch from 1ace801 to 3c5d58c Compare November 27, 2026 08:37
@Xuanwo
Xuanwo merged commit 59faed4 into apache:main Nov 27, 2026
59 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bindings/python releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants