Skip to content

Commit

Permalink
CLN: updated types to pass mypy tests without type: ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaustin123 committed Nov 28, 2019
1 parent 917d6c8 commit 4b51227
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,9 @@ def sort_values(self, inplace=False, ascending=True, na_position="last", key=Non
na_position : {'first', 'last'} (optional, default='last')
'first' puts NaNs at the beginning
'last' puts NaNs at the end
key : Callable, default None
If not None, apply the key function to every value before
sorting. Identical to key argument in built-in sorted function.
Returns
-------
Expand Down
7 changes: 3 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4712,18 +4712,17 @@ def f(vals):

# ----------------------------------------------------------------------
# Sorting

@Substitution(**_shared_doc_kwargs)
@Appender(NDFrame.sort_values.__doc__)
def sort_values( # type: ignore
def sort_values(
self,
by,
axis=0,
ascending=True,
inplace=False,
kind="quicksort",
na_position="last",
key: Optional[Callable] = None,
key=None,
):
inplace = validate_bool_kwarg(inplace, "inplace")
axis = self._get_axis_number(axis)
Expand Down Expand Up @@ -4766,7 +4765,7 @@ def sort_values( # type: ignore

@Substitution(**_shared_doc_kwargs)
@Appender(NDFrame.sort_index.__doc__)
def sort_index( # type: ignore
def sort_index(
self,
axis=0,
level=None,
Expand Down
5 changes: 4 additions & 1 deletion pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ def sort_values(
"""
Return sorted copy of Index.
"""
if not isinstance(self, Index):
raise TypeError("sort_values must be called on an Index object")

if key:
idx = self.map(key, na_action="ignore")
else:
Expand Down Expand Up @@ -308,7 +311,7 @@ def sort_values(
if not ascending:
sorted_values = sorted_values[::-1]

return self._simple_new(sorted_values, **attribs) # type: ignore
return self._simple_new(sorted_values, **attribs)

@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2831,14 +2831,14 @@ def update(self, other):
# ----------------------------------------------------------------------
# Reindexing, sorting

def sort_values( # type: ignore
def sort_values(
self,
axis=0,
ascending=True,
inplace=False,
kind="quicksort",
na_position="last",
key: Optional[Callable] = None,
key=None,
):
"""
Sort by the values.
Expand Down Expand Up @@ -3029,7 +3029,7 @@ def _try_kind_sort(arr):
else:
return result.__finalize__(self)

def sort_index( # type: ignore
def sort_index(
self,
axis=0,
level=None,
Expand Down

0 comments on commit 4b51227

Please sign in to comment.