Skip to content

Commit

Permalink
TYP: annotation of __init__ return type (PEP 484) (pandas/plotting) (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
nafarya authored and yehoshuadimarsky committed Jul 13, 2022
1 parent 3ddfdc5 commit b082975
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ class PlotAccessor(PandasObject):
_kind_aliases = {"density": "kde"}
_all_kinds = _common_kinds + _series_kinds + _dataframe_kinds

def __init__(self, data):
def __init__(self, data) -> None:
self._parent = data

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BP(NamedTuple):
ax: Axes
lines: dict[str, list[Line2D]]

def __init__(self, data, return_type="axes", **kwargs):
def __init__(self, data, return_type="axes", **kwargs) -> None:
# Do not call LinePlot.__init__ which may fill nan
if return_type not in self._valid_return_types:
raise ValueError("return_type must be {None, 'axes', 'dict', 'both'}")
Expand Down
10 changes: 5 additions & 5 deletions pandas/plotting/_matplotlib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def default_units(x, axis) -> str:

# time formatter
class TimeFormatter(Formatter):
def __init__(self, locs):
def __init__(self, locs) -> None:
self.locs = locs

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


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


Expand Down Expand Up @@ -371,7 +371,7 @@ class MilliSecondLocator(dates.DateLocator):

UNIT = 1.0 / (24 * 3600 * 1000)

def __init__(self, tz):
def __init__(self, tz) -> None:
dates.DateLocator.__init__(self, tz)
self._interval = 1.0

Expand Down Expand Up @@ -941,7 +941,7 @@ def __init__(
month=1,
day=1,
plot_obj=None,
):
) -> None:
freq = to_offset(freq)
self.freq = freq
self.base = base
Expand Down Expand Up @@ -1025,7 +1025,7 @@ def __init__(
minor_locator: bool = False,
dynamic_mode: bool = True,
plot_obj=None,
):
) -> None:
freq = to_offset(freq)
self.format = None
self.freq = freq
Expand Down
16 changes: 8 additions & 8 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(
include_bool=False,
column: IndexLabel | None = None,
**kwds,
):
) -> None:

import matplotlib.pyplot as plt

Expand Down Expand Up @@ -984,7 +984,7 @@ class PlanePlot(MPLPlot):

_layout_type = "single"

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

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

def __init__(self, data, x, y, C=None, **kwargs):
def __init__(self, data, x, y, C=None, **kwargs) -> None:
super().__init__(data, x, y, **kwargs)
if is_integer(C) and not self.data.columns.holds_integer():
C = self.data.columns[C]
Expand Down Expand Up @@ -1157,7 +1157,7 @@ class LinePlot(MPLPlot):
_default_rot = 0
orientation = "vertical"

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

MPLPlot.__init__(self, data, **kwargs)
Expand Down Expand Up @@ -1349,7 +1349,7 @@ def get_label(i):
class AreaPlot(LinePlot):
_kind = "area"

def __init__(self, data, **kwargs):
def __init__(self, data, **kwargs) -> None:
kwargs.setdefault("stacked", True)
data = data.fillna(value=0)
LinePlot.__init__(self, data, **kwargs)
Expand Down Expand Up @@ -1424,7 +1424,7 @@ class BarPlot(MPLPlot):
_default_rot = 90
orientation = "vertical"

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

def __init__(self, data, kind=None, **kwargs):
def __init__(self, data, kind=None, **kwargs) -> None:
data = data.fillna(value=0)
if (data < 0).any().any():
raise ValueError(f"{self._kind} plot doesn't allow negative values")
Expand Down
4 changes: 2 additions & 2 deletions pandas/plotting/_matplotlib/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
class HistPlot(LinePlot):
_kind = "hist"

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

def __init__(self, data, bw_method=None, ind=None, **kwargs):
def __init__(self, data, bw_method=None, ind=None, **kwargs) -> None:
MPLPlot.__init__(self, data, **kwargs)
self.bw_method = bw_method
self.ind = ind
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ class _Options(dict):
_ALIASES = {"x_compat": "xaxis.compat"}
_DEFAULT_KEYS = ["xaxis.compat"]

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

Expand Down

0 comments on commit b082975

Please sign in to comment.