mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-20 07:14:20 +01:00
Remove type hinting for decorators _require_websocket_connection and _require_websocket_authentication.
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
from typing import Literal, TypeVar, Callable, cast
|
|
||||||
|
|
||||||
import asyncio, json, uuid, websockets
|
import asyncio, json, uuid, websockets
|
||||||
|
|
||||||
from ..handlers import PublicChannelsHandler
|
from ..handlers import PublicChannelsHandler
|
||||||
@@ -8,16 +6,14 @@ from ..exceptions import ConnectionNotOpen, TooManySubscriptions
|
|||||||
|
|
||||||
_HEARTBEAT = "hb"
|
_HEARTBEAT = "hb"
|
||||||
|
|
||||||
F = TypeVar("F", bound=Callable[..., Literal[None]])
|
def _require_websocket_connection(function):
|
||||||
|
|
||||||
def _require_websocket_connection(function: F) -> F:
|
|
||||||
async def wrapper(self, *args, **kwargs):
|
async def wrapper(self, *args, **kwargs):
|
||||||
if self.websocket is None or not self.websocket.open:
|
if self.websocket is None or not self.websocket.open:
|
||||||
raise ConnectionNotOpen("No open connection with the server.")
|
raise ConnectionNotOpen("No open connection with the server.")
|
||||||
|
|
||||||
await function(self, *args, **kwargs)
|
await function(self, *args, **kwargs)
|
||||||
|
|
||||||
return cast(F, wrapper)
|
return wrapper
|
||||||
|
|
||||||
class BfxWebSocketBucket:
|
class BfxWebSocketBucket:
|
||||||
VERSION = 2
|
VERSION = 2
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
from typing import cast
|
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -8,7 +6,7 @@ import traceback, json, asyncio, hmac, hashlib, time, socket, random, websockets
|
|||||||
|
|
||||||
from pyee.asyncio import AsyncIOEventEmitter
|
from pyee.asyncio import AsyncIOEventEmitter
|
||||||
|
|
||||||
from .bfx_websocket_bucket import _HEARTBEAT, F, _require_websocket_connection, BfxWebSocketBucket
|
from .bfx_websocket_bucket import _HEARTBEAT, _require_websocket_connection, BfxWebSocketBucket
|
||||||
|
|
||||||
from .bfx_websocket_inputs import BfxWebSocketInputs
|
from .bfx_websocket_inputs import BfxWebSocketInputs
|
||||||
from ..handlers import PublicChannelsHandler, AuthEventsHandler
|
from ..handlers import PublicChannelsHandler, AuthEventsHandler
|
||||||
@@ -19,7 +17,7 @@ from ...utils.json_encoder import JSONEncoder
|
|||||||
|
|
||||||
from ...utils.logger import ColorLogger, FileLogger
|
from ...utils.logger import ColorLogger, FileLogger
|
||||||
|
|
||||||
def _require_websocket_authentication(function: F) -> F:
|
def _require_websocket_authentication(function):
|
||||||
async def wrapper(self, *args, **kwargs):
|
async def wrapper(self, *args, **kwargs):
|
||||||
if hasattr(self, "authentication") and not self.authentication:
|
if hasattr(self, "authentication") and not self.authentication:
|
||||||
raise WebSocketAuthenticationRequired("To perform this action you need to " \
|
raise WebSocketAuthenticationRequired("To perform this action you need to " \
|
||||||
@@ -27,7 +25,7 @@ def _require_websocket_authentication(function: F) -> F:
|
|||||||
|
|
||||||
await _require_websocket_connection(function)(self, *args, **kwargs)
|
await _require_websocket_connection(function)(self, *args, **kwargs)
|
||||||
|
|
||||||
return cast(F, wrapper)
|
return wrapper
|
||||||
|
|
||||||
class _Delay:
|
class _Delay:
|
||||||
BACKOFF_MIN, BACKOFF_MAX = 1.92, 60.0
|
BACKOFF_MIN, BACKOFF_MAX = 1.92, 60.0
|
||||||
|
|||||||
Reference in New Issue
Block a user