Skip to content

Commit 5db4097

Browse files
ShaharNavehWillAyd
authored andcommitted
TYP: Annotations in pandas/core/{accessor, sorting}.py (#30079)
1 parent 673436e commit 5db4097

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pandas/core/accessor.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def _delegate_method(self, name, *args, **kwargs):
5858
raise TypeError("You cannot call method {name}".format(name=name))
5959

6060
@classmethod
61-
def _add_delegate_accessors(cls, delegate, accessors, typ, overwrite=False):
61+
def _add_delegate_accessors(
62+
cls, delegate, accessors, typ: str, overwrite: bool = False
63+
):
6264
"""
6365
Add accessors to cls from the delegate class.
6466
@@ -107,7 +109,7 @@ def f(self, *args, **kwargs):
107109
setattr(cls, name, f)
108110

109111

110-
def delegate_names(delegate, accessors, typ, overwrite=False):
112+
def delegate_names(delegate, accessors, typ: str, overwrite: bool = False):
111113
"""
112114
Add delegated names to a class using a class decorator. This provides
113115
an alternative usage to directly calling `_add_delegate_accessors`
@@ -162,7 +164,7 @@ class CachedAccessor:
162164
the single argument ``data``.
163165
"""
164166

165-
def __init__(self, name, accessor):
167+
def __init__(self, name: str, accessor) -> None:
166168
self._name = name
167169
self._accessor = accessor
168170

pandas/core/sorting.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def indexer_from_factorized(labels, shape, compress: bool = True):
187187
return get_group_index_sorter(ids, ngroups)
188188

189189

190-
def lexsort_indexer(keys, orders=None, na_position="last"):
190+
def lexsort_indexer(keys, orders=None, na_position: str = "last"):
191191
from pandas.core.arrays import Categorical
192192

193193
labels = []
@@ -233,7 +233,9 @@ def lexsort_indexer(keys, orders=None, na_position="last"):
233233
return indexer_from_factorized(labels, shape)
234234

235235

236-
def nargsort(items, kind="quicksort", ascending: bool = True, na_position="last"):
236+
def nargsort(
237+
items, kind: str = "quicksort", ascending: bool = True, na_position: str = "last"
238+
):
237239
"""
238240
This is intended to be a drop-in replacement for np.argsort which
239241
handles NaNs. It adds ascending and na_position parameters.
@@ -273,7 +275,7 @@ class _KeyMapper:
273275
Ease my suffering. Map compressed group id -> key tuple
274276
"""
275277

276-
def __init__(self, comp_ids, ngroups, levels, labels):
278+
def __init__(self, comp_ids, ngroups: int, levels, labels):
277279
self.levels = levels
278280
self.labels = labels
279281
self.comp_ids = comp_ids.astype(np.int64)

0 commit comments

Comments
 (0)