Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bindings/python/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ clean:
[group('build')]
stub-gen: setup
@echo "{{ BOLD }}--- Generating Python type stubs ---{{ NORMAL }}"
@cargo run --quiet --manifest-path=../../dev/Cargo.toml -- generate -l python
Copy link
Copy Markdown
Contributor Author

@chitralverma chitralverma Oct 22, 2025

Choose a reason for hiding this comment

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

Overloads and Scheme generates as part of the stub-gen process

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.

This made me think that can we move stub_gen to odev instead.

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.

This made me think that can we move stub_gen to odev instead.

actually these are 2 separate processes that cannot be merged into the binding or in odev from what i understood.

  1. pyo3-stub-gen requires.... well, pyo3 which is available in python bindings. this step is responsible for generating most of the python stubs from rust code.
  2. the stuff in odev uses jinja templating because it has parsing logic of services code used for java as well. if odev had lib target then it could be used as a build dependency but still would be separate from pyo3 stuff.

@cargo run --quiet --bin stub_gen
@echo "{{ BOLD }}--- Formatting and fixing generated stubs ---{{ NORMAL }}"
-@bash -c 'shopt -s globstar; uv run ruff check **/*.pyi --fix --unsafe-fixes --silent || true'
Expand Down
21 changes: 18 additions & 3 deletions bindings/python/python/opendal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,25 @@
# ruff: noqa: D104
import builtins

from opendal._opendal import * # noqa: F403 # pyright:ignore
from opendal._opendal import ( # noqa: F403
capability,
exceptions,
file,
layers,
services,
types,
)
from opendal.operator import AsyncOperator, Operator # pyright:ignore

__version__: builtins.str

__all__ = _opendal.__all__ # noqa: F405 # pyright:ignore
__all__ += ["AsyncOperator", "Operator"] # pyright:ignore
__all__ = [
"capability",
"exceptions",
"file",
"layers",
"services",
"types",
"AsyncOperator",
"Operator",
Comment on lines +21 to +41
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.

makes things explicit

]
4 changes: 3 additions & 1 deletion bindings/python/python/opendal/file.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import collections.abc
import types
import typing

import typing_extensions

@typing.final
class AsyncFile:
r"""
Expand Down Expand Up @@ -111,7 +113,7 @@ class AsyncFile:
-----
A closed file cannot be used for further I/O operations.
"""
def __aenter__(self) -> typing.Self: ...
def __aenter__(self) -> typing_extensions.Self: ...
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.

typing.Self was not available in python 3.10 which opendal supports, so fixed this

def __aexit__(
self,
exc_type: type[builtins.BaseException] | None,
Expand Down
Loading
Loading