apache / apache/arrow

pyright type error when hinting pyarrow.compute functions as Callable[[ChunkedArray[Any]], ChunkedArray[Any]]

Open
#48,677 0 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

I’m seeing a pyright type-checking error when I try to treat a pyarrow.compute function (for example pc.sin) as a callable that takes a ChunkedArray and returns a ChunkedArray.

At runtime this works as expected, but pyright reports a type error.

**Minimal example:**

```
import pyarrow.compute as pc
from typing import Callable, Any
from pyarrow import ChunkedArray

f: Callable[[ChunkedArray[Any]], ChunkedArray[Any]] = pc.sin
```

Leads to pyright error:
```
Type of "pc.sin" is "Overload[...]" which cannot be assigned to
"Callable[[ChunkedArray[Any]], ChunkedArray[Any]]"
(reportArgumentType)
```

**Environment**
pyarrow: 22.0.0
pyarrow-stubs: 19.2
pyright: 1.1.407
Python: 3.12.12

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.