From 428cab29ac60be964e60db8a950d81f9e4173a99 Mon Sep 17 00:00:00 2001 From: tp Date: Wed, 21 Apr 2021 11:45:28 +0100 Subject: [PATCH 1/2] TYP: Specify specific type for NumericIndex._values --- pandas/core/indexes/numeric.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pandas/core/indexes/numeric.py b/pandas/core/indexes/numeric.py index 28144af36d6ea..ebe26d2cd793b 100644 --- a/pandas/core/indexes/numeric.py +++ b/pandas/core/indexes/numeric.py @@ -47,6 +47,7 @@ class NumericIndex(Index): This is an abstract class. """ + _values: np.ndarray _default_dtype: np.dtype @@ -253,9 +254,7 @@ def asi8(self) -> np.ndarray: FutureWarning, stacklevel=2, ) - # error: Incompatible return value type (got "Union[ExtensionArray, ndarray]", - # expected "ndarray") - return self._values.view(self._default_dtype) # type: ignore[return-value] + return self._values.view(self._default_dtype) class Int64Index(IntegerIndex): @@ -330,10 +329,7 @@ def astype(self, dtype, copy=True): elif is_integer_dtype(dtype) and not is_extension_array_dtype(dtype): # TODO(jreback); this can change once we have an EA Index type # GH 13149 - - # error: Argument 1 to "astype_nansafe" has incompatible type - # "Union[ExtensionArray, ndarray]"; expected "ndarray" - arr = astype_nansafe(self._values, dtype=dtype) # type: ignore[arg-type] + arr = astype_nansafe(self._values, dtype=dtype) return Int64Index(arr, name=self.name) return super().astype(dtype, copy=copy) From 94d20a79f397b062c4648ac55f25b4a0e61e4710 Mon Sep 17 00:00:00 2001 From: tp Date: Wed, 21 Apr 2021 11:54:56 +0100 Subject: [PATCH 2/2] pre-commit fixups --- pandas/core/indexes/numeric.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/numeric.py b/pandas/core/indexes/numeric.py index ebe26d2cd793b..cd75336ad7bdf 100644 --- a/pandas/core/indexes/numeric.py +++ b/pandas/core/indexes/numeric.py @@ -47,8 +47,8 @@ class NumericIndex(Index): This is an abstract class. """ - _values: np.ndarray + _values: np.ndarray _default_dtype: np.dtype _is_numeric_dtype = True