@@ -327,7 +327,7 @@ def _format_native_types(self, na_rep="NaT", date_format=None):
327327 """
328328 raise AbstractMethodError (self )
329329
330- def _formatter (self , boxed = False ):
330+ def _formatter (self , boxed : bool = False ):
331331 # TODO: Remove Datetime & DatetimeTZ formatters.
332332 return "'{}'" .format
333333
@@ -354,7 +354,7 @@ def __getitem__(
354354 result ._freq = self ._get_getitem_freq (key )
355355 return result
356356
357- def _get_getitem_freq (self , key ):
357+ def _get_getitem_freq (self , key ) -> Optional [ BaseOffset ] :
358358 """
359359 Find the `freq` attribute to assign to the result of a __getitem__ lookup.
360360 """
@@ -406,7 +406,7 @@ def _maybe_clear_freq(self):
406406 # DatetimeArray and TimedeltaArray
407407 pass
408408
409- def astype (self , dtype , copy = True ):
409+ def astype (self , dtype , copy : bool = True ):
410410 # Some notes on cases we don't have to handle here in the base class:
411411 # 1. PeriodArray.astype handles period -> period
412412 # 2. DatetimeArray.astype handles conversion between tz.
@@ -545,7 +545,7 @@ def _values_for_factorize(self):
545545
546546 @classmethod
547547 def _from_factorized (
548- cls : Type [DatetimeLikeArrayT ], values , original
548+ cls : Type [DatetimeLikeArrayT ], values , original : DatetimeLikeArrayT
549549 ) -> DatetimeLikeArrayT :
550550 return cls (values , dtype = original .dtype )
551551
@@ -939,7 +939,7 @@ def freq(self, value):
939939 self ._freq = value
940940
941941 @property
942- def freqstr (self ):
942+ def freqstr (self ) -> Optional [ str ] :
943943 """
944944 Return the frequency object as a string if its set, otherwise None.
945945 """
@@ -948,7 +948,7 @@ def freqstr(self):
948948 return self .freq .freqstr
949949
950950 @property # NB: override with cache_readonly in immutable subclasses
951- def inferred_freq (self ):
951+ def inferred_freq (self ) -> Optional [ str ] :
952952 """
953953 Tries to return a string representing a frequency guess,
954954 generated by infer_freq. Returns None if it can't autodetect the
@@ -963,8 +963,11 @@ def inferred_freq(self):
963963
964964 @property # NB: override with cache_readonly in immutable subclasses
965965 def _resolution_obj (self ) -> Optional [Resolution ]:
966+ freqstr = self .freqstr
967+ if freqstr is None :
968+ return None
966969 try :
967- return Resolution .get_reso_from_freq (self . freqstr )
970+ return Resolution .get_reso_from_freq (freqstr )
968971 except KeyError :
969972 return None
970973
@@ -1241,7 +1244,7 @@ def _addsub_object_array(self, other: np.ndarray, op):
12411244 )
12421245 return result
12431246
1244- def _time_shift (self , periods , freq = None ):
1247+ def _time_shift (self , periods : int , freq = None ):
12451248 """
12461249 Shift each value by `periods`.
12471250
@@ -1440,7 +1443,7 @@ def __isub__(self, other):
14401443 # --------------------------------------------------------------
14411444 # Reductions
14421445
1443- def min (self , * , axis = None , skipna = True , ** kwargs ):
1446+ def min (self , * , axis : Optional [ int ] = None , skipna : bool = True , ** kwargs ):
14441447 """
14451448 Return the minimum value of the Array or minimum along
14461449 an axis.
@@ -1469,7 +1472,7 @@ def min(self, *, axis=None, skipna=True, **kwargs):
14691472 result = nanops .nanmin (self ._ndarray , axis = axis , skipna = skipna )
14701473 return self ._wrap_reduction_result (axis , result )
14711474
1472- def max (self , * , axis = None , skipna = True , ** kwargs ):
1475+ def max (self , * , axis : Optional [ int ] = None , skipna : bool = True , ** kwargs ):
14731476 """
14741477 Return the maximum value of the Array or maximum along
14751478 an axis.
@@ -1500,7 +1503,7 @@ def max(self, *, axis=None, skipna=True, **kwargs):
15001503 result = nanops .nanmax (self ._ndarray , axis = axis , skipna = skipna )
15011504 return self ._wrap_reduction_result (axis , result )
15021505
1503- def mean (self , * , skipna = True , axis : Optional [int ] = 0 ):
1506+ def mean (self , * , skipna : bool = True , axis : Optional [int ] = 0 ):
15041507 """
15051508 Return the mean value of the Array.
15061509
@@ -1568,7 +1571,7 @@ class DatelikeOps(DatetimeLikeArrayMixin):
15681571 URL = "https://docs.python.org/3/library/datetime.html"
15691572 "#strftime-and-strptime-behavior"
15701573 )
1571- def strftime (self , date_format ) :
1574+ def strftime (self , date_format : str ) -> np . ndarray :
15721575 """
15731576 Convert to Index using specified date_format.
15741577
@@ -1760,7 +1763,7 @@ def all(self, *, axis: Optional[int] = None, skipna: bool = True):
17601763 # --------------------------------------------------------------
17611764 # Frequency Methods
17621765
1763- def _maybe_clear_freq (self ):
1766+ def _maybe_clear_freq (self ) -> None :
17641767 self ._freq = None
17651768
17661769 def _with_freq (self , freq ):
0 commit comments