Skip to content

Commit 1f7f9b8

Browse files
committed
DOC: Fix GH24143
1 parent 949b148 commit 1f7f9b8

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

pandas/core/indexes/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,12 +2110,12 @@ def get_duplicates(self):
21102110
"""
21112111
Extract duplicated index elements.
21122112
2113-
Returns a sorted list of index elements which appear more than once in
2114-
the index.
2115-
21162113
.. deprecated:: 0.23.0
21172114
Use idx[idx.duplicated()].unique() instead
21182115
2116+
Returns a sorted list of index elements which appear more than once in
2117+
the index.
2118+
21192119
Returns
21202120
-------
21212121
array-like

pandas/core/indexes/multi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,11 +1484,11 @@ def to_hierarchical(self, n_repeat, n_shuffle=1):
14841484
Return a MultiIndex reshaped to conform to the
14851485
shapes given by n_repeat and n_shuffle.
14861486
1487+
.. deprecated:: 0.24.0
1488+
14871489
Useful to replicate and rearrange a MultiIndex for combination
14881490
with another Index with n_repeat items.
14891491
1490-
.. deprecated:: 0.24.0
1491-
14921492
Parameters
14931493
----------
14941494
n_repeat : int

pandas/core/series.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,12 +1082,12 @@ def set_value(self, label, value, takeable=False):
10821082
"""
10831083
Quickly set single value at passed label.
10841084
1085-
If label is not contained, a new object is created with the label
1086-
placed at the end of the result index.
1087-
10881085
.. deprecated:: 0.21.0
10891086
Please use .at[] or .iat[] accessors.
10901087
1088+
If label is not contained, a new object is created with the label
1089+
placed at the end of the result index.
1090+
10911091
Parameters
10921092
----------
10931093
label : object

pandas/io/stata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
_data_method_doc = """\
120120
Reads observations from Stata file, converting them into a dataframe
121121
122-
.. deprecated::
123-
This is a legacy method. Use `read` in new code.
122+
.. deprecated::
123+
This is a legacy method. Use `read` in new code.
124124
125125
Parameters
126126
----------

scripts/tests/test_validate_docstrings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,20 @@ def sections_in_wrong_order(self):
407407
before Examples.
408408
"""
409409

410+
def deprecation_in_wrong_order(self):
411+
"""
412+
This is what old method does.
413+
414+
This is an extended summary with more details about
415+
what `some_old_method` does.
416+
417+
The extended summary can contain multiple paragraphs.
418+
419+
.. deprecated:: 1.0
420+
This should generate an error as it needs to go before
421+
extended summary.
422+
"""
423+
410424
def method_wo_docstrings(self):
411425
pass
412426

@@ -772,6 +786,8 @@ def test_bad_generic_functions(self, func):
772786
('BadGenericDocStrings', 'sections_in_wrong_order',
773787
('Sections are in the wrong order. Correct order is: Parameters, '
774788
'See Also, Examples',)),
789+
('BadGenericDocStrings', 'deprecation_in_wrong_order',
790+
('Deprecation warning should precede extended summary',)),
775791
('BadSeeAlso', 'desc_no_period',
776792
('Missing period at end of description for See Also "Series.iloc"',)),
777793
('BadSeeAlso', 'desc_first_letter_lowercase',

scripts/validate_docstrings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
'GL07': 'Sections are in the wrong order. Correct order is: '
8080
'{correct_sections}',
8181
'GL08': 'The object does not have a docstring',
82+
'GL09': 'Deprecation warning should precede extended summary',
8283
'SS01': 'No summary found (a short summary in a single line should be '
8384
'present at the beginning of the docstring)',
8485
'SS02': 'Summary does not start with a capital letter',
@@ -624,6 +625,10 @@ def get_validation_data(doc):
624625
errs.append(error('GL07',
625626
correct_sections=', '.join(correct_order)))
626627

628+
if (doc.deprecated and not doc.name.startswith('pandas.Panel')
629+
and not doc.extended_summary.startswith('.. deprecated:: ')):
630+
errs.append(error('GL09'))
631+
627632
if not doc.summary:
628633
errs.append(error('SS01'))
629634
else:
@@ -857,6 +862,7 @@ def header(title, width=80, char='#'):
857862

858863
else:
859864
result = validate_one(func_name)
865+
860866
sys.stderr.write(header('Docstring ({})'.format(func_name)))
861867
sys.stderr.write('{}\n'.format(result['docstring']))
862868
sys.stderr.write(header('Validation'))

0 commit comments

Comments
 (0)