Skip to content

TYP: fix mypy ignored error in pandas/compat/numpy/function.py #50104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10 changes: 5 additions & 5 deletions pandas/compat/numpy/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ 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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't defined in the False case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I remove the variable and return True instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to make sure ascend is defined in the False case



CLIP_DEFAULTS: dict[str, Any] = {"out": None}
Expand Down Expand Up @@ -192,12 +192,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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here, you need to make srue axes is defined in the other case


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] = {}
Expand Down