From 76db26390d3914e8604deb830cc5f217c0926daf Mon Sep 17 00:00:00 2001 From: Benjamin Thomas Schwertfeger Date: Sun, 27 Sep 2026 08:59:45 +0200 Subject: [PATCH 1/2] Only warn on explicit get_trade_volume fee_info use --- src/kraken/spot/user.py | 23 ++++++++++++----------- tests/spot/test_spot_user.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/kraken/spot/user.py b/src/kraken/spot/user.py index d413ef9..dd6f05d 100644 --- a/src/kraken/spot/user.py +++ b/src/kraken/spot/user.py @@ -916,7 +916,7 @@ def get_trade_volume( self: User, pair: str | list[str] | None = None, *, - fee_info: bool = True, + fee_info: bool | None = None, fee_schedule: bool | None = None, extra_params: dict | None = None, ) -> dict: @@ -930,9 +930,9 @@ def get_trade_volume( :param pair: Asset pair, list of asset pairs or comma delimited list (as string) of asset pairs to filter :type pair: str | list[str], optional - :param fee_info: Deprecated and without effect (default: ``True``). + :param fee_info: Deprecated and without effect (default: ``None``). Kraken now derives fee inclusion from ``pair`` alone and treats - this as a legacy no-op parameter. Calling this method emits a + this as a legacy no-op parameter. Passing it emits a ``DeprecationWarning``; the parameter will be removed in a future release. :type fee_info: bool, optional @@ -1004,14 +1004,15 @@ def get_trade_volume( } """ - warnings.warn( - f"`fee_info={fee_info}` has no effect: Kraken now derives fee" - " inclusion from `pair` alone, treating `fee_info` as a legacy" - " no-op parameter. It will be removed in a future release. See" - " https://docs.kraken.com/api/docs/rest-api/get-trade-volume", - category=DeprecationWarning, - stacklevel=3, - ) + if defined(fee_info): + warnings.warn( + f"`fee_info={fee_info}` has no effect: Kraken now derives fee" + " inclusion from `pair` alone, treating `fee_info` as a legacy" + " no-op parameter. It will be removed in a future release. See" + " https://docs.kraken.com/api/docs/rest-api/get-trade-volume", + category=DeprecationWarning, + stacklevel=3, + ) params: dict = {} if defined(pair): params["pair"] = pair diff --git a/tests/spot/test_spot_user.py b/tests/spot/test_spot_user.py index b2dd66f..d438bb1 100644 --- a/tests/spot/test_spot_user.py +++ b/tests/spot/test_spot_user.py @@ -11,6 +11,7 @@ import random import tempfile +import warnings from contextlib import suppress from datetime import datetime from pathlib import Path @@ -73,6 +74,33 @@ def test_get_trade_volume_fee_schedule_serialization( User().get_trade_volume(fee_schedule=fee_schedule) assert request.call_args.kwargs["params"]["fee_schedule"] == expected + def test_get_trade_volume_no_warning_by_default(self: Self) -> None: + """ + Checks that ``get_trade_volume`` does not emit a ``DeprecationWarning`` + when the caller never passes ``fee_info``. + """ + with ( + mock.patch.object(User, "request", return_value={}), + warnings.catch_warnings(), + ): + warnings.simplefilter("error") + User().get_trade_volume() + + @pytest.mark.parametrize("fee_info", [True, False]) + def test_get_trade_volume_warns_on_explicit_fee_info( + self: Self, + fee_info: bool, + ) -> None: + """ + Checks that ``get_trade_volume`` emits a ``DeprecationWarning`` when + the caller explicitly passes ``fee_info``, regardless of its value. + """ + with ( + mock.patch.object(User, "request", return_value={}), + pytest.warns(DeprecationWarning, match="fee_info"), + ): + User().get_trade_volume(fee_info=fee_info) + @pytest.mark.integration @pytest.mark.spot From 083e42661491efd58016e5c3f2e62c4babe7fea3 Mon Sep 17 00:00:00 2001 From: Benjamin Thomas Schwertfeger Date: Sun, 27 Sep 2026 09:14:11 +0200 Subject: [PATCH 2/2] Drop unit tests for get_trade_volume fee_info warning --- tests/spot/test_spot_user.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/tests/spot/test_spot_user.py b/tests/spot/test_spot_user.py index d438bb1..b2dd66f 100644 --- a/tests/spot/test_spot_user.py +++ b/tests/spot/test_spot_user.py @@ -11,7 +11,6 @@ import random import tempfile -import warnings from contextlib import suppress from datetime import datetime from pathlib import Path @@ -74,33 +73,6 @@ def test_get_trade_volume_fee_schedule_serialization( User().get_trade_volume(fee_schedule=fee_schedule) assert request.call_args.kwargs["params"]["fee_schedule"] == expected - def test_get_trade_volume_no_warning_by_default(self: Self) -> None: - """ - Checks that ``get_trade_volume`` does not emit a ``DeprecationWarning`` - when the caller never passes ``fee_info``. - """ - with ( - mock.patch.object(User, "request", return_value={}), - warnings.catch_warnings(), - ): - warnings.simplefilter("error") - User().get_trade_volume() - - @pytest.mark.parametrize("fee_info", [True, False]) - def test_get_trade_volume_warns_on_explicit_fee_info( - self: Self, - fee_info: bool, - ) -> None: - """ - Checks that ``get_trade_volume`` emits a ``DeprecationWarning`` when - the caller explicitly passes ``fee_info``, regardless of its value. - """ - with ( - mock.patch.object(User, "request", return_value={}), - pytest.warns(DeprecationWarning, match="fee_info"), - ): - User().get_trade_volume(fee_info=fee_info) - @pytest.mark.integration @pytest.mark.spot