Skip to content

Commit 2b3037a

Browse files
authored
CLN: Enforce nonkeyword deprecations (#57405)
1 parent 38ac713 commit 2b3037a

File tree

5 files changed

+8
-20
lines changed

5 files changed

+8
-20
lines changed

doc/source/whatsnew/v3.0.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ Deprecations
105105
Removal of prior version deprecations/changes
106106
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
107107
- :func:`read_excel`, :func:`read_json`, :func:`read_html`, and :func:`read_xml` no longer accept raw string or byte representation of the data. That type of data must be wrapped in a :py:class:`StringIO` or :py:class:`BytesIO` (:issue:`53767`)
108+
- All arguments except ``name`` in :meth:`Index.rename` are now keyword only (:issue:`56493`)
108109
- All arguments except the first ``path``-like argument in IO writers are now keyword only (:issue:`54229`)
110+
- All arguments in :meth:`Index.sort_values` are now keyword only (:issue:`56493`)
111+
- All arguments in :meth:`Series.to_dict` are now keyword only (:issue:`56493`)
109112
- Changed the default value of ``observed`` in :meth:`DataFrame.groupby` and :meth:`Series.groupby` to ``True`` (:issue:`51811`)
110113
- Enforced silent-downcasting deprecation for :ref:`all relevant methods <whatsnew_220.silent_downcasting>` (:issue:`54710`)
111114
- Removed ``DataFrame.applymap``, ``Styler.applymap`` and ``Styler.applymap_index`` (:issue:`52364`)

pandas/core/frame.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
from pandas.util._decorators import (
6464
Appender,
6565
Substitution,
66-
deprecate_nonkeyword_arguments,
6766
doc,
6867
)
6968
from pandas.util._exceptions import (
@@ -3195,16 +3194,14 @@ def to_xml(
31953194
) -> None:
31963195
...
31973196

3198-
@deprecate_nonkeyword_arguments(
3199-
version="3.0", allowed_args=["self", "path_or_buffer"], name="to_xml"
3200-
)
32013197
@doc(
32023198
storage_options=_shared_docs["storage_options"],
32033199
compression_options=_shared_docs["compression_options"] % "path_or_buffer",
32043200
)
32053201
def to_xml(
32063202
self,
32073203
path_or_buffer: FilePath | WriteBuffer[bytes] | WriteBuffer[str] | None = None,
3204+
*,
32083205
index: bool = True,
32093206
root_name: str | None = "data",
32103207
row_name: str | None = "row",

pandas/core/indexes/base.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
from pandas.util._decorators import (
7272
Appender,
7373
cache_readonly,
74-
deprecate_nonkeyword_arguments,
7574
doc,
7675
)
7776
from pandas.util._exceptions import (
@@ -1891,10 +1890,7 @@ def rename(self, name, *, inplace: Literal[False] = ...) -> Self:
18911890
def rename(self, name, *, inplace: Literal[True]) -> None:
18921891
...
18931892

1894-
@deprecate_nonkeyword_arguments(
1895-
version="3.0", allowed_args=["self", "name"], name="rename"
1896-
)
1897-
def rename(self, name, inplace: bool = False) -> Self | None:
1893+
def rename(self, name, *, inplace: bool = False) -> Self | None:
18981894
"""
18991895
Alter Index or MultiIndex name.
19001896
@@ -5503,11 +5499,9 @@ def sort_values(
55035499
) -> Self | tuple[Self, np.ndarray]:
55045500
...
55055501

5506-
@deprecate_nonkeyword_arguments(
5507-
version="3.0", allowed_args=["self"], name="sort_values"
5508-
)
55095502
def sort_values(
55105503
self,
5504+
*,
55115505
return_indexer: bool = False,
55125506
ascending: bool = True,
55135507
na_position: NaPosition = "last",

pandas/core/indexes/range.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from pandas.compat.numpy import function as nv
2828
from pandas.util._decorators import (
2929
cache_readonly,
30-
deprecate_nonkeyword_arguments,
3130
doc,
3231
)
3332

@@ -592,11 +591,9 @@ def sort_values(
592591
) -> Self | tuple[Self, np.ndarray | RangeIndex]:
593592
...
594593

595-
@deprecate_nonkeyword_arguments(
596-
version="3.0", allowed_args=["self"], name="sort_values"
597-
)
598594
def sort_values(
599595
self,
596+
*,
600597
return_indexer: bool = False,
601598
ascending: bool = True,
602599
na_position: NaPosition = "last",

pandas/core/series.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
from pandas.util._decorators import (
4747
Appender,
4848
Substitution,
49-
deprecate_nonkeyword_arguments,
5049
doc,
5150
)
5251
from pandas.util._exceptions import find_stack_level
@@ -1736,11 +1735,9 @@ def to_dict(self, *, into: type[dict] = ...) -> dict:
17361735

17371736
# error: Incompatible default for argument "into" (default has type "type[
17381737
# dict[Any, Any]]", argument has type "type[MutableMappingT] | MutableMappingT")
1739-
@deprecate_nonkeyword_arguments(
1740-
version="3.0", allowed_args=["self"], name="to_dict"
1741-
)
17421738
def to_dict(
17431739
self,
1740+
*,
17441741
into: type[MutableMappingT] | MutableMappingT = dict, # type: ignore[assignment]
17451742
) -> MutableMappingT:
17461743
"""

0 commit comments

Comments
 (0)