Skip to content

Commit c0d746f

Browse files
authored
TYP: annotation of __init__ return type (PEP 484) (pandas/plotting) (#46283)
1 parent 56f27d7 commit c0d746f

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

pandas/plotting/_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ class PlotAccessor(PandasObject):
783783
_kind_aliases = {"density": "kde"}
784784
_all_kinds = _common_kinds + _series_kinds + _dataframe_kinds
785785

786-
def __init__(self, data):
786+
def __init__(self, data) -> None:
787787
self._parent = data
788788

789789
@staticmethod

pandas/plotting/_matplotlib/boxplot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class BP(NamedTuple):
4444
ax: Axes
4545
lines: dict[str, list[Line2D]]
4646

47-
def __init__(self, data, return_type="axes", **kwargs):
47+
def __init__(self, data, return_type="axes", **kwargs) -> None:
4848
# Do not call LinePlot.__init__ which may fill nan
4949
if return_type not in self._valid_return_types:
5050
raise ValueError("return_type must be {None, 'axes', 'dict', 'both'}")

pandas/plotting/_matplotlib/converter.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def default_units(x, axis) -> str:
184184

185185
# time formatter
186186
class TimeFormatter(Formatter):
187-
def __init__(self, locs):
187+
def __init__(self, locs) -> None:
188188
self.locs = locs
189189

190190
def __call__(self, x, pos=0) -> str:
@@ -339,7 +339,7 @@ def axisinfo(unit: tzinfo | None, axis) -> units.AxisInfo:
339339

340340

341341
class PandasAutoDateFormatter(dates.AutoDateFormatter):
342-
def __init__(self, locator, tz=None, defaultfmt="%Y-%m-%d"):
342+
def __init__(self, locator, tz=None, defaultfmt="%Y-%m-%d") -> None:
343343
dates.AutoDateFormatter.__init__(self, locator, tz, defaultfmt)
344344

345345

@@ -371,7 +371,7 @@ class MilliSecondLocator(dates.DateLocator):
371371

372372
UNIT = 1.0 / (24 * 3600 * 1000)
373373

374-
def __init__(self, tz):
374+
def __init__(self, tz) -> None:
375375
dates.DateLocator.__init__(self, tz)
376376
self._interval = 1.0
377377

@@ -941,7 +941,7 @@ def __init__(
941941
month=1,
942942
day=1,
943943
plot_obj=None,
944-
):
944+
) -> None:
945945
freq = to_offset(freq)
946946
self.freq = freq
947947
self.base = base
@@ -1025,7 +1025,7 @@ def __init__(
10251025
minor_locator: bool = False,
10261026
dynamic_mode: bool = True,
10271027
plot_obj=None,
1028-
):
1028+
) -> None:
10291029
freq = to_offset(freq)
10301030
self.format = None
10311031
self.freq = freq

pandas/plotting/_matplotlib/core.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(
128128
include_bool=False,
129129
column: IndexLabel | None = None,
130130
**kwds,
131-
):
131+
) -> None:
132132

133133
import matplotlib.pyplot as plt
134134

@@ -984,7 +984,7 @@ class PlanePlot(MPLPlot):
984984

985985
_layout_type = "single"
986986

987-
def __init__(self, data, x, y, **kwargs):
987+
def __init__(self, data, x, y, **kwargs) -> None:
988988
MPLPlot.__init__(self, data, **kwargs)
989989
if x is None or y is None:
990990
raise ValueError(self._kind + " requires an x and y column")
@@ -1037,7 +1037,7 @@ def _plot_colorbar(self, ax: Axes, **kwds):
10371037
class ScatterPlot(PlanePlot):
10381038
_kind = "scatter"
10391039

1040-
def __init__(self, data, x, y, s=None, c=None, **kwargs):
1040+
def __init__(self, data, x, y, s=None, c=None, **kwargs) -> None:
10411041
if s is None:
10421042
# hide the matplotlib default for size, in case we want to change
10431043
# the handling of this argument later
@@ -1125,7 +1125,7 @@ def _make_plot(self):
11251125
class HexBinPlot(PlanePlot):
11261126
_kind = "hexbin"
11271127

1128-
def __init__(self, data, x, y, C=None, **kwargs):
1128+
def __init__(self, data, x, y, C=None, **kwargs) -> None:
11291129
super().__init__(data, x, y, **kwargs)
11301130
if is_integer(C) and not self.data.columns.holds_integer():
11311131
C = self.data.columns[C]
@@ -1157,7 +1157,7 @@ class LinePlot(MPLPlot):
11571157
_default_rot = 0
11581158
orientation = "vertical"
11591159

1160-
def __init__(self, data, **kwargs):
1160+
def __init__(self, data, **kwargs) -> None:
11611161
from pandas.plotting import plot_params
11621162

11631163
MPLPlot.__init__(self, data, **kwargs)
@@ -1349,7 +1349,7 @@ def get_label(i):
13491349
class AreaPlot(LinePlot):
13501350
_kind = "area"
13511351

1352-
def __init__(self, data, **kwargs):
1352+
def __init__(self, data, **kwargs) -> None:
13531353
kwargs.setdefault("stacked", True)
13541354
data = data.fillna(value=0)
13551355
LinePlot.__init__(self, data, **kwargs)
@@ -1424,7 +1424,7 @@ class BarPlot(MPLPlot):
14241424
_default_rot = 90
14251425
orientation = "vertical"
14261426

1427-
def __init__(self, data, **kwargs):
1427+
def __init__(self, data, **kwargs) -> None:
14281428
# we have to treat a series differently than a
14291429
# 1-column DataFrame w.r.t. color handling
14301430
self._is_series = isinstance(data, ABCSeries)
@@ -1606,7 +1606,7 @@ class PiePlot(MPLPlot):
16061606
_kind = "pie"
16071607
_layout_type = "horizontal"
16081608

1609-
def __init__(self, data, kind=None, **kwargs):
1609+
def __init__(self, data, kind=None, **kwargs) -> None:
16101610
data = data.fillna(value=0)
16111611
if (data < 0).any().any():
16121612
raise ValueError(f"{self._kind} plot doesn't allow negative values")

pandas/plotting/_matplotlib/hist.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
class HistPlot(LinePlot):
4343
_kind = "hist"
4444

45-
def __init__(self, data, bins=10, bottom=0, **kwargs):
45+
def __init__(self, data, bins=10, bottom=0, **kwargs) -> None:
4646
self.bins = bins # use mpl default
4747
self.bottom = bottom
4848
# Do not call LinePlot.__init__ which may fill nan
@@ -170,7 +170,7 @@ class KdePlot(HistPlot):
170170
_kind = "kde"
171171
orientation = "vertical"
172172

173-
def __init__(self, data, bw_method=None, ind=None, **kwargs):
173+
def __init__(self, data, bw_method=None, ind=None, **kwargs) -> None:
174174
MPLPlot.__init__(self, data, **kwargs)
175175
self.bw_method = bw_method
176176
self.ind = ind

pandas/plotting/_misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class _Options(dict):
521521
_ALIASES = {"x_compat": "xaxis.compat"}
522522
_DEFAULT_KEYS = ["xaxis.compat"]
523523

524-
def __init__(self, deprecated=False):
524+
def __init__(self, deprecated=False) -> None:
525525
self._deprecated = deprecated
526526
super().__setitem__("xaxis.compat", False)
527527

0 commit comments

Comments
 (0)