Closed
Description
Describe the bug
Calling to_numpy
with na_value
set to a NumPy type gives a type error. This works at runtime.
To Reproduce
-
Provide a minimal runnable
pandas
example that is not properly checked by the stubs.import numpy as np import pandas as pd data_array = pd.arrays.IntegerArray( np.array([1, 2, -1], dtype=np.int32), mask=np.array([0, 0, 1], dtype=np.bool), ) data = data_array.to_numpy( dtype=np.int32, na_value=np.int32(42), )
-
Indicate which type checker you are using (
mypy
orpyright
).I am using MyPy.
-
Show the error message received from that type checker while checking your example.
Argument "na_value" to "to_numpy" of "BaseMaskedArray" has incompatible type "signedinteger[_32Bit]"; expected "str | bytes | date | datetime | timedelta | <7 more items> | complex"
Please complete the following information:
- OS: Windows
- OS Version: 11
- python version: 3.11.11
- version of type checker: 1.15.0
- version of installed
pandas-stubs
: 2.2.3.250308
Metadata
Metadata
Assignees
Labels
No labels