You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "trim21 (via GitHub)" <gi...@apache.org> on 2026/08/01 16:18:04 UTC
[PR] fix(bindings/python): annotate **kwargs types in generated stubs [opendal]
trim21 opened a new pull request, #8012:
URL: https://github.com/apache/opendal/pull/8012
# Which issue does this PR close?
N/A
# Rationale for this change
Untyped `**kwargs` in the PyO3 signatures produce bare `**kwargs` in the generated `.pyi` stubs, which trips type checkers that report unknown parameter types (e.g. pyright's `reportUnknownParameterType`).
# What changes are included in this PR?
Annotate the kwargs in the `#[pyo3(signature = ...)]` attributes in `bindings/python/src/operator.rs`:
- `Operator.__new__` / `AsyncOperator.__new__` and `from_uri` accept string-only service configs (`HashMap<String, String>`), so they use `**kwargs: "str"`.
- `open` forwards kwargs to `ReadOptions` / `WriteOptions`, whose fields mix `str`, `int`, `bool` and `dict[str, str]`, so it keeps `**kwargs: "Any"`.
`python/opendal/operator.pyi` is regenerated accordingly.
# Are there any user-facing changes?
Stubs only; runtime behavior is unchanged. The generated stubs now carry types for `**kwargs`, so type checkers no longer warn about unknown parameter types on `__new__`, `from_uri` and `open`.
# AI Usage Statement
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714341638
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I think you misunderstand what type annotation `T` for `**kwargs: T` mean, it means kwargs is a `dict[str, T]`, so a str here make kwargs match `HashMap<String, String>`, the expected caller is still `from_uri(uri='...', option='...')`
if we have `call(**kwargs: dict[str, str])`, that means caller need to call it with `call(option={'...': '...'})`, the actually expected calling `call(option='...')` is forbidden.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714341638
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I think you misunderstand what type annotation `T` for `**kwargs: T` mean, it means kwargs is a `Optional[dict[str, T]]`, so a str here make kwargs match `Option<HashMap<String, String>>`
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714341638
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I think you misunderstand what type annotation `T` for `**kwargs: T` mean, it means kwargs is a `dict[str, T]`, so a str here make kwargs match `HashMap<String, String>`
if we have `call(**kwargs: dict[str, str])`, that means you need to call it with `call(option={'...': '...'}`
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan merged PR #8012:
URL: https://github.com/apache/opendal/pull/8012
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714341638
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I think you misunderstand what type annotation `T` for `**kwargs: T` mean, it means kwargs is a `dict[str, T]`, so a str here make kwargs match `HashMap<String, String>`, the expected caller is still `from_uri(uri='...', option='...')`
if we have `call(**kwargs: dict[str, str])`, that means you need to call it with `call(option={'...': '...'}`
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714756197
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I see. I learnt a new thing!
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714344029
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
and Yes I miss uri str type here
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714035668
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I know you wrote about kwargs being str. But uri is either a string, and this map allows additional overrides. Either remove this kwargs or consider accepting an optional dict.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714341638
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I think you misunderstand what type annotation `T` for `**kwargs: T` mean, it means kwargs is a `dict[str, T]`, so a str here make kwargs match `HashMap<String, String>`
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
<img width="1952" height="417" alt="image" src="https://github.com/user-attachments/assets/1bc87a54-75e2-44bc-9a7a-0558a65fb77f" />
<img width="1992" height="503" alt="image" src="https://github.com/user-attachments/assets/afbd8c85-cab9-48d1-9ea9-59d0710171ec" />
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714344029
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
and it has nothing to do with uri type here
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714341638
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I think you misunderstand what type annotation `T` for `**kwargs: T` mean, it means kwargs is a `dict[str, T]`, so a str here make kwargs match `HashMap<String, String>`, the expected caller is still `from_uri(uri='...', option='...')`
if we have `call(**kwargs: dict[str, str])`, that means you need to call it with `call(option={'...': '...'})`, `call(option='...')` is forbidden.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(bindings/python): annotate `**kwargs` types in generated stubs [opendal]
Posted by "trim21 (via GitHub)" <gi...@apache.org>.
trim21 commented on code in PR #8012:
URL: https://github.com/apache/opendal/pull/8012#discussion_r3714341638
##########
bindings/python/src/operator.rs:
##########
@@ -242,7 +242,7 @@ impl Operator {
/// op = opendal.Operator.from_uri(f"s3://bucket/path?{query}")
/// ```
#[classmethod]
- #[pyo3(signature = (uri, **kwargs))]
+ #[pyo3(signature = (uri, **kwargs: "str"))]
Review Comment:
I think you misunderstand what type annotation `T` for `**kwargs: T` mean, it means kwargs is a `dict[str, T]`, so a str here make kwargs match `HashMap<String, String>`, the expected caller is still `from_uri(uri='...', option='...')`
if we have `from_uri(uri: str, **kwargs: dict[str, str])`, that means caller need to call it with `from_uri(uri='...', option={'...': '...'})`, the actually expected calling `from_uri(uri='...', option='...')` is forbidden.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org