SAMARTHJAISWAL opened a new pull request, #8525:
URL: https://github.com/apache/opendal/pull/8525
# Which issue does this PR close?
Closes #8515.
# Rationale for this change
`AsyncFile.__aexit__` returns a future at runtime (it calls `close`), but
its signature says `-> None`. Type checkers therefore reject every `async with
await op.open(...)` block, for example ty reports `invalid-context-manager`.
# What changes are included in this PR?
- `bindings/python/src/file.rs`: the `__aexit__` signature now returns
`collections.abc.Awaitable[None]`, the same as `close`.
- `bindings/python/python/opendal/file.pyi`: the same change in the
committed stub.
I edited the stub by hand to match and did not run `just stub-gen`.
I checked a small `async with await op.open("file", "rb") as f:` example
with ty against the stubs: it reports `invalid-context-manager` before the
change and passes after it. I did not add a test, because `ty check` only
covers `python/opendal` and the tests are not type-checked.
# Are there any user-facing changes?
Only the type annotation. Runtime behaviour is unchanged.
# Breaking changes
# AI Usage Statement
- Harness: Claude Code
- Model: Claude Fable 5.2
- Effort: default
- Role: located the wrong annotation and wrote the two-line change and this
description. I reviewed the change and ran the ty check myself.
--
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]