Skip to content

DOC: Fix some RT02 issues in docstrings #50896

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

Merged
merged 2 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,8 @@ fi
### DOCSTRINGS ###
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Validate docstrings (EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Partially validate docstrings (RT02)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=RT02 --ignore_functions \
pandas.Index.all \
pandas.Index.any \
pandas.MultiIndex.drop \
pandas.DatetimeIndex.to_pydatetime \
pandas.TimedeltaIndex.to_pytimedelta \
pandas.io.formats.style.Styler.export \
pandas.api.extensions.ExtensionArray.astype \
pandas.api.extensions.ExtensionArray.dropna \
pandas.api.extensions.ExtensionArray.isna \
pandas.api.extensions.ExtensionArray.repeat \
pandas.api.extensions.ExtensionArray.unique
MSG='Validate docstrings (EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
RET=$(($RET + $?)) ; echo $MSG "DONE"

fi
Expand Down
10 changes: 5 additions & 5 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike:

Returns
-------
array : np.ndarray or ExtensionArray
np.ndarray or pandas.api.extensions.ExtensionArray
An ExtensionArray if dtype is ExtensionDtype,
Otherwise a NumPy ndarray with 'dtype' for its dtype.
"""
Expand Down Expand Up @@ -600,7 +600,7 @@ def isna(self) -> np.ndarray | ExtensionArraySupportsAnyAll:

Returns
-------
na_values : Union[np.ndarray, ExtensionArray]
numpy.ndarray or pandas.api.extensions.ExtensionArray
In most cases, this should return a NumPy ndarray. For
exceptional cases like ``SparseArray``, where returning
an ndarray would be expensive, an ExtensionArray may be
Expand Down Expand Up @@ -819,7 +819,7 @@ def dropna(self: ExtensionArrayT) -> ExtensionArrayT:

Returns
-------
valid : ExtensionArray
pandas.api.extensions.ExtensionArray
"""
# error: Unsupported operand type for ~ ("ExtensionArray")
return self[~self.isna()] # type: ignore[operator]
Expand Down Expand Up @@ -880,7 +880,7 @@ def unique(self: ExtensionArrayT) -> ExtensionArrayT:

Returns
-------
uniques : ExtensionArray
pandas.api.extensions.ExtensionArray
"""
uniques = unique(self.astype(object))
return self._from_sequence(uniques, dtype=self.dtype)
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def factorize(

Returns
-------
repeated_array : %(klass)s
%(klass)s
Newly created %(klass)s with repeated elements.

See Also
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ def to_pydatetime(self) -> npt.NDArray[np.object_]:

Returns
-------
datetimes : ndarray[object]
numpy.ndarray
"""
return ints_to_pydatetime(self.asi8, tz=self.tz, reso=self._creso)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:

Returns
-------
timedeltas : ndarray[object]
numpy.ndarray
"""
return ints_to_pytimedelta(self._ndarray)

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6680,7 +6680,7 @@ def any(self, *args, **kwargs):

Returns
-------
any : bool or array-like (if axis is specified)
bool or array-like (if axis is specified)
A single element array-like may be converted to bool.

See Also
Expand Down Expand Up @@ -6724,7 +6724,7 @@ def all(self, *args, **kwargs):

Returns
-------
all : bool or array-like (if axis is specified)
bool or array-like (if axis is specified)
A single element array-like may be converted to bool.

See Also
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ def drop( # type: ignore[override]

Returns
-------
dropped : MultiIndex
MultiIndex
"""
if level is not None:
return self._drop_from_level(codes, level, errors)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ def repeat(self, repeats):

Returns
-------
Series or Index of object
Series or pandas.Index
Series or Index of repeated string objects specified by
input parameter repeats.

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ def export(self) -> dict[str, Any]:

Returns
-------
styles : dict
dict

See Also
--------
Expand Down