Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
d3abee6
Add pyarrow-stubs minus their docstings
rok Sep 20, 2025
2199817
Minor changes to pyarrow so some typechecks pass
rok Sep 20, 2025
f0223a8
Add utility for adding docstrings into annotations
rok Sep 20, 2025
4f860f2
Add CI check
rok Sep 20, 2025
ce2b46b
lint
rok Sep 22, 2025
b33e5dc
adding some ignores to pass more checks
rok Sep 22, 2025
4113927
minor
rok Sep 23, 2025
ee6d3ba
minor
rok Sep 23, 2025
2dcd1e2
minor
rok Sep 23, 2025
fe422d6
Apply suggestions from code review
rok Oct 6, 2025
41f3bb1
Update python/pyarrow-stubs/_compute.pyi
rok Oct 6, 2025
fb45cfc
Update python/pyarrow-stubs/_compute.pyi
rok Oct 6, 2025
e3a5623
Update python/pyarrow-stubs/_compute.pyi
rok Oct 6, 2025
e331dde
annotation fix
rok Oct 6, 2025
ed3a280
Review feedback
rok Oct 7, 2025
e6d6352
Some changes
rok Oct 7, 2025
faa04a8
fixing missing-imports
rok Oct 8, 2025
0493abb
fix pyright config
rok Oct 8, 2025
a20b07a
experiment
rok Oct 8, 2025
4c1ca02
reduce mypy errors
rok Oct 10, 2025
f33b3f7
ty
rok Oct 10, 2025
b7636f4
Update python/pyarrow-stubs/pyarrow/compute.pyi
rok Oct 10, 2025
85b7c15
Update python/pyarrow-stubs/pyarrow/compute.pyi
rok Oct 10, 2025
ad4c4c3
misc
rok Oct 10, 2025
7653fe4
misc
rok Oct 10, 2025
2363e83
Update python/pyproject.toml
rok Oct 13, 2025
00a4ebd
bumpy python in pyright
rok Oct 13, 2025
f25792c
workaround for shadowed types module
rok Oct 13, 2025
563bf1e
Make pyright stricter
rok Oct 13, 2025
882be03
pyright work
rok Oct 13, 2025
24a15e6
further pyright work
rok Oct 14, 2025
839be53
yet further pyright work
rok Oct 14, 2025
4043e7b
pyright work
rok Oct 15, 2025
84e985e
pyright work
rok Oct 15, 2025
54279ec
pyright for test_dataset.py
rok Oct 15, 2025
0d1cd25
pyright for test_compute.py
rok Oct 16, 2025
2450c28
pyright for test_{sparse_tensor,substrait,tensor,types,udf,without_nu…
rok Oct 16, 2025
605b62c
WIP pyright for test_{pandas,scalars,schema,substrait}.py
rok Oct 17, 2025
cd64771
WIP
rok Oct 20, 2025
3f75075
WIP
rok Oct 20, 2025
7b9f66b
fix ty checks
rok Oct 20, 2025
ace804c
minor fixes
rok Oct 20, 2025
d31ddda
fix mypy
rok Oct 21, 2025
5338ffe
minor fix
rok Oct 21, 2025
dd43b9d
minor fix
rok Oct 21, 2025
0f8ea49
minor fix
rok Oct 21, 2025
00f320d
minor fix
rok Oct 21, 2025
91fde5b
fix CI
rok Oct 21, 2025
a62e179
minor fix
rok Oct 21, 2025
f7abb6b
test
rok Oct 22, 2025
24a7660
fixes
rok Oct 22, 2025
7e2209c
cleanup
rok Oct 23, 2025
8f018e5
lint
rok Oct 23, 2025
5d9a30c
fix
rok Oct 24, 2025
6473eb6
fix
rok Oct 24, 2025
007b125
more fix
rok Oct 24, 2025
31d551f
fixes
rok Oct 24, 2025
b140921
remove some newlines
rok Oct 24, 2025
afdaf60
some fixes
rok Oct 25, 2025
0e3babf
Review feedback
rok Nov 10, 2025
1d0df8c
test for pyarrow
rok Nov 10, 2025
7ef81cb
Moving typechecks under 'Execute Docker Build' step
rok Nov 10, 2025
9a37405
Add typechecking for macos
rok Nov 10, 2025
070a4e1
Add typechecking for macos
rok Nov 10, 2025
7766b55
Add typechecking for Windows
rok Nov 10, 2025
9b0d38b
package stubs into wheels and test for presence
rok Nov 10, 2025
94812e7
add type checking guidelines for developers
rok Nov 10, 2025
17085e8
lint
rok Nov 10, 2025
301fb5c
lint
rok Nov 10, 2025
005572a
fix path on macos
rok Nov 10, 2025
f64ca0a
fix some annotations
rok Nov 10, 2025
3331f19
annotation fix
rok Nov 11, 2025
94cfb06
lint
rok Nov 11, 2025
e6f93df
lint
rok Nov 11, 2025
18ec57f
minor post rebase change
rok Nov 18, 2025
5489b68
dan's homework
rok Nov 18, 2025
1ce9c09
rebase and some minor work
rok Dec 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ jobs:
- name: Test
shell: bash
run: ci/scripts/python_test.sh $(pwd) $(pwd)/build
- name: Test annotations
shell: bash
env:
PYARROW_TEST_ANNOTATIONS: "ON"
run: ci/scripts/python_test_type_annotations.sh $(pwd)/python

windows:
name: AMD64 Windows 2022 Python 3.13
Expand Down Expand Up @@ -296,3 +301,7 @@ jobs:
shell: cmd
run: |
call "ci\scripts\python_test.bat" %cd%
- name: Test annotations
shell: cmd
run: |
call "ci\scripts\python_test_type_annotations.bat" %cd%\python
38 changes: 38 additions & 0 deletions ci/scripts/python_test_type_annotations.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@rem Licensed to the Apache Software Foundation (ASF) under one
@rem or more contributor license agreements. See the NOTICE file
@rem distributed with this work for additional information
@rem regarding copyright ownership. The ASF licenses this file
@rem to you under the Apache License, Version 2.0 (the
@rem "License"); you may not use this file except in compliance
@rem with the License. You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing,
@rem software distributed under the License is distributed on an
@rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@rem KIND, either express or implied. See the License for the
@rem specific language governing permissions and limitations
@rem under the License.

@echo on

set PYARROW_DIR=%1

echo Annotation testing on Windows ...

@REM Install library stubs
%PYTHON_CMD% -m pip install pandas-stubs scipy-stubs sphinx types-cffi types-psutil types-requests types-python-dateutil || exit /B 1

@REM Install other dependencies for type checking
%PYTHON_CMD% -m pip install fsspec || exit /B 1

@REM Install type checkers
%PYTHON_CMD% -m pip install mypy pyright ty || exit /B 1

@REM Run type checkers
pushd %PYARROW_DIR%

mypy
pyright
ty check
40 changes: 40 additions & 0 deletions ci/scripts/python_test_type_annotations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -ex
pyarrow_dir=${1}

if [ "${PYARROW_TEST_ANNOTATIONS}" == "ON" ]; then
# Install library stubs
pip install pandas-stubs scipy-stubs sphinx types-cffi types-psutil types-requests types-python-dateutil

# Install type checkers
pip install mypy pyright ty

# Install other dependencies for type checking
pip install fsspec

# Run type checkers
pushd ${pyarrow_dir}
mypy
pyright
ty check;
else
echo "Skipping type annotation tests";
fi
5 changes: 5 additions & 0 deletions ci/scripts/python_wheel_macos_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ export CMAKE_PREFIX_PATH=${build_dir}/install
export SETUPTOOLS_SCM_PRETEND_VERSION=${PYARROW_VERSION}

pushd ${source_dir}/python
# We first populate stub docstrings and then build the wheel
python setup.py build_ext --inplace
python -m pip install griffe libcst
python ../dev/update_stub_docstrings.py pyarrow-stubs

python setup.py bdist_wheel
popd

Expand Down
5 changes: 5 additions & 0 deletions ci/scripts/python_wheel_validate_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def validate_wheel(path):
assert not outliers, f"Unexpected contents in wheel: {sorted(outliers)}"
print(f"The wheel: {wheels[0]} seems valid.")

candidates = [info for info in f.filelist if info.filename.endswith('compute.pyi')]
assert candidates, "compute.pyi not found in wheel"
content = f.read(candidates[0]).decode('utf-8', errors='replace')
assert '"""' in content, "compute.pyi missing docstrings (no triple quotes found)"


def main():
parser = argparse.ArgumentParser()
Expand Down
5 changes: 5 additions & 0 deletions ci/scripts/python_wheel_windows_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ pushd C:\arrow\python
@REM Build wheel
%PYTHON_CMD% setup.py bdist_wheel || exit /B 1

@REM We first populate stub docstrings and then build the wheel
%PYTHON_CMD% setup.py build_ext --inplace
%PYTHON_CMD% -m pip install griffe libcst
%PYTHON_CMD% ..\dev\update_stub_docstrings.py pyarrow-stubs

@REM Repair the wheel with delvewheel
@REM
@REM Since we bundled the Arrow C++ libraries ourselves, we only need to
Expand Down
5 changes: 5 additions & 0 deletions ci/scripts/python_wheel_xlinux_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ export ARROW_HOME=/tmp/arrow-dist
export CMAKE_PREFIX_PATH=/tmp/arrow-dist

pushd /arrow/python
# We first populate stub docstrings and then build the wheel
python setup.py build_ext --inplace
python -m pip install griffe libcst
python ../dev/update_stub_docstrings.py pyarrow-stubs

python setup.py bdist_wheel

echo "=== Strip symbols from wheel ==="
Expand Down
16 changes: 12 additions & 4 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,14 @@ services:
environment:
<<: [*common, *ccache, *sccache]
PYTEST_ARGS: # inherit
PYARROW_TEST_ANNOTATIONS: "ON"
volumes: *conda-volumes
command: &python-conda-command
["
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
/arrow/ci/scripts/python_test.sh /arrow"]
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"]

conda-python-emscripten:
# Usage:
Expand Down Expand Up @@ -1001,14 +1003,16 @@ services:
ARROW_S3: "OFF"
ARROW_SUBSTRAIT: "OFF"
ARROW_WITH_OPENTELEMETRY: "OFF"
PYARROW_TEST_ANNOTATIONS: "ON"
SETUPTOOLS_SCM_PRETEND_VERSION:
volumes: *ubuntu-volumes
deploy: *cuda-deploy
command: &python-command >
/bin/bash -c "
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
/arrow/ci/scripts/python_test.sh /arrow"
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"

debian-python:
# Usage:
Expand Down Expand Up @@ -1500,6 +1504,7 @@ services:
python: ${PYTHON}
shm_size: *shm-size
environment:
PYARROW_TEST_ANNOTATIONS: "ON"
<<: [*common, *ccache, *sccache]
PARQUET_REQUIRE_ENCRYPTION: # inherit
HYPOTHESIS_PROFILE: # inherit
Expand All @@ -1510,7 +1515,8 @@ services:
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
mamba uninstall -y numpy &&
/arrow/ci/scripts/python_test.sh /arrow"]
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"]

conda-python-docs:
# Usage:
Expand All @@ -1530,13 +1536,15 @@ services:
BUILD_DOCS_CPP: "ON"
BUILD_DOCS_PYTHON: "ON"
PYTEST_ARGS: "--doctest-modules --doctest-cython"
PYARROW_TEST_ANNOTATIONS: "ON"
volumes: *conda-volumes
command:
["/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
pip install -e /arrow/dev/archery[numpydoc] &&
archery numpydoc --allow-rule GL10,PR01,PR03,PR04,PR05,PR10,RT03,YD01 &&
/arrow/ci/scripts/python_test.sh /arrow"]
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"]

conda-python-dask:
# Possible $DASK parameters:
Expand Down
Loading
Loading