From f0754ec7f006c67573b799f2fd0776cc0f821353 Mon Sep 17 00:00:00 2001 From: Sam Goldman Date: Wed, 23 Sep 2026 10:58:50 -0700 Subject: [PATCH] GH-51474: [Python][Annotations] Add pyrefly check to CI Run pyrefly alongside mypy, pyright, and ty in ci/scripts/python_test_type_annotations.sh, with a [tool.pyrefly] section in python/pyproject.toml that mirrors the existing checkers (check only pyarrow-stubs, resolve pyarrow from pyarrow-stubs first, Python 3.11), and document it in the developer guide. --- ci/scripts/python_test_type_annotations.sh | 3 ++- docs/source/developers/python/development.rst | 11 +++++++++++ python/pyproject.toml | 13 +++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ci/scripts/python_test_type_annotations.sh b/ci/scripts/python_test_type_annotations.sh index 092bedf3f5ea..9c4ca3dd9731 100755 --- a/ci/scripts/python_test_type_annotations.sh +++ b/ci/scripts/python_test_type_annotations.sh @@ -29,10 +29,11 @@ fi pip install fsspec pandas-stubs scipy-stubs types-cffi types-psutil types-requests types-python-dateutil # Install type checkers -pip install mypy pyright ty +pip install mypy pyrefly pyright ty # Run type checkers cd "${pyarrow_dir}" mypy pyright --stats ty check --verbose --output-format concise +pyrefly check --summarize-errors diff --git a/docs/source/developers/python/development.rst b/docs/source/developers/python/development.rst index 91f98cab060b..a6fdf4d1c2f2 100644 --- a/docs/source/developers/python/development.rst +++ b/docs/source/developers/python/development.rst @@ -145,6 +145,17 @@ To run ty (note: currently only partially configured): $ cd arrow/python $ ty check +**pyrefly** + +To run pyrefly: + +.. code-block:: + + $ cd arrow/python + $ pyrefly check + +The pyrefly configuration is in the ``[tool.pyrefly]`` section of ``pyproject.toml``. + Maintaining Type Stubs ----------------------- diff --git a/python/pyproject.toml b/python/pyproject.toml index 68c1a807dd51..f98ed3fed899 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -137,6 +137,19 @@ exclude = [ stubPath = "pyarrow-stubs" typeCheckingMode = "basic" +# TODO: Enable type checking once stubs are merged +[tool.pyrefly] +project-includes = ["pyarrow-stubs"] +project-excludes = [ + "pyarrow", + "benchmarks", + "examples", + "scripts", + "build", +] +search-path = ["pyarrow-stubs"] +python-version = "3.11" + # TODO: Enable type checking once stubs are merged [tool.ty.environment] extra-paths = ["pyarrow-stubs"]