Skip to content

Commit cbe88f3

Browse files
rsm-23mroeschke
andauthored
DEPR: make arguments keyword only in to_clipboard (#54634)
* made arguments keyword only * added whatsnew * deprecated nonkeyword arguments * corrected typo * Update pandas/core/generic.py Co-authored-by: Matthew Roeschke <[email protected]> * added test --------- Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 47ae3f0 commit cbe88f3

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

doc/source/whatsnew/v2.2.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Other API changes
9292

9393
Deprecations
9494
~~~~~~~~~~~~
95+
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_clipboard`. (:issue:`54229`)
9596
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_csv` except ``path_or_buf``. (:issue:`54229`)
9697
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_hdf` except ``path_or_buf``. (:issue:`54229`)
9798
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_html` except ``buf``. (:issue:`54229`)

pandas/core/generic.py

+3
Original file line numberDiff line numberDiff line change
@@ -3096,6 +3096,9 @@ def to_pickle(
30963096
)
30973097

30983098
@final
3099+
@deprecate_nonkeyword_arguments(
3100+
version="3.0", allowed_args=["self"], name="to_clipboard"
3101+
)
30993102
def to_clipboard(
31003103
self, excel: bool_t = True, sep: str | None = None, **kwargs
31013104
) -> None:

pandas/tests/io/test_clipboard.py

+10
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,13 @@ def test_invalid_dtype_backend(self):
471471
)
472472
with pytest.raises(ValueError, match=msg):
473473
read_clipboard(dtype_backend="numpy")
474+
475+
def test_to_clipboard_pos_args_deprecation(self):
476+
# GH-54229
477+
df = DataFrame({"a": [1, 2, 3]})
478+
msg = (
479+
r"Starting with pandas version 3.0 all arguments of to_clipboard "
480+
r"will be keyword-only."
481+
)
482+
with tm.assert_produces_warning(FutureWarning, match=msg):
483+
df.to_clipboard(True, None)

0 commit comments

Comments
 (0)