Upgrade to Mypy 1.3.0 (old: 0.991). Fix compatibility problems with Mypy. Add type hints to bfxapi.websocket.handlers.

This commit is contained in:
Davide Casale
2023-05-19 22:13:15 +02:00
parent 57680abd06
commit c8290f144b
7 changed files with 161 additions and 133 deletions

View File

@@ -1,20 +1,5 @@
from typing import TypedDict, Union, Literal, Optional
_Channel = Literal[
"ticker",
"trades",
"book",
"candles",
"status"
]
_Header = TypedDict("_Header", {
"event": Literal["subscribed"],
"channel": _Channel,
"chanId": int
})
Subscription = Union[_Header, "Ticker", "Trades", "Book", "Candles", "Status"]
from typing import TypedDict, \
Union, Literal, Optional
class Ticker(TypedDict):
subId: str
@@ -43,3 +28,33 @@ class Candles(TypedDict):
class Status(TypedDict):
subId: str
key: str
Subscription = Union["_Ticker", "_Trades", "_Book", "_Candles", "_Status"]
_Channel = Literal["ticker", "trades", "book", "candles", "status"]
_Header = TypedDict("_Header", {
"event": Literal["subscribed"],
"channel": _Channel,
"chanId": int
})
#pylint: disable-next=inherit-non-class
class _Ticker(Ticker, _Header):
pass
#pylint: disable-next=inherit-non-class
class _Trades(Trades, _Header):
pass
#pylint: disable-next=inherit-non-class
class _Book(Book, _Header):
pass
#pylint: disable-next=inherit-non-class
class _Candles(Candles, _Header):
pass
#pylint: disable-next=inherit-non-class
class _Status(Status, _Header):
pass