Skip to content

Commit ad407f7

Browse files
authored
TYP: Specify specific type for NumericIndex._values (#41073)
1 parent 1fb626d commit ad407f7

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pandas/core/indexes/numeric.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class NumericIndex(Index):
5050
This is an abstract class.
5151
"""
5252

53+
_values: np.ndarray
5354
_default_dtype: np.dtype
5455
_dtype_validation_metadata: tuple[Callable[..., bool], str]
5556

@@ -250,9 +251,7 @@ def asi8(self) -> np.ndarray:
250251
FutureWarning,
251252
stacklevel=2,
252253
)
253-
# error: Incompatible return value type (got "Union[ExtensionArray, ndarray]",
254-
# expected "ndarray")
255-
return self._values.view(self._default_dtype) # type: ignore[return-value]
254+
return self._values.view(self._default_dtype)
256255

257256

258257
class Int64Index(IntegerIndex):
@@ -330,10 +329,7 @@ def astype(self, dtype, copy=True):
330329
elif is_integer_dtype(dtype) and not is_extension_array_dtype(dtype):
331330
# TODO(jreback); this can change once we have an EA Index type
332331
# GH 13149
333-
334-
# error: Argument 1 to "astype_nansafe" has incompatible type
335-
# "Union[ExtensionArray, ndarray]"; expected "ndarray"
336-
arr = astype_nansafe(self._values, dtype=dtype) # type: ignore[arg-type]
332+
arr = astype_nansafe(self._values, dtype=dtype)
337333
return Int64Index(arr, name=self.name)
338334
return super().astype(dtype, copy=copy)
339335

0 commit comments

Comments
 (0)