Skip to content

feat(bindings/python): Add stubs for Exception and Capability#6690

Merged
Xuanwo merged 4 commits intoapache:mainfrom
chitralverma:gen-stubs-1
Oct 18, 2025
Merged

feat(bindings/python): Add stubs for Exception and Capability#6690
Xuanwo merged 4 commits intoapache:mainfrom
chitralverma:gen-stubs-1

Conversation

@chitralverma
Copy link
Copy Markdown
Contributor

@chitralverma chitralverma commented Oct 17, 2025

Which issue does this PR close?

Parts from #6622

Rationale for this change

Partially Closes #6253

What changes are included in this PR?

  • Add pyo3-stub-gen
  • Stubs for Capability
  • Stubs for Exception(s)

Are there any user-facing changes?

No.

pub read: bool,
/// Indicates if conditional read operations using If-Match are supported.
/// If conditional read operations using If-Match are supported.
pub read_with_if_match: bool,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

these changes are primarily a fix for for line length lints reported by ruff.

Comment on lines +84 to +89
macro_rules! add_pymodule {
($py:expr, $parent:expr, $name:expr, [$($cls:ty),* $(,)?]) => {{
let sub_module = pyo3::types::PyModule::new($py, $name)?;
$(
sub_module.add_class::<$cls>()?;
)*
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will be useful for other stubs later.

setup:
@echo "{{ BOLD }}--- Installing/ validating dependencies ---{{ NORMAL }}"
@uv sync --managed-python --all-groups --all-extras --compile-bytecode --upgrade
@uv sync --managed-python --all-groups --all-extras --compile-bytecode
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

probably best to keep upgrades manual

@chitralverma chitralverma marked this pull request as ready for review October 17, 2025 11:39
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. releases-note/feat The PR implements a new feature or has a title that begins with "feat" labels Oct 17, 2025
@chitralverma
Copy link
Copy Markdown
Contributor Author

chitralverma commented Oct 17, 2025

@Xuanwo @messense 1st smaller stubs PR ready for your review.

Copy link
Copy Markdown
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Thank you, love this!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 18, 2025
fn main() -> Result<()> {
// `stub_info` is a function defined by `define_stub_info_gatherer!` macro.
let stub = _opendal::stub_info()?;
stub.generate()?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just put in build.rs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tried that but doesn't work. _opendal crate is needed.

https://github.com/Jij-Inc/pyo3-stub-gen?tab=readme-ov-file#generate-a-stub-file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@chitralverma chitralverma requested a review from Xuanwo October 18, 2025 05:01
@Xuanwo Xuanwo merged commit 9b11e7f into apache:main Oct 18, 2025
65 checks passed
@chitralverma chitralverma deleted the gen-stubs-1 branch October 18, 2025 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer 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.

new feature: Improve automatic stub generation for python bindings

2 participants