Skip to content

Commit 5e0070e

Browse files
Cleanup
1 parent d4e6d09 commit 5e0070e

File tree

7 files changed

+68
-44
lines changed

7 files changed

+68
-44
lines changed

.github/workflows/_test_futures_private.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ jobs:
8989
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
9090
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
9191
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
92-
run: pytest -vv -m "futures and futures_auth and not futures_websocket and not flaky" tests
92+
run: pytest -vv -m "futures and futures_auth and not futures_websocket" tests
9393

9494
- name: Testing Futures websocket client
9595
env:
9696
FUTURES_API_KEY: ${{ secrets.FUTURES_API_KEY }}
9797
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
9898
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
9999
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
100-
run: pytest -vv -m "futures and futures_auth and futures_websocket and not flaky" tests
100+
run: pytest -vv -m "futures and futures_auth and futures_websocket" tests

Makefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ PYTEST_OPTS := -vv --junit-xml=pytest.xml
1111
PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov --cov-report=xml:coverage.xml --cov-report=term
1212
TEST_DIR := tests
1313

14-
## ======= H E L P =======
14+
## ======= M A K E F I L E - T A R G E T S =====================================
15+
## help Show this help message
16+
##
1517
.PHONY: help
1618
help:
1719
@grep "^##" Makefile | sed -e "s/##//"
1820

19-
## ======= B U I L D I N G =======
21+
## ======= B U I L D I N G =====================================================
2022
## build Builds the package
2123
##
2224
.PHONY: build
2325
build: check-uv
2426
$(UV) build .
2527

28+
## rebuild Rebuild the package
29+
##
2630
.PHONY: rebuild
2731
rebuild: clean build
2832

@@ -32,7 +36,7 @@ rebuild: clean build
3236
doc:
3337
cd doc && make html
3438

35-
## ======= I N S T A L L A T I O N =======
39+
## ======= I N S T A L L A T I O N =============================================
3640
## install Install the package
3741
##
3842
.PHONY: install
@@ -45,7 +49,7 @@ install: check-uv
4549
dev: check-uv
4650
$(UV) pip install -e ".[dev,test,examples,jupyter]"
4751

48-
## ======= T E S T I N G =======
52+
## ======= T E S T I N G =======================================================
4953
## test Run the unit tests
5054
##
5155
.PHONY: test
@@ -56,6 +60,8 @@ test:
5660
.PHONY: tests
5761
tests: test
5862

