erickguan commented on code in PR #6086:
URL: https://github.com/apache/opendal/pull/6086#discussion_r2116325346
##########
bindings/python/pyproject.toml:
##########
@@ -70,8 +70,22 @@ cache-keys = [
{ file = "../../core/**/*.rs" },
]
+[tool.ruff]
+line-length = 88
Review Comment:
I would vote for 120 because our screen can view these many characters with
ease.
##########
bindings/python/python/opendal/__init__.pyi:
##########
@@ -191,64 +182,54 @@ class AsyncOperator(_Base):
Example:
```python
import opendal
+
op = opendal.AsyncOperator("s3", bucket="bucket", region="us-east-1")
await op.write("hello.txt", b"hello world")
```
"""
def __init__(self, scheme: str, **options: Any) -> None: ...
- def layer(self, layer: Layer) -> "AsyncOperator": ...
- async def open(self, path: PathBuf, mode: str) -> AsyncFile:
+ def layer(self, layer: Layer) -> AsyncOperator: ...
+ async def open(self, path: PathBuf, mode: str, **options: Any) ->
AsyncFile:
"""Open a file at the given path for reading or writing.
Args:
path (str|Path): The path to the file.
mode (str): The mode to open the file. Can be "rb" or "wb".
+ **options (any): Reader options if mode == "rb" and
+ writer options if mode == "wb".
+ See the documentation `reader_with` and `writer_with` for more
details.
Returns:
A file-like object that can be used to read or write the file.
Example:
```python
import opendal
+
op = opendal.AsyncOperator("s3", bucket="bucket",
region="us-east-1")
async with await op.open("hello.txt", "wb") as f:
await f.write(b"hello world")
```
"""
- async def read(self, path: PathBuf) -> bytes:
+ async def read(self, path: PathBuf, **options: Any) -> bytes:
"""Read the content of the object at the given path.
Args:
path (str|Path): The path to the object.
+ **options (any): Reader options.
+ See the documentation `reader_with` for more details.
Returns:
The content of the object as bytes.
"""
- async def write(
- self,
- path: PathBuf,
- bs: bytes,
- *,
- append: bool = ...,
- chunk: int = ...,
- content_type: str = ...,
- content_disposition: str = ...,
- cache_control: str = ...,
- ) -> None:
+ async def write(self, path: PathBuf, bs: bytes, **options: Any) -> None:
"""Write the content to the object at the given path.
Args:
path (str|Path): The path to the object.
bs (bytes): The content to write.
- append (bool): Whether to append the content to the object.
- Defaults to False.
- chunk (int): The chunk size for writing. Defaults to write all.
- content_type (str): The content type of the object.
- Defaults to None.
- content_disposition (str): The content disposition of the object.
- Defaults to None.
- cache_control (str): The cache control of the object.
- Defaults to None.
+ **options (any): Reader options.
+ See the documentation `reader_with` for more details.
Review Comment:
This is off.
##########
bindings/python/python/opendal/__init__.pyi:
##########
@@ -52,58 +54,48 @@ class Operator(_Base):
Returns:
The new operator with the layer added.
"""
- def open(self, path: PathBuf, mode: str) -> File:
+ def open(self, path: PathBuf, mode: str, **options: Any) -> File:
"""Open a file at the given path for reading or writing.
Args:
path (str|Path): The path to the file.
mode (str): The mode to open the file. Can be "rb" or "wb".
+ **options (any): Reader options if mode == "rb" and
+ writer options if mode == "wb".
+ See the documentation `reader_with` and `writer_with` for more
details.
+
Returns:
A file-like object that can be used to read or write the file.
Example:
```python
import opendal
+
op = opendal.Operator("s3", bucket="bucket", region="us-east-1")
with op.open("hello.txt", "wb") as f:
f.write(b"hello world")
```
"""
- def read(self, path: PathBuf) -> bytes:
+ def read(self, path: PathBuf, **options: Any) -> bytes:
"""Read the content of the object at the given path.
Args:
path (str|Path): The path to the object.
+ **options (any): Reader options.
+ See the documentation `reader_with` for more details.
Returns:
The content of the object as bytes.
"""
- def write(
- self,
- path: PathBuf,
- bs: bytes,
- *,
- append: bool = ...,
- chunk: int = ...,
- content_type: str = ...,
- content_disposition: str = ...,
- cache_control: str = ...,
- ) -> None:
+ def write(self, path: PathBuf, bs: bytes, **options: Any) -> None:
"""Write the content to the object at the given path.
Args:
path (str|Path): The path to the object.
bs (bytes): The content to write.
- append (bool): Whether to append the content to the object.
- Defaults to False.
- chunk (int): The chunk size for writing. Defaults to write all.
- content_type (str): The content type of the object.
- Defaults to None.
- content_disposition (str): The content disposition of the object.
- Defaults to None.
- cache_control (str): The cache control of the object.
- Defaults to None.
+ **options (any): Writer options.
+ See the documentation `writer_with` for more details.
Review Comment:
Which `writer_with`? Although the documentation for options are incomplete,
I think it is better to keep them.
- Because OpenDAL aims to build ergonomic Python bindings.
- The `writer_with` context is not available in Python documentation.
- Maybe we can have a link to the crate doc in the meantime.
##########
bindings/python/python/opendal/__init__.pyi:
##########
@@ -52,58 +54,48 @@ class Operator(_Base):
Returns:
The new operator with the layer added.
"""
- def open(self, path: PathBuf, mode: str) -> File:
+ def open(self, path: PathBuf, mode: str, **options: Any) -> File:
"""Open a file at the given path for reading or writing.
Args:
path (str|Path): The path to the file.
mode (str): The mode to open the file. Can be "rb" or "wb".
+ **options (any): Reader options if mode == "rb" and
+ writer options if mode == "wb".
+ See the documentation `reader_with` and `writer_with` for more
details.
+
Returns:
A file-like object that can be used to read or write the file.
Example:
```python
import opendal
+
op = opendal.Operator("s3", bucket="bucket", region="us-east-1")
with op.open("hello.txt", "wb") as f:
f.write(b"hello world")
```
"""
- def read(self, path: PathBuf) -> bytes:
+ def read(self, path: PathBuf, **options: Any) -> bytes:
"""Read the content of the object at the given path.
Args:
path (str|Path): The path to the object.
+ **options (any): Reader options.
+ See the documentation `reader_with` for more details.
Review Comment:
Which `reader_with`? :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]