From 867d59b930b27e774fd391d3f372272a5ddcd7d3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 12 Sep 2022 20:00:01 +0200 Subject: [PATCH] Improve type specifitivity --- freqtrade/rpc/external_message_consumer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/freqtrade/rpc/external_message_consumer.py b/freqtrade/rpc/external_message_consumer.py index 122863987..bd921cf8e 100644 --- a/freqtrade/rpc/external_message_consumer.py +++ b/freqtrade/rpc/external_message_consumer.py @@ -8,7 +8,7 @@ import asyncio import logging import socket from threading import Thread -from typing import TYPE_CHECKING, Any, Dict, List +from typing import TYPE_CHECKING, Any, Callable, Dict, List import websockets from pydantic import ValidationError @@ -80,7 +80,7 @@ class ExternalMessageConsumer: ] # Specify which function to use for which RPCMessageType - self._message_handlers = { + self._message_handlers: Dict[str, Callable[[str, WSMessageSchema], None]] = { RPCMessageType.WHITELIST: self._consume_whitelist_message, RPCMessageType.ANALYZED_DF: self._consume_analyzed_df_message, } @@ -279,7 +279,7 @@ class ExternalMessageConsumer: message_handler(producer_name, producer_message) - def _consume_whitelist_message(self, producer_name: str, message: Any): + def _consume_whitelist_message(self, producer_name: str, message: WSMessageSchema): try: # Validate the message message = WSWhitelistMessage.parse_obj(message) @@ -292,7 +292,7 @@ class ExternalMessageConsumer: logger.debug(f"Consumed message from `{producer_name}` of type `RPCMessageType.WHITELIST`") - def _consume_analyzed_df_message(self, producer_name: str, message: Any): + def _consume_analyzed_df_message(self, producer_name: str, message: WSMessageSchema): try: message = WSAnalyzedDFMessage.parse_obj(message) except ValidationError as e: