This is an automated email from the ASF dual-hosted git repository.
PsiACE pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 65a70132a chore(bindings/python): replace pyright with ty for type
checking (#7813)
65a70132a is described below
commit 65a70132a321efd2ca164180f277b5f4a003e1df
Author: Chitral Verma <[email protected]>
AuthorDate: Mon Jun 22 18:25:59 2026 +0530
chore(bindings/python): replace pyright with ty for type checking (#7813)
Switch the Python binding from pyright/basedpyright to ty (astral-sh/ty).
Remove pyrightconfig.json, add a [tool.ty.src] config plus the ty lint
dependency in pyproject.toml, and run ty check from the lint recipe.
Drop the now-unnecessary pyright:ignore in __init__.py and update a
type-checker reference in upgrade.md.
---
bindings/python/justfile | 2 ++
bindings/python/pyproject.toml | 8 +++++++-
bindings/python/pyrightconfig.json | 7 -------
bindings/python/python/opendal/__init__.py | 2 +-
bindings/python/upgrade.md | 2 +-
bindings/python/uv.lock | 31 +++++++++++++++++++++++++++++-
6 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/bindings/python/justfile b/bindings/python/justfile
index 8338ff831..932bd50e3 100644
--- a/bindings/python/justfile
+++ b/bindings/python/justfile
@@ -118,6 +118,8 @@ lint: setup
@cargo clippy -- -D warnings -D clippy::dbg_macro -A
clippy::incompatible_msrv
@echo "{{ BOLD }}--- Running Python linter (Ruff) ---{{ NORMAL }}"
@uv run ruff check
+ @echo "{{ BOLD }}--- Running Python type checker (ty) ---{{ NORMAL }}"
+ @uv run ty check
# Format all code (Rust, Python, etc.)
[group('lint')]
diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml
index 79f3106e1..a1e2917dd 100644
--- a/bindings/python/pyproject.toml
+++ b/bindings/python/pyproject.toml
@@ -48,7 +48,7 @@ benchmark = [
]
dev = ["maturin>=1.8.2"]
docs = ["mkdocs", "mkdocs-material", "mkdocstrings[python]", "mkdocs-jupyter"]
-lint = ["ruff>=0.9.10"]
+lint = ["ruff>=0.9.10", "ty>=0.0.51"]
test = [
"pytest>=8.3.5",
"pytest-asyncio>=0.25.3",
@@ -62,6 +62,12 @@ module-name = "opendal._opendal"
python-source = "python"
strip = true
+[tool.ty.src]
+include = ["python/opendal"]
+# Generated stubs target the abi3 floor (cp311); skip them so the `>=3.10`
+# `requires-python` does not flag `typing.Self` and other newer stdlib symbols.
+exclude = ["python/opendal/*.pyi"]
+
[tool.uv]
cache-keys = [
{ file = "pyproject.toml" },
diff --git a/bindings/python/pyrightconfig.json
b/bindings/python/pyrightconfig.json
deleted file mode 100644
index c792ffe00..000000000
--- a/bindings/python/pyrightconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "include": ["python/opendal/"],
- "ignore": [
- "python/opendal/*.pyi"
- ],
- "reportIgnoreCommentWithoutRule": false
-}
diff --git a/bindings/python/python/opendal/__init__.py
b/bindings/python/python/opendal/__init__.py
index 77f0687c6..ec40a0006 100644
--- a/bindings/python/python/opendal/__init__.py
+++ b/bindings/python/python/opendal/__init__.py
@@ -34,7 +34,7 @@ else:
types,
)
-from opendal.operator import AsyncOperator, Operator # pyright:ignore
+from opendal.operator import AsyncOperator, Operator
__all__ = [
"capability",
diff --git a/bindings/python/upgrade.md b/bindings/python/upgrade.md
index bf15c936e..7175465fe 100644
--- a/bindings/python/upgrade.md
+++ b/bindings/python/upgrade.md
@@ -39,7 +39,7 @@ Both `Operator.full_capability()` and
`AsyncOperator.full_capability()` have bee
## Breaking change: Service identifiers now have typed enums
-The constructors for `Operator` / `AsyncOperator` provide overloads that
accept `opendal.services.Scheme` members. While plain strings are still
accepted at runtime, type checkers (pyright/mypy) expect the new enum values.
Migrate code bases that relied on importing the old `Scheme` enum from
`opendal` to `from opendal import services` and use `services.Scheme.<NAME>`.
+The constructors for `Operator` / `AsyncOperator` provide overloads that
accept `opendal.services.Scheme` members. While plain strings are still
accepted at runtime, type checkers (ty/mypy) expect the new enum values.
Migrate code bases that relied on importing the old `Scheme` enum from
`opendal` to `from opendal import services` and use `services.Scheme.<NAME>`.
# Upgrade to v0.46
diff --git a/bindings/python/uv.lock b/bindings/python/uv.lock
index ac588370e..28be0197c 100644
--- a/bindings/python/uv.lock
+++ b/bindings/python/uv.lock
@@ -1351,6 +1351,7 @@ docs = [
]
lint = [
{ name = "ruff" },
+ { name = "ty" },
]
test = [
{ name = "pydantic-settings" },
@@ -1377,7 +1378,10 @@ docs = [
{ name = "mkdocs-material" },
{ name = "mkdocstrings", extras = ["python"] },
]
-lint = [{ name = "ruff", specifier = ">=0.9.10" }]
+lint = [
+ { name = "ruff", specifier = ">=0.9.10" },
+ { name = "ty", specifier = ">=0.0.51" },
+]
test = [
{ name = "pydantic-settings", specifier = ">=2.8.1" },
{ name = "pytest", specifier = ">=8.3.5" },
@@ -2215,6 +2219,31 @@ wheels = [
{ url =
"https://files.pythonhosted.org/packages/00/c0/8f5d070730d7836adc9c9b6408dec68c6ced86b304a9b26a14df072a6e8c/traitlets-5.14.3-py3-none-any.whl",
hash =
"sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f", size
= 85359, upload-time = "2024-04-19T11:11:46.763Z" },
]
+[[package]]
+name = "ty"
+version = "0.0.51"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url =
"https://files.pythonhosted.org/packages/7e/ce/352fcdba5c72ea20e5d2e46e28809cdb617575b71209d971eff2ace8e6c4/ty-0.0.51.tar.gz",
hash =
"sha256:b90172d46365bb9d51a7011cbb5c60cc4f514f42c86635df6c092b717f85e1ac", size
= 5953151, upload-time = "2026-06-19T01:48:58.015Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/2b/8f/8fe7cab79a45320b2cdcd602f16d44c8108d2f418ff7ec316c6212f1f0cc/ty-0.0.51-py3-none-linux_armv6l.whl",
hash =
"sha256:947986bd82d324b3a5c58ce03f1dad160cdf36443d3e8f64b3484b861ba9bc64", size
= 11884805, upload-time = "2026-06-19T01:48:20.184Z" },
+ { url =
"https://files.pythonhosted.org/packages/fa/b4/56fdc39a3f44c0564fd157e1e59e1f9c3fc5ba57ae4472ded85c67c63d74/ty-0.0.51-py3-none-macosx_10_12_x86_64.whl",
hash =
"sha256:25a5b31e6f23fd5dc63ad29087ded09932409e4154e2fe07bbaed015035990bb", size
= 11633593, upload-time = "2026-06-19T01:48:22.998Z" },
+ { url =
"https://files.pythonhosted.org/packages/33/57/136e83f24fc04f5afdcabff42f40fa27eae5ac3f0e3f12627d072a55f679/ty-0.0.51-py3-none-macosx_11_0_arm64.whl",
hash =
"sha256:2faed19a8f1505370de071c008df52a994fc03a204f3267c3a33a32ca26f854f", size
= 11063076, upload-time = "2026-06-19T01:48:25.223Z" },
+ { url =
"https://files.pythonhosted.org/packages/32/f8/5d32f0df5692446440ab781b9b119aa3e0c0dbfa78c583fe9be8417d54fa/ty-0.0.51-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
hash =
"sha256:08adbe53fb8bc9e7f00e89bf1d3c875a02cda76d83f109d2e6ab1ff35a7bfa8c", size
= 11579542, upload-time = "2026-06-19T01:48:27.302Z" },
+ { url =
"https://files.pythonhosted.org/packages/7f/0c/4f54ef338e9623886809ecd508931b0cd5b3aba1e591586a2f6aeaa8bd11/ty-0.0.51-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
hash =
"sha256:dc5e93695ab5dcbf1eef663aee60ec23a413547cc9cb06adcb0d842e9166bd0f", size
= 11676189, upload-time = "2026-06-19T01:48:29.518Z" },
+ { url =
"https://files.pythonhosted.org/packages/56/27/31729066f9b9d3596941edaf267894eefc0b30df4518f003dba5f7276258/ty-0.0.51-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl",
hash =
"sha256:abd92913bc90d1705ef9391ff8c6822b61e2e827fa295eb30bf0dfabcf815645", size
= 12188154, upload-time = "2026-06-19T01:48:31.68Z" },
+ { url =
"https://files.pythonhosted.org/packages/2f/38/d4301aa12d2283c7130908baf1417a37dfe3e10f5669cb4ce2853c2540b4/ty-0.0.51-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
hash =
"sha256:429a997394dac73870d71b87cc90efc54da3efaf319e72ca18aeef35a78aef90", size
= 12780597, upload-time = "2026-06-19T01:48:33.839Z" },
+ { url =
"https://files.pythonhosted.org/packages/c1/52/4b2e67e53f126d39abe201bd2299e467e27463a284e965ad195cbc217fa0/ty-0.0.51-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl",
hash =
"sha256:62d94f06e8c317e89b6884f2bde443040e596b88c7c79bd944c84c105b06257a", size
= 12491115, upload-time = "2026-06-19T01:48:36.169Z" },
+ { url =
"https://files.pythonhosted.org/packages/74/50/aabfe55c132ebe72b4d639cbf772d931e11b0990d29c1f691922b6ccabc1/ty-0.0.51-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
hash =
"sha256:f8f52952cff665bc52a36147e610c10f5699d30007d7a14ab7f345cff93476ff", size
= 12230135, upload-time = "2026-06-19T01:48:38.445Z" },
+ { url =
"https://files.pythonhosted.org/packages/0d/1b/9aa428052dbed91c50919cd080426a313cf20ce14c6bfe2b71345e548671/ty-0.0.51-py3-none-manylinux_2_31_riscv64.whl",
hash =
"sha256:c1bd1355aee86af01e4e21b0bc16fc460fb05905761f0d8b8d70841de0feade8", size
= 12468123, upload-time = "2026-06-19T01:48:40.47Z" },
+ { url =
"https://files.pythonhosted.org/packages/0b/5a/f6ce69f2575259386c950c40e02578d0902760cb61f95045e9971182c24e/ty-0.0.51-py3-none-musllinux_1_2_aarch64.whl",
hash =
"sha256:79d1877e93460f936bc10ed1a31525702b7ce51075763ccba993be17f0b9e905", size
= 11541672, upload-time = "2026-06-19T01:48:42.635Z" },
+ { url =
"https://files.pythonhosted.org/packages/35/3a/2af48924a683e959e95e5cc4dc88e5a8595206a0812b869032b95196f2b0/ty-0.0.51-py3-none-musllinux_1_2_armv7l.whl",
hash =
"sha256:cc233a6235fb23e2a44b14731a10043e37ba2f30f2c361cf49ad3633c5b9da9c", size
= 11694015, upload-time = "2026-06-19T01:48:44.819Z" },
+ { url =
"https://files.pythonhosted.org/packages/a4/12/899875d8a60b198c8121cb92ce18e18cc072d23ca2130fcdaa176383ef72/ty-0.0.51-py3-none-musllinux_1_2_i686.whl",
hash =
"sha256:bc7459348a253247bbfb2669a021e614281b86bbea24c36112b8a6e1a2499a16", size
= 11832856, upload-time = "2026-06-19T01:48:47.028Z" },
+ { url =
"https://files.pythonhosted.org/packages/e6/a2/88f681d826d97cc96ef9f6cadd4935f775758944cee07340aa46113bce28/ty-0.0.51-py3-none-musllinux_1_2_x86_64.whl",
hash =
"sha256:49a21237f6fd1de56beaff0a3e85fe022a09a3401e67e3abec41ce838a5d4d2e", size
= 12333449, upload-time = "2026-06-19T01:48:49.091Z" },
+ { url =
"https://files.pythonhosted.org/packages/f8/61/535a4163b4452c6978c31fedfd7b5803cf3a2253e9455cde350f86638d6a/ty-0.0.51-py3-none-win32.whl",
hash =
"sha256:61b4b6a003c3ebe53a63a1125c9b6542aa01bc1b6c9a235d01ee328d000d61a9", size
= 11177338, upload-time = "2026-06-19T01:48:51.433Z" },
+ { url =
"https://files.pythonhosted.org/packages/aa/4d/2334fbb74291a20129fa7aaa8f789619ec9b6883b27f997b8baa27e4674f/ty-0.0.51-py3-none-win_amd64.whl",
hash =
"sha256:608d417cd1eaf79bcbd713d9830d5e3db9d57ec225c3af3e4ac9a9ff66b45d70", size
= 12325675, upload-time = "2026-06-19T01:48:53.774Z" },
+ { url =
"https://files.pythonhosted.org/packages/50/b5/d49096cd5f3694becb86a5a6ccd0f229ead695fc7430d6bc4dd0a104c6fe/ty-0.0.51-py3-none-win_arm64.whl",
hash =
"sha256:62ced5e380284f12b2dc4802a3e4ed3dac39913fc6719afde7978814a4c7f169", size
= 11657350, upload-time = "2026-06-19T01:48:55.904Z" },
+]
+
[[package]]
name = "types-awscrt"
version = "0.28.1"