Skip to content

Commit cebbfcd

Browse files
committed
add PYARROW_TEST_ANNOTATIONS to AMD64 Windows 2022 Python 3.13
change bat lint add a popd and nicer logging for windows ReplaceElipsis -> DocstringInserter simplify remove sphinx
1 parent a2b522d commit cebbfcd

4 files changed

Lines changed: 16 additions & 15 deletions

File tree

.github/workflows/python.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,5 +303,7 @@ jobs:
303303
call "ci\scripts\python_test.bat" %cd%
304304
- name: Test annotations
305305
shell: cmd
306+
env:
307+
PYARROW_TEST_ANNOTATIONS: "ON"
306308
run: |
307309
call "ci\scripts\python_test_type_annotations.bat" %cd%\python

ci/scripts/python_test_type_annotations.bat

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,18 @@ if "%PYARROW_TEST_ANNOTATIONS%"=="ON" (
2323
echo Annotation testing on Windows ...
2424

2525
@REM Install library stubs. Note some libraries contain their own type hints so they need to be installed.
26-
%PYTHON_CMD% -m pip install fsspec pandas-stubs scipy-stubs sphinx types-cffi types-psutil types-requests types-python-dateutil || exit /B 1
26+
%PYTHON_CMD% -m pip install fsspec pandas-stubs scipy-stubs types-cffi types-psutil types-requests types-python-dateutil || exit /B 1
2727

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

3131
@REM Run type checkers
3232
pushd %PYARROW_DIR%
3333

34-
mypy
35-
pyright
36-
ty check
34+
mypy || exit /B 1
35+
pyright || exit /B 1
36+
ty check || exit /B 1
37+
popd
38+
) else (
39+
echo Annotation testing skipped on Windows ...
3740
)

ci/scripts/python_test_type_annotations.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ if [ "${PYARROW_TEST_ANNOTATIONS}" == "ON" ]; then
3636
mypy
3737
pyright
3838
ty check;
39+
popd
3940
else
4041
echo "Skipping type annotation tests";
4142
fi

dev/update_stub_docstrings.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
from pathlib import Path
3232
from textwrap import indent
3333

34-
# Add current directory to path to find locally built pyarrow
35-
sys.path.insert(0, ".")
36-
3734
import libcst
3835
from libcst import matchers as m
3936

37+
# Add current directory to path to find locally built pyarrow
38+
sys.path.insert(0, ".")
39+
4040

4141
def _resolve_object(module, path):
4242
"""
@@ -66,13 +66,8 @@ def _resolve_object(module, path):
6666
try:
6767
obj = getattr(obj, part)
6868
except AttributeError:
69-
# Fallback: try __dict__ access for special methods like __init__
69+
# Fallback: try vars() for special methods like __init__
7070
# that may not be directly accessible via getattr
71-
if hasattr(parent, "__dict__"):
72-
obj = parent.__dict__.get(part)
73-
if obj is not None:
74-
continue
75-
# Try vars() as another fallback
7671
try:
7772
obj = vars(parent).get(part)
7873
if obj is not None:
@@ -137,7 +132,7 @@ def _get_docstring(name, module, indentation):
137132
return docstring
138133

139134

140-
class ReplaceEllipsis(libcst.CSTTransformer):
135+
class DocstringInserter(libcst.CSTTransformer):
141136
def __init__(self, module, namespace):
142137
self.module = module
143138
self.base_namespace = namespace
@@ -277,7 +272,7 @@ def add_docs_to_stub_files(pyarrow_folder):
277272
elif module == "__init__":
278273
module = ""
279274

280-
modified_tree = tree.visit(ReplaceEllipsis(pyarrow_module, module))
275+
modified_tree = tree.visit(DocstringInserter(pyarrow_module, module))
281276
with open(stub_file, "w") as f:
282277
f.write(modified_tree.code)
283278
print("\n")

0 commit comments

Comments
 (0)