63+
## retest Run tests that failed in the last run
64+
##
5965
.PHONY: retest
6066
retest:
6167
@rm .cache/tests/*.log || true
@@ -68,7 +74,7 @@ wip:
6874
@rm .cache/tests/*.log || true
6975
$(PYTEST) -m "wip" -vv $(TEST_DIR)
7076

71-
## coverage Run all tests and generate the coverage report
77+
## coverage Run all tests and generate the coverage report
7278
##
7379
.PHONY: coverage
7480
coverage:
@@ -81,14 +87,15 @@ coverage:
8187
doctest:
8288
cd docs && make doctest
8389

84-
## ======= M I S C E L A N I O U S =======
90+
## ======= M I S C E L A N I O U S =============================================
8591
## pre-commit Run the pre-commit targets
8692
##
8793
.PHONY: pre-commit
8894
pre-commit:
8995
@pre-commit run -a
9096

91-
## ruff Run ruff without fix
97+
## ruff Run ruff without fix
98+
##
9299
.PHONY: ruff
93100
ruff:
94101
$(UVX) ruff check --preview .
@@ -141,7 +148,7 @@ clean:
141148
find src -name "__pycache__" | xargs rm -rf
142149
find examples -name "__pycache__" | xargs rm -rf
143150

144-
## check-uv Check if uv is installed
151+
## check-uv Check if uv is installed
145152
##
146153
.PHONY: check-uv
147154
check-uv:

pyproject.toml

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -114,37 +114,36 @@ cache_dir = ".cache/pytest"
114114
# Retrying tests once, as we're testing against lots of API endpoints, the tests
115115
# are flaky by design.
116116
retries = 1
117+
retry_delay = 1 # seconds
118+
timeout = 60 # seconds
119+
asyncio_mode = "auto"
120+
asyncio_default_fixture_loop_scope = "function"
117121

118122
markers = [
119123
"wip: Used to run a specific test by hand.",
120124
"flaky: Flaky tests",
121-
"spot: Spot endpoint.",
122-
"spot_auth: … authenticated Spot endpoint.",
123-
"spot_earn: Spot Earn endpoint.",
124-
"spot_trade: Spot Trade endpoint.",
125-
"spot_user: Spot User endpoint.",
126-
"spot_market: Spot Market endpoint.",
127-
"spot_funding: Spot Funding endpoint.",
128-
"spot_websocket: Spot Websocket client + Spot Orderbook client.",
129-
"spot_orderbook: Spot Orderbook client.",
130-
"futures: Futures endpoint.",
131-
"futures_auth: … authenticated Futures endpoint.",
132-
"futures_market: Futures Market endpoint.",
133-
"futures_user: Futures User endpoint.",
134-
"futures_trade: Futures Trade endpoint.",
135-
"futures_funding: Futures Funding endpoint.",
136-
"futures_websocket: Futures Websocket endpoint.",
137-
"nft: NFT endpoint.",
138-
"nft_auth: … authenticated NFT endpoint.",
139-
"nft_market: NFT Market endpoint.",
140-
"nft_trade: NFT Trade endpoint.",
125+
"spot: Spot endpoint.",
126+
"spot_auth: Private Spot endpoint.",
127+
"spot_earn: Spot Earn endpoint.",
128+
"spot_trade: Spot Trade endpoint.",
129+
"spot_user: Spot User endpoint.",
130+
"spot_market: Spot Market endpoint.",
131+
"spot_funding: Spot Funding endpoint.",
132+
"spot_websocket: Spot Websocket client + Spot Orderbook client.",
133+
"spot_orderbook: Spot Orderbook client.",
134+
"futures: Futures endpoint.",
135+
"futures_auth: Private Futures endpoint.",
136+
"futures_market: Futures Market endpoint.",
137+
"futures_user: Futures User endpoint.",
138+
"futures_trade: Futures Trade endpoint.",
139+
"futures_funding: Futures Funding endpoint.",
140+
"futures_websocket: Futures Websocket endpoint.",
141+
"nft: NFT endpoint.",
142+
"nft_auth: Private NFT endpoint.",
143+
"nft_market: NFT Market endpoint.",
144+
"nft_trade: NFT Trade endpoint.",
141145
]
142146

143-
asyncio_default_fixture_loop_scope = "function"
144-
145-
asyncio_mode = "auto"
146-
timeout = 60 # seconds
147-
148147
# filterwarnings = [
149148
# "ignore:The Kraken websocket API v1 is marked as deprecated*:DeprecationWarning",
150149
# ]

src/kraken/base_api/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
if TYPE_CHECKING:
2525
from collections.abc import Awaitable, Callable, Coroutine
2626
from typing import Final
27+
import warnings
2728

2829
Self = TypeVar("Self")
2930

@@ -663,6 +664,12 @@ async def __check_response_data( # pylint: disable=invalid-overridden-method
663664

664665
async def async_close(self: SpotAsyncClient) -> None:
665666
"""Closes the aiohttp session"""
667+
warnings.warn(
668+
"The 'async_close' function is deprecated and will be replaced by"
669+
" 'close' in a future release.",
670+
DeprecationWarning,
671+
stacklevel=2,
672+
)
666673
await self.__session.close()
667674

668675
async def __aenter__(self: Self) -> Self:
@@ -1144,6 +1151,12 @@ async def __check_response_data( # pylint: disable=invalid-overridden-method
11441151

11451152
async def async_close(self: FuturesAsyncClient) -> None:
11461153
"""Closes the aiohttp session"""
1154+
warnings.warn(
1155+
"The 'async_close' function is deprecated and will be replaced by"
1156+
" 'close' in a future release.",
1157+
DeprecationWarning,
1158+
stacklevel=2,
1159+
)
11471160
await self.__session.close()
11481161

11491162
async def __aenter__(self: Self) -> Self:

src/kraken/futures/ws_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
if TYPE_CHECKING:
2323
from collections.abc import Callable
2424
from typing import Any
25+
import warnings
2526

2627
Self = TypeVar("Self")
2728

@@ -155,6 +156,12 @@ async def start(self: FuturesWSClient) -> None:
155156

156157
async def stop(self: FuturesWSClient) -> None:
157158
"""Method to stop the websocket connection."""
159+
warnings.warn(
160+
"The 'stop' function is deprecated and will be replaced by"
161+
" 'close' in a future release.",
162+
DeprecationWarning,
163+
stacklevel=2,
164+
)
158165
if self._conn:
159166
await self._conn.stop()
160167

src/kraken/spot/websocket/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from __future__ import annotations
1111

1212
import logging
13+
import warnings
1314
from asyncio import sleep as async_sleep
1415
from typing import TYPE_CHECKING, Any, TypeVar
1516

@@ -139,6 +140,12 @@ async def start(self: SpotWSClientBase) -> None:
139140

140141
async def stop(self: SpotWSClientBase) -> None:
141142
"""Method to stop the websocket connection."""
143+
warnings.warn(
144+
"The 'stop' function is deprecated and will be replaced by"
145+
" 'close' in a future release.",
146+
DeprecationWarning,
147+
stacklevel=2,
148+
)
142149
if self._pub_conn:
143150
await self._pub_conn.stop()
144151
if self._priv_conn:

tests/futures/test_futures_user.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def test_get_notifications(futures_auth_user: User) -> None:
6060
assert is_success(futures_auth_user.get_notifications())
6161

6262

63-
@pytest.mark.flaky
6463
@pytest.mark.futures
6564
@pytest.mark.futures_auth
6665
@pytest.mark.futures_user
@@ -75,8 +74,6 @@ def test_get_account_log(futures_auth_user: User) -> None:
7574
)
7675

7776

78-
# FIXME: They often encounter 500 status_codes - maybe an error in Kraken's API
79-
@pytest.mark.flaky
8077
@pytest.mark.futures
8178
@pytest.mark.futures_auth
8279
@pytest.mark.futures_user
@@ -96,8 +93,6 @@ def test_get_account_log_csv(futures_auth_user: User) -> None:
9693
file.write(chunk)
9794

9895

99-
# FIXME: They often encounter 500 status_codes - maybe an error in Kraken's API
100-
@pytest.mark.flaky
10196
@pytest.mark.futures
10297
@pytest.mark.futures_auth
10398
@pytest.mark.futures_user
@@ -116,8 +111,6 @@ def test_get_execution_events(futures_auth_user: User) -> None:
116111
assert "elements" in result
117112

118113

119-
# FIXME: They often encounter 500 status_codes - maybe an error in Kraken's API
120-
@pytest.mark.flaky
121114
@pytest.mark.futures
122115
@pytest.mark.futures_auth
123116
@pytest.mark.futures_user
@@ -155,8 +148,6 @@ def test_get_open_positions(futures_auth_user: User) -> None:
155148
assert is_success(futures_auth_user.get_open_positions())
156149

157150

158-
# FIXME: They often encounter 500 status_codes - maybe an error in Kraken's API
159-
@pytest.mark.flaky
160151
@pytest.mark.futures
161152
@pytest.mark.futures_auth
162153
@pytest.mark.futures_user

0 commit comments

Comments
 (0)