From ae637826d74e1b02b9f6d6b7e916a177ed4993d2 Mon Sep 17 00:00:00 2001 From: 0xevolve Date: Wed, 8 Jan 2025 14:04:54 +0100 Subject: [PATCH] fix: price-pusher circular deps (#240) --- price-pusher/price_pusher/core/listener.py | 2 +- .../price_pusher/core/request_handlers/__init__.py | 2 +- price-pusher/price_pusher/main.py | 2 +- price-pusher/price_pusher/orchestrator.py | 2 +- price-pusher/price_pusher/{types.py => price_types.py} | 2 +- price-pusher/price_pusher/utils.py | 7 ++++--- 6 files changed, 9 insertions(+), 8 deletions(-) rename price-pusher/price_pusher/{types.py => price_types.py} (89%) diff --git a/price-pusher/price_pusher/core/listener.py b/price-pusher/price_pusher/core/listener.py index c2a24259..d53246e1 100644 --- a/price-pusher/price_pusher/core/listener.py +++ b/price-pusher/price_pusher/core/listener.py @@ -14,7 +14,7 @@ from price_pusher.utils import exclude_none_and_exceptions, flatten_list from price_pusher.configs import PriceConfig from price_pusher.core.request_handlers.interface import IRequestHandler -from price_pusher.types import ( +from price_pusher.price_types import ( DurationInSeconds, LatestOraclePairPrices, LatestOrchestratorPairPrices, diff --git a/price-pusher/price_pusher/core/request_handlers/__init__.py b/price-pusher/price_pusher/core/request_handlers/__init__.py index 5e009e5f..2c3c292e 100644 --- a/price-pusher/price_pusher/core/request_handlers/__init__.py +++ b/price-pusher/price_pusher/core/request_handlers/__init__.py @@ -1,6 +1,6 @@ from typing import Dict -from price_pusher.types import Target +from price_pusher.price_types import Target from .api import APIRequestHandler from .chain import ChainRequestHandler diff --git a/price-pusher/price_pusher/main.py b/price-pusher/price_pusher/main.py index 5dbd19c5..4036bbde 100644 --- a/price-pusher/price_pusher/main.py +++ b/price-pusher/price_pusher/main.py @@ -26,7 +26,7 @@ PriceConfig, ) from price_pusher.orchestrator import Orchestrator -from price_pusher.types import Target, Network +from price_pusher.price_types import Target, Network logger = logging.getLogger(__name__) diff --git a/price-pusher/price_pusher/orchestrator.py b/price-pusher/price_pusher/orchestrator.py index b77f61da..781e6ff6 100644 --- a/price-pusher/price_pusher/orchestrator.py +++ b/price-pusher/price_pusher/orchestrator.py @@ -10,7 +10,7 @@ from price_pusher.core.poller import PricePoller from price_pusher.core.listener import PriceListener from price_pusher.core.pusher import PricePusher -from price_pusher.types import LatestOrchestratorPairPrices +from price_pusher.price_types import LatestOrchestratorPairPrices logger = logging.getLogger(__name__) diff --git a/price-pusher/price_pusher/types.py b/price-pusher/price_pusher/price_types.py similarity index 89% rename from price-pusher/price_pusher/types.py rename to price-pusher/price_pusher/price_types.py index e6c601a8..2f048a9e 100644 --- a/price-pusher/price_pusher/types.py +++ b/price-pusher/price_pusher/price_types.py @@ -15,4 +15,4 @@ ] LatestOraclePairPrices = Dict[PairId, Dict[DataTypes, Entry]] Target = Literal["onchain", "offchain"] -Network = Literal["mainnet", "sepolia", "pragma_devnet"] +Network = Literal["mainnet", "sepolia", "pragma_devnet"] \ No newline at end of file diff --git a/price-pusher/price_pusher/utils.py b/price-pusher/price_pusher/utils.py index 1ad022cc..8b743295 100644 --- a/price-pusher/price_pusher/utils.py +++ b/price-pusher/price_pusher/utils.py @@ -1,9 +1,10 @@ -from typing import List, Union, Optional +from typing import List, Union, Optional, TypeVar from pragma_sdk.offchain.client import PragmaAPIError +T = TypeVar('T') -def exclude_none_and_exceptions[T]( +def exclude_none_and_exceptions( to_filter: List[Optional[Union[T, BaseException, Exception, PragmaAPIError]]], ) -> List[T]: """ @@ -13,7 +14,7 @@ def exclude_none_and_exceptions[T]( return [item for item in to_filter if not isinstance(item, exception_types)] -def flatten_list[T](to_flatten: List[Union[T, List[T]]]) -> List[T]: +def flatten_list(to_flatten: List[Union[T, List[T]]]) -> List[T]: """ Flatten a list that contains items and list of items into a list of items. """