22import datetime as pydt
33from datetime import datetime , timedelta , tzinfo
44import functools
5- from typing import Optional , Tuple
5+ from typing import Any , List , Optional , Tuple
66
77from dateutil .relativedelta import relativedelta
88import matplotlib .dates as dates
@@ -144,7 +144,7 @@ def convert(value, unit, axis):
144144 return value
145145
146146 @staticmethod
147- def axisinfo (unit , axis ):
147+ def axisinfo (unit , axis ) -> Optional [ units . AxisInfo ] :
148148 if unit != "time" :
149149 return None
150150
@@ -294,7 +294,7 @@ def try_parse(values):
294294 return values
295295
296296 @staticmethod
297- def axisinfo (unit , axis ):
297+ def axisinfo (unit : Optional [ tzinfo ] , axis ) -> units . AxisInfo :
298298 """
299299 Return the :class:`~matplotlib.units.AxisInfo` for *unit*.
300300
@@ -473,7 +473,7 @@ def _get_default_annual_spacing(nyears) -> Tuple[int, int]:
473473 return (min_spacing , maj_spacing )
474474
475475
476- def period_break (dates , period ) :
476+ def period_break (dates : PeriodIndex , period : str ) -> np . ndarray :
477477 """
478478 Returns the indices where the given period changes.
479479
@@ -489,7 +489,7 @@ def period_break(dates, period):
489489 return np .nonzero (current - previous )[0 ]
490490
491491
492- def has_level_label (label_flags , vmin ) :
492+ def has_level_label (label_flags : np . ndarray , vmin : float ) -> bool :
493493 """
494494 Returns true if the ``label_flags`` indicate there is at least one label
495495 for this level.
@@ -984,18 +984,24 @@ class TimeSeries_DateFormatter(Formatter):
984984 ----------
985985 freq : {int, string}
986986 Valid frequency specifier.
987- minor_locator : {False, True}
987+ minor_locator : bool, default False
988988 Whether the current formatter should apply to minor ticks (True) or
989989 major ticks (False).
990- dynamic_mode : {True, False}
990+ dynamic_mode : bool, default True
991991 Whether the formatter works in dynamic mode or not.
992992 """
993993
994- def __init__ (self , freq , minor_locator = False , dynamic_mode = True , plot_obj = None ):
994+ def __init__ (
995+ self ,
996+ freq ,
997+ minor_locator : bool = False ,
998+ dynamic_mode : bool = True ,
999+ plot_obj = None ,
1000+ ):
9951001 freq = to_offset (freq )
9961002 self .format = None
9971003 self .freq = freq
998- self .locs = []
1004+ self .locs : List [ Any ] = [] # unused, for matplotlib compat
9991005 self .formatdict = None
10001006 self .isminor = minor_locator
10011007 self .isdynamic = dynamic_mode
0 commit comments