Skip to content

Commit 3b795d9

Browse files
TYP: annotation of __init__ return type (PEP 484) (pandas/core/arrays) (#46255)
1 parent 41d248e commit 3b795d9

16 files changed

+23
-19
lines changed

pandas/core/arrays/_arrow_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def pyarrow_array_to_numpy_and_mask(arr, dtype: np.dtype):
4848

4949

5050
class ArrowPeriodType(pyarrow.ExtensionType):
51-
def __init__(self, freq):
51+
def __init__(self, freq) -> None:
5252
# attributes need to be set first before calling
5353
# super init (as that calls serialize)
5454
self._freq = freq
@@ -88,7 +88,7 @@ def to_pandas_dtype(self):
8888

8989

9090
class ArrowIntervalType(pyarrow.ExtensionType):
91-
def __init__(self, subtype, closed):
91+
def __init__(self, subtype, closed) -> None:
9292
# attributes need to be set first before calling
9393
# super init (as that calls serialize)
9494
assert closed in VALID_CLOSED

pandas/core/arrays/_mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ class ArrowExtensionArray(ExtensionArray):
532532

533533
_data: pa.ChunkedArray
534534

535-
def __init__(self, values: pa.ChunkedArray):
535+
def __init__(self, values: pa.ChunkedArray) -> None:
536536
self._data = values
537537

538538
def __arrow_array__(self, type=None):

pandas/core/arrays/boolean.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ class BooleanArray(BaseMaskedArray):
297297
_TRUE_VALUES = {"True", "TRUE", "true", "1", "1.0"}
298298
_FALSE_VALUES = {"False", "FALSE", "false", "0", "0.0"}
299299

300-
def __init__(self, values: np.ndarray, mask: np.ndarray, copy: bool = False):
300+
def __init__(
301+
self, values: np.ndarray, mask: np.ndarray, copy: bool = False
302+
) -> None:
301303
if not (isinstance(values, np.ndarray) and values.dtype == np.bool_):
302304
raise TypeError(
303305
"values should be boolean numpy array. Use "

pandas/core/arrays/categorical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def __init__(
367367
dtype: Dtype | None = None,
368368
fastpath: bool = False,
369369
copy: bool = True,
370-
):
370+
) -> None:
371371

372372
dtype = CategoricalDtype._from_values_or_dtype(
373373
values, categories, ordered, dtype
@@ -2704,7 +2704,7 @@ class CategoricalAccessor(PandasDelegate, PandasObject, NoNewAttributesMixin):
27042704
Categories (3, object): ['a', 'b', 'c']
27052705
"""
27062706

2707-
def __init__(self, data):
2707+
def __init__(self, data) -> None:
27082708
self._validate(data)
27092709
self._parent = data.values
27102710
self._index = data.index

pandas/core/arrays/datetimelike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class DatetimeLikeArrayMixin(OpsMixin, NDArrayBackedExtensionArray):
169169
def _can_hold_na(self) -> bool:
170170
return True
171171

172-
def __init__(self, data, dtype: Dtype | None = None, freq=None, copy=False):
172+
def __init__(self, data, dtype: Dtype | None = None, freq=None, copy=False) -> None:
173173
raise AbstractMethodError(self)
174174

175175
@property

pandas/core/arrays/datetimes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ class DatetimeArray(dtl.TimelikeOps, dtl.DatelikeOps):
254254
_dtype: np.dtype | DatetimeTZDtype
255255
_freq = None
256256

257-
def __init__(self, values, dtype=DT64NS_DTYPE, freq=None, copy: bool = False):
257+
def __init__(
258+
self, values, dtype=DT64NS_DTYPE, freq=None, copy: bool = False
259+
) -> None:
258260
values = extract_array(values, extract_numpy=True)
259261
if isinstance(values, IntegerArray):
260262
values = values.to_numpy("int64", na_value=iNaT)

pandas/core/arrays/masked.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class BaseMaskedArray(OpsMixin, ExtensionArray):
107107

108108
def __init__(
109109
self, values: np.ndarray, mask: npt.NDArray[np.bool_], copy: bool = False
110-
):
110+
) -> None:
111111
# values is supposed to already be validated in the subclass
112112
if not (isinstance(mask, np.ndarray) and mask.dtype == np.bool_):
113113
raise TypeError(

pandas/core/arrays/numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class NumericArray(BaseMaskedArray):
222222

223223
def __init__(
224224
self, values: np.ndarray, mask: npt.NDArray[np.bool_], copy: bool = False
225-
):
225+
) -> None:
226226
checker = self._dtype_cls._checker
227227
if not (isinstance(values, np.ndarray) and checker(values.dtype)):
228228
descr = (

pandas/core/arrays/numpy_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class PandasArray(
6666
# ------------------------------------------------------------------------
6767
# Constructors
6868

69-
def __init__(self, values: np.ndarray | PandasArray, copy: bool = False):
69+
def __init__(self, values: np.ndarray | PandasArray, copy: bool = False) -> None:
7070
if isinstance(values, type(self)):
7171
values = values._ndarray
7272
if not isinstance(values, np.ndarray):

pandas/core/arrays/period.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class PeriodArray(dtl.DatelikeOps):
201201

202202
def __init__(
203203
self, values, dtype: Dtype | None = None, freq=None, copy: bool = False
204-
):
204+
) -> None:
205205
freq = validate_dtype_freq(dtype, freq)
206206

207207
if freq is not None:

0 commit comments

Comments
 (0)