Skip to content

Commit 56f27d7

Browse files
authored
TYP: annotation of __init__ return type (PEP 484) (pandas/core) (#46279)
1 parent e12d4ec commit 56f27d7

28 files changed

+56
-56
lines changed

pandas/core/algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ def checked_add_with_arr(
10981098

10991099

11001100
class SelectN:
1101-
def __init__(self, obj, n: int, keep: str):
1101+
def __init__(self, obj, n: int, keep: str) -> None:
11021102
self.obj = obj
11031103
self.n = n
11041104
self.keep = keep
@@ -1218,7 +1218,7 @@ class SelectNFrame(SelectN):
12181218
nordered : DataFrame
12191219
"""
12201220

1221-
def __init__(self, obj: DataFrame, n: int, keep: str, columns: IndexLabel):
1221+
def __init__(self, obj: DataFrame, n: int, keep: str, columns: IndexLabel) -> None:
12221222
super().__init__(obj, n, keep)
12231223
if not is_list_like(columns) or isinstance(columns, tuple):
12241224
columns = [columns]

pandas/core/apply.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __init__(
113113
result_type: str | None,
114114
args,
115115
kwargs,
116-
):
116+
) -> None:
117117
self.obj = obj
118118
self.raw = raw
119119
self.args = args or ()
@@ -1053,7 +1053,7 @@ def __init__(
10531053
convert_dtype: bool,
10541054
args,
10551055
kwargs,
1056-
):
1056+
) -> None:
10571057
self.convert_dtype = convert_dtype
10581058

10591059
super().__init__(
@@ -1157,7 +1157,7 @@ def __init__(
11571157
func: AggFuncType,
11581158
args,
11591159
kwargs,
1160-
):
1160+
) -> None:
11611161
kwargs = kwargs.copy()
11621162
self.axis = obj.obj._get_axis_number(kwargs.get("axis", 0))
11631163
super().__init__(
@@ -1186,7 +1186,7 @@ def __init__(
11861186
func: AggFuncType,
11871187
args,
11881188
kwargs,
1189-
):
1189+
) -> None:
11901190
super().__init__(
11911191
obj,
11921192
func,

pandas/core/describe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class NDFrameDescriberAbstract(ABC):
106106
Whether to treat datetime dtypes as numeric.
107107
"""
108108

109-
def __init__(self, obj: DataFrame | Series, datetime_is_numeric: bool):
109+
def __init__(self, obj: DataFrame | Series, datetime_is_numeric: bool) -> None:
110110
self.obj = obj
111111
self.datetime_is_numeric = datetime_is_numeric
112112

@@ -156,7 +156,7 @@ def __init__(
156156
include: str | Sequence[str] | None,
157157
exclude: str | Sequence[str] | None,
158158
datetime_is_numeric: bool,
159-
):
159+
) -> None:
160160
self.include = include
161161
self.exclude = exclude
162162

pandas/core/dtypes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class Registry:
430430
These are tried in order.
431431
"""
432432

433-
def __init__(self):
433+
def __init__(self) -> None:
434434
self.dtypes: list[type_t[ExtensionDtype]] = []
435435

436436
def register(self, dtype: type_t[ExtensionDtype]) -> None:

pandas/core/dtypes/dtypes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class CategoricalDtype(PandasExtensionDtype, ExtensionDtype):
181181
_metadata = ("categories", "ordered")
182182
_cache_dtypes: dict[str_type, PandasExtensionDtype] = {}
183183

184-
def __init__(self, categories=None, ordered: Ordered = False):
184+
def __init__(self, categories=None, ordered: Ordered = False) -> None:
185185
self._finalize(categories, ordered, fastpath=False)
186186

187187
@classmethod
@@ -672,7 +672,7 @@ class DatetimeTZDtype(PandasExtensionDtype):
672672
_match = re.compile(r"(datetime64|M8)\[(?P<unit>.+), (?P<tz>.+)\]")
673673
_cache_dtypes: dict[str_type, PandasExtensionDtype] = {}
674674

675-
def __init__(self, unit: str_type | DatetimeTZDtype = "ns", tz=None):
675+
def __init__(self, unit: str_type | DatetimeTZDtype = "ns", tz=None) -> None:
676676
if isinstance(unit, DatetimeTZDtype):
677677
# error: "str" has no attribute "tz"
678678
unit, tz = unit.unit, unit.tz # type: ignore[attr-defined]
@@ -1303,7 +1303,7 @@ class PandasDtype(ExtensionDtype):
13031303

13041304
_metadata = ("_dtype",)
13051305

1306-
def __init__(self, dtype: npt.DTypeLike | PandasDtype | None):
1306+
def __init__(self, dtype: npt.DTypeLike | PandasDtype | None) -> None:
13071307
if isinstance(dtype, PandasDtype):
13081308
# make constructor univalent
13091309
dtype = dtype.numpy_dtype

pandas/core/flags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Flags:
4444

4545
_keys = {"allows_duplicate_labels"}
4646

47-
def __init__(self, obj, *, allows_duplicate_labels):
47+
def __init__(self, obj, *, allows_duplicate_labels) -> None:
4848
self._allows_duplicate_labels = allows_duplicate_labels
4949
self._obj = weakref.ref(obj)
5050

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def __init__(
599599
columns: Axes | None = None,
600600
dtype: Dtype | None = None,
601601
copy: bool | None = None,
602-
):
602+
) -> None:
603603

604604
if data is None:
605605
data = {}

pandas/core/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def __init__(
243243
data: Manager,
244244
copy: bool_t = False,
245245
attrs: Mapping[Hashable, Any] | None = None,
246-
):
246+
) -> None:
247247
# copy kwarg is retained for mypy compat, is not used
248248

249249
object.__setattr__(self, "_is_copy", None)

pandas/core/groupby/groupby.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ class GroupByPlot(PandasObject):
533533
Class implementing the .plot attribute for groupby objects.
534534
"""
535535

536-
def __init__(self, groupby: GroupBy):
536+
def __init__(self, groupby: GroupBy) -> None:
537537
self._groupby = groupby
538538

539539
def __call__(self, *args, **kwargs):
@@ -854,7 +854,7 @@ def __init__(
854854
observed: bool = False,
855855
mutated: bool = False,
856856
dropna: bool = True,
857-
):
857+
) -> None:
858858

859859
self._selection = selection
860860

pandas/core/groupby/grouper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def __init__(
281281
axis: int = 0,
282282
sort: bool = False,
283283
dropna: bool = True,
284-
):
284+
) -> None:
285285
self.key = key
286286
self.level = level
287287
self.freq = freq
@@ -475,7 +475,7 @@ def __init__(
475475
observed: bool = False,
476476
in_axis: bool = False,
477477
dropna: bool = True,
478-
):
478+
) -> None:
479479
self.level = level
480480
self._orig_grouper = grouper
481481
self.grouping_vector = _convert_grouper(index, grouper)

0 commit comments

Comments
 (0)