jameslamb opened a new issue, #49831:
URL: https://github.com/apache/arrow/issues/49831
### Describe the bug, including details regarding any error messages,
version, and platform.
Consider the following snippet:
```shell
docker run \
--rm \
-it python:3.13 \
bash
pip install 'pyarrow>=24.0' 'mypy'
cat > test.py <<EOF
import pyarrow as pa
import pyarrow.compute as pa_compute
def all_ones(arr) -> bool:
return pa_compute.all(pa_compute.equal(arr, 1))
if __name__ == "__main__":
X = pa.array([1, 1, 1])
print(f"all ones?: {all_ones(X)}")
EOF
```
This is totally plausible `pyarrow` code and works as expected.
```console
$ python ./test.py
all ones?: True
```
But `mypy` complains about it referencing things that don't exist in
`pyarrow`
```console
$ mypy --version
mypy 1.20.2 (compiled: yes)
$ mypy ./test.py
test.py:5: error: Module has no attribute "all" [attr-defined]
test.py:5: error: Module has no attribute "equal" [attr-defined]
Found 2 errors in 1 file (checked 1 source file)
```
## Notes
Similar errors are not surfaced by type checkers like `mypy` on
`pyarrow<24`, so I strongly suspect this is related to something new in the
24.0 release. Possibly the introduction of type-checking infrastructure (a
`py.typed` file and `.pyi` stubs), around #48618
Maybe the `.pyi` stub file(s) are incomplete? At
https://mypy.readthedocs.io/en/stable/stubs.html#creating-a-stub, I see:
> _If a directory contains both a `.py` and a `.pyi` file for the same
module, the `.pyi` file takes precedence._
Or maybe `mypy` does not handle well situations where things are added to
`globals` at import time like this?
https://github.com/apache/arrow/blob/acd8e442939b5fbf90d0cd65ca506514ec3851c4/python/pyarrow/compute.py#L343
Thanks for your time and consideration.
### Component(s)
Python
--
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]