From 97da5adbaefc4d857216816355f6b71cca7a73d3 Mon Sep 17 00:00:00 2001 From: Jasmandeep Kaur Date: Wed, 7 Dec 2022 19:41:59 +0530 Subject: [PATCH 1/2] TYP: fix mypy ignored error in pandas/compat/numpy/function.py --- pandas/compat/numpy/function.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/compat/numpy/function.py b/pandas/compat/numpy/function.py index b02dfac1400d1..46b508eaa50f5 100644 --- a/pandas/compat/numpy/function.py +++ b/pandas/compat/numpy/function.py @@ -156,11 +156,10 @@ def validate_argsort_with_ascending(ascending: bool | int | None, args, kwargs) """ if is_integer(ascending) or ascending is None: args = (ascending,) + args - ascending = True + ascend = True validate_argsort_kind(args, kwargs, max_fname_arg_count=3) - # error: Incompatible return value type (got "int", expected "bool") - return ascending # type: ignore[return-value] + return ascend CLIP_DEFAULTS: dict[str, Any] = {"out": None} @@ -192,12 +191,12 @@ def validate_clip_with_axis( args = (axis,) + args # error: Incompatible types in assignment (expression has type "None", # variable has type "Union[ndarray[Any, Any], str, int]") - axis = None # type: ignore[assignment] + axes = None # type: ignore[assignment] validate_clip(args, kwargs) # error: Incompatible return value type (got "Union[ndarray[Any, Any], # str, int]", expected "Union[str, int, None]") - return axis # type: ignore[return-value] + return axes # type: ignore[return-value] CUM_FUNC_DEFAULTS: dict[str, Any] = {} From 6014a1ba80c45e699c19b52327fd13c36a376c14 Mon Sep 17 00:00:00 2001 From: Jasmandeep Kaur Date: Sun, 11 Dec 2022 20:40:56 +0530 Subject: [PATCH 2/2] Adding in false case for ascend --- pandas/compat/numpy/function.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/compat/numpy/function.py b/pandas/compat/numpy/function.py index 46b508eaa50f5..a1fd4353b02a8 100644 --- a/pandas/compat/numpy/function.py +++ b/pandas/compat/numpy/function.py @@ -154,6 +154,7 @@ def validate_argsort_with_ascending(ascending: bool | int | None, args, kwargs) 'None', so check if the 'ascending' parameter has either integer type or is None, since 'ascending' itself should be a boolean """ + ascend = False if is_integer(ascending) or ascending is None: args = (ascending,) + args ascend = True