Skip to content

Commit 62a69be

Browse files
authored
DOC: Add numpydoc SS06 validation (#47885)
1 parent 2a082fd commit 62a69be

37 files changed

+242
-236
lines changed

ci/code_checks.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ fi
7878
### DOCSTRINGS ###
7979
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8080

81-
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)' ; echo $MSG
82-
$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
81+
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
82+
$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
8383
RET=$(($RET + $?)) ; echo $MSG "DONE"
8484

8585
fi

pandas/_config/config.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ class RegisteredOption(NamedTuple):
102102

103103
class OptionError(AttributeError, KeyError):
104104
"""
105-
Exception for pandas.options, backwards compatible with KeyError
106-
checks.
105+
Exception raised for pandas.options.
106+
107+
Backwards compatible with KeyError checks.
107108
"""
108109

109110

pandas/_libs/interval.pyx

+6-4
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,9 @@ cdef class Interval(IntervalMixin):
352352

353353
cdef readonly str inclusive
354354
"""
355-
Whether the interval is inclusive on the left-side, right-side, both or
356-
neither.
355+
String describing the inclusive side the intervals.
356+
357+
Either ``left``, ``right``, ``both`` or ``neither``.
357358
"""
358359

359360
def __init__(self, left, right, inclusive: str | None = None, closed: None | lib.NoDefault = lib.no_default):
@@ -384,10 +385,11 @@ cdef class Interval(IntervalMixin):
384385
@property
385386
def closed(self):
386387
"""
387-
Whether the interval is closed on the left-side, right-side, both or
388-
neither.
388+
String describing the inclusive side the intervals.
389389
390390
.. deprecated:: 1.5.0
391+
392+
Either ``left``, ``right``, ``both`` or ``neither``.
391393
"""
392394
warnings.warn(
393395
"Attribute `closed` is deprecated in favor of `inclusive`.",

pandas/_libs/lib.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,7 @@ cdef object _try_infer_map(object dtype):
13471347

13481348
def infer_dtype(value: object, skipna: bool = True) -> str:
13491349
"""
1350-
Efficiently infer the type of a passed val, or list-like
1351-
array of values. Return a string describing the type.
1350+
Return a string label of the type of a scalar or list-like of values.
13521351

13531352
Parameters
13541353
----------

pandas/_libs/tslibs/nattype.pyx

+14-16
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,15 @@ class NaTType(_NaT):
446446
"weekday",
447447
"""
448448
Return the day of the week represented by the date.
449+
449450
Monday == 0 ... Sunday == 6.
450451
""",
451452
)
452453
isoweekday = _make_nan_func(
453454
"isoweekday",
454455
"""
455456
Return the day of the week represented by the date.
457+
456458
Monday == 1 ... Sunday == 7.
457459
""",
458460
)
@@ -533,10 +535,7 @@ class NaTType(_NaT):
533535
strftime = _make_error_func(
534536
"strftime",
535537
"""
536-
Timestamp.strftime(format)
537-
538-
Return a string representing the given POSIX timestamp
539-
controlled by an explicit format string.
538+
Return a formatted string of the Timestamp.
540539
541540
Parameters
542541
----------
@@ -680,10 +679,7 @@ class NaTType(_NaT):
680679
fromordinal = _make_error_func(
681680
"fromordinal",
682681
"""
683-
Timestamp.fromordinal(ordinal, freq=None, tz=None)
684-
685-
Passed an ordinal, translate and convert to a ts.
686-
Note: by definition there cannot be any tz info on the ordinal itself.
682+
Construct a timestamp from a a proleptic Gregorian ordinal.
687683
688684
Parameters
689685
----------
@@ -694,6 +690,10 @@ class NaTType(_NaT):
694690
tz : str, pytz.timezone, dateutil.tz.tzfile or None
695691
Time zone for the Timestamp.
696692
693+
Notes
694+
-----
695+
By definition there cannot be any tz info on the ordinal itself.
696+
697697
Examples
698698
--------
699699
>>> pd.Timestamp.fromordinal(737425)
@@ -725,10 +725,7 @@ class NaTType(_NaT):
725725
now = _make_nat_func(
726726
"now",
727727
"""
728-
Timestamp.now(tz=None)
729-
730-
Return new Timestamp object representing current time local to
731-
tz.
728+
Return new Timestamp object representing current time local to tz.
732729
733730
Parameters
734731
----------
@@ -749,10 +746,9 @@ class NaTType(_NaT):
749746
today = _make_nat_func(
750747
"today",
751748
"""
752-
Timestamp.today(cls, tz=None)
749+
Return the current time in the local timezone.
753750
754-
Return the current time in the local timezone. This differs
755-
from datetime.today() in that it can be localized to a
751+
This differs from datetime.today() in that it can be localized to a
756752
passed timezone.
757753
758754
Parameters
@@ -1090,7 +1086,9 @@ timedelta}, default 'raise'
10901086
tz_localize = _make_nat_func(
10911087
"tz_localize",
10921088
"""
1093-
Convert naive Timestamp to local time zone, or remove
1089+
Localize the Timestamp to a timezone.
1090+
1091+
Convert naive Timestamp to local time zone or remove
10941092
timezone from timezone-aware Timestamp.
10951093
10961094
Parameters

pandas/_libs/tslibs/np_datetime.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ cdef inline bint cmp_scalar(int64_t lhs, int64_t rhs, int op) except -1:
156156

157157
class OutOfBoundsDatetime(ValueError):
158158
"""
159-
Raised when the datetime is outside the range that
160-
can be represented.
159+
Raised when the datetime is outside the range that can be represented.
161160
"""
162161
pass
163162

164163

165164
class OutOfBoundsTimedelta(ValueError):
166165
"""
167-
Raised when encountering a timedelta value that cannot be represented
168-
as a timedelta64[ns].
166+
Raised when encountering a timedelta value that cannot be represented.
167+
168+
Representation should be within a timedelta64[ns].
169169
"""
170170
# Timedelta analogue to OutOfBoundsDatetime
171171
pass

pandas/_libs/tslibs/offsets.pyx

+10-13
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,7 @@ cdef class BaseOffset:
585585

586586
def apply_index(self, dtindex):
587587
"""
588-
Vectorized apply of DateOffset to DatetimeIndex,
589-
raises NotImplementedError for offsets without a
590-
vectorized implementation.
588+
Vectorized apply of DateOffset to DatetimeIndex.
591589
592590
.. deprecated:: 1.1.0
593591
@@ -2448,8 +2446,7 @@ cdef class SemiMonthOffset(SingleConstructorOffset):
24482446

24492447
cdef class SemiMonthEnd(SemiMonthOffset):
24502448
"""
2451-
Two DateOffset's per month repeating on the last
2452-
day of the month and day_of_month.
2449+
Two DateOffset's per month repeating on the last day of the month & day_of_month.
24532450
24542451
Parameters
24552452
----------
@@ -2470,8 +2467,7 @@ cdef class SemiMonthEnd(SemiMonthOffset):
24702467

24712468
cdef class SemiMonthBegin(SemiMonthOffset):
24722469
"""
2473-
Two DateOffset's per month repeating on the first
2474-
day of the month and day_of_month.
2470+
Two DateOffset's per month repeating on the first day of the month & day_of_month.
24752471
24762472
Parameters
24772473
----------
@@ -2704,8 +2700,9 @@ cdef class WeekOfMonth(WeekOfMonthMixin):
27042700

27052701
cdef class LastWeekOfMonth(WeekOfMonthMixin):
27062702
"""
2707-
Describes monthly dates in last week of month like "the last Tuesday of
2708-
each month".
2703+
Describes monthly dates in last week of month.
2704+
2705+
For example "the last Tuesday of each month".
27092706
27102707
Parameters
27112708
----------
@@ -2991,8 +2988,9 @@ cdef class FY5253(FY5253Mixin):
29912988

29922989
cdef class FY5253Quarter(FY5253Mixin):
29932990
"""
2994-
DateOffset increments between business quarter dates
2995-
for 52-53 week fiscal year (also known as a 4-4-5 calendar).
2991+
DateOffset increments between business quarter dates for 52-53 week fiscal year.
2992+
2993+
Also known as a 4-4-5 calendar.
29962994
29972995
It is used by companies that desire that their
29982996
fiscal year always end on the same day of the week.
@@ -3602,8 +3600,7 @@ def _get_offset(name: str) -> BaseOffset:
36023600

36033601
cpdef to_offset(freq):
36043602
"""
3605-
Return DateOffset object from string or tuple representation
3606-
or datetime.timedelta object.
3603+
Return DateOffset object from string or datetime.timedelta object.
36073604
36083605
Parameters
36093606
----------

pandas/_libs/tslibs/period.pyx

+6-6
Original file line numberDiff line numberDiff line change
@@ -2322,12 +2322,12 @@ cdef class _Period(PeriodMixin):
23222322

23232323
def strftime(self, fmt: str) -> str:
23242324
r"""
2325-
Returns the string representation of the :class:`Period`, depending
2326-
on the selected ``fmt``. ``fmt`` must be a string
2327-
containing one or several directives. The method recognizes the same
2328-
directives as the :func:`time.strftime` function of the standard Python
2329-
distribution, as well as the specific additional directives ``%f``,
2330-
``%F``, ``%q``, ``%l``, ``%u``, ``%n``.
2325+
Returns a formatted string representation of the :class:`Period`.
2326+
2327+
``fmt`` must be a string containing one or several directives.
2328+
The method recognizes the same directives as the :func:`time.strftime`
2329+
function of the standard Python distribution, as well as the specific
2330+
additional directives ``%f``, ``%F``, ``%q``, ``%l``, ``%u``, ``%n``.
23312331
(formatting & docs originally from scikits.timeries).
23322332

23332333
+-----------+--------------------------------+-------+

pandas/_libs/tslibs/timedeltas.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,8 @@ cdef class _Timedelta(timedelta):
14641464

14651465
def isoformat(self) -> str:
14661466
"""
1467-
Format Timedelta as ISO 8601 Duration like
1467+
Format the Timedelta as ISO 8601 Duration.
1468+
14681469
``P[n]Y[n]M[n]DT[n]H[n]M[n]S``, where the ``[n]`` s are replaced by the
14691470
values. See https://en.wikipedia.org/wiki/ISO_8601#Durations.
14701471

pandas/_libs/tslibs/timestamps.pyx

+15-16
Original file line numberDiff line numberDiff line change
@@ -1345,10 +1345,7 @@ class Timestamp(_Timestamp):
13451345
@classmethod
13461346
def fromordinal(cls, ordinal, freq=None, tz=None):
13471347
"""
1348-
Timestamp.fromordinal(ordinal, freq=None, tz=None)
1349-
1350-
Passed an ordinal, translate and convert to a ts.
1351-
Note: by definition there cannot be any tz info on the ordinal itself.
1348+
Construct a timestamp from a a proleptic Gregorian ordinal.
13521349
13531350
Parameters
13541351
----------
@@ -1359,6 +1356,10 @@ class Timestamp(_Timestamp):
13591356
tz : str, pytz.timezone, dateutil.tz.tzfile or None
13601357
Time zone for the Timestamp.
13611358
1359+
Notes
1360+
-----
1361+
By definition there cannot be any tz info on the ordinal itself.
1362+
13621363
Examples
13631364
--------
13641365
>>> pd.Timestamp.fromordinal(737425)
@@ -1370,10 +1371,7 @@ class Timestamp(_Timestamp):
13701371
@classmethod
13711372
def now(cls, tz=None):
13721373
"""
1373-
Timestamp.now(tz=None)
1374-
1375-
Return new Timestamp object representing current time local to
1376-
tz.
1374+
Return new Timestamp object representing current time local to tz.
13771375
13781376
Parameters
13791377
----------
@@ -1397,10 +1395,9 @@ class Timestamp(_Timestamp):
13971395
@classmethod
13981396
def today(cls, tz=None):
13991397
"""
1400-
Timestamp.today(cls, tz=None)
1398+
Return the current time in the local timezone.
14011399
1402-
Return the current time in the local timezone. This differs
1403-
from datetime.today() in that it can be localized to a
1400+
This differs from datetime.today() in that it can be localized to a
14041401
passed timezone.
14051402
14061403
Parameters
@@ -1477,10 +1474,7 @@ class Timestamp(_Timestamp):
14771474

14781475
def strftime(self, format):
14791476
"""
1480-
Timestamp.strftime(format)
1481-
1482-
Return a string representing the given POSIX timestamp
1483-
controlled by an explicit format string.
1477+
Return a formatted string of the Timestamp.
14841478
14851479
Parameters
14861480
----------
@@ -2052,7 +2046,9 @@ timedelta}, default 'raise'
20522046

20532047
def tz_localize(self, tz, ambiguous='raise', nonexistent='raise'):
20542048
"""
2055-
Convert naive Timestamp to local time zone, or remove
2049+
Localize the Timestamp to a timezone.
2050+
2051+
Convert naive Timestamp to local time zone or remove
20562052
timezone from timezone-aware Timestamp.
20572053
20582054
Parameters
@@ -2343,6 +2339,7 @@ default 'raise'
23432339
def to_julian_date(self) -> np.float64:
23442340
"""
23452341
Convert TimeStamp to a Julian Date.
2342+
23462343
0 Julian date is noon January 1, 4713 BC.
23472344

23482345
Examples
@@ -2374,6 +2371,7 @@ default 'raise'
23742371
def isoweekday(self):
23752372
"""
23762373
Return the day of the week represented by the date.
2374+
23772375
Monday == 1 ... Sunday == 7.
23782376
"""
23792377
# same as super().isoweekday(), but that breaks because of how
@@ -2383,6 +2381,7 @@ default 'raise'
23832381
def weekday(self):
23842382
"""
23852383
Return the day of the week represented by the date.
2384+
23862385
Monday == 0 ... Sunday == 6.
23872386
"""
23882387
# same as super().weekday(), but that breaks because of how

pandas/core/arrays/datetimelike.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -953,9 +953,9 @@ def freqstr(self) -> str | None:
953953
@property # NB: override with cache_readonly in immutable subclasses
954954
def inferred_freq(self) -> str | None:
955955
"""
956-
Tries to return a string representing a frequency guess,
957-
generated by infer_freq. Returns None if it can't autodetect the
958-
frequency.
956+
Tries to return a string representing a frequency generated by infer_freq.
957+
958+
Returns None if it can't autodetect the frequency.
959959
"""
960960
if self.ndim != 1:
961961
return None

0 commit comments

Comments
 (0)