Skip to content

Commit 894a590

Browse files
authored
Argument 1 to "apply" of "Series" has incompatible type "Callable[[Any], Union[int, NAType]]" (#724)
Update series.pyi and add test case
1 parent a9f3327 commit 894a590

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pandas-stubs/core/series.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
851851
@overload
852852
def apply(
853853
self,
854-
func: Callable[..., Scalar | Sequence | set | Mapping | None],
854+
func: Callable[..., Scalar | Sequence | set | Mapping | NAType | None],
855855
convertDType: _bool = ...,
856856
args: tuple = ...,
857857
**kwds,

tests/test_series.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
)
3636
import xarray as xr
3737

38+
from pandas._libs.missing import NAType
3839
from pandas._libs.tslibs.timedeltas import Timedelta
3940
from pandas._libs.tslibs.timestamps import Timestamp
4041
from pandas._typing import (
@@ -470,6 +471,8 @@ def get_depth(url: str) -> int:
470471
ss = s.astype(str)
471472
check(assert_type(ss.apply(get_depth), pd.Series), pd.Series, np.int64)
472473

474+
check(assert_type(s.apply(lambda x: pd.NA), pd.Series), pd.Series, NAType)
475+
473476

474477
def test_types_element_wise_arithmetic() -> None:
475478
s = pd.Series([0, 1, -10])

0 commit comments

Comments
 (0)