diff --git a/pandas/core/accessor.py b/pandas/core/accessor.py index 96b7cf8f97c3f..963c9c65cb30c 100644 --- a/pandas/core/accessor.py +++ b/pandas/core/accessor.py @@ -58,7 +58,9 @@ def _delegate_method(self, name, *args, **kwargs): raise TypeError("You cannot call method {name}".format(name=name)) @classmethod - def _add_delegate_accessors(cls, delegate, accessors, typ, overwrite=False): + def _add_delegate_accessors( + cls, delegate, accessors, typ: str, overwrite: bool = False + ): """ Add accessors to cls from the delegate class. @@ -107,7 +109,7 @@ def f(self, *args, **kwargs): setattr(cls, name, f) -def delegate_names(delegate, accessors, typ, overwrite=False): +def delegate_names(delegate, accessors, typ: str, overwrite: bool = False): """ Add delegated names to a class using a class decorator. This provides an alternative usage to directly calling `_add_delegate_accessors` @@ -162,7 +164,7 @@ class CachedAccessor: the single argument ``data``. """ - def __init__(self, name, accessor): + def __init__(self, name: str, accessor) -> None: self._name = name self._accessor = accessor diff --git a/pandas/core/sorting.py b/pandas/core/sorting.py index b99ac9cc333c6..3005bdcbe78a4 100644 --- a/pandas/core/sorting.py +++ b/pandas/core/sorting.py @@ -187,7 +187,7 @@ def indexer_from_factorized(labels, shape, compress: bool = True): return get_group_index_sorter(ids, ngroups) -def lexsort_indexer(keys, orders=None, na_position="last"): +def lexsort_indexer(keys, orders=None, na_position: str = "last"): from pandas.core.arrays import Categorical labels = [] @@ -233,7 +233,9 @@ def lexsort_indexer(keys, orders=None, na_position="last"): return indexer_from_factorized(labels, shape) -def nargsort(items, kind="quicksort", ascending: bool = True, na_position="last"): +def nargsort( + items, kind: str = "quicksort", ascending: bool = True, na_position: str = "last" +): """ This is intended to be a drop-in replacement for np.argsort which handles NaNs. It adds ascending and na_position parameters. @@ -273,7 +275,7 @@ class _KeyMapper: Ease my suffering. Map compressed group id -> key tuple """ - def __init__(self, comp_ids, ngroups, levels, labels): + def __init__(self, comp_ids, ngroups: int, levels, labels): self.levels = levels self.labels = labels self.comp_ids = comp_ids.astype(np.int64)