From 63717a53191cbde8d67bac45957e6c8b76a74257 Mon Sep 17 00:00:00 2001 From: gabrielfior Date: Fri, 9 Aug 2024 09:16:44 -0300 Subject: [PATCH] Implemented PR comments --- .github/workflows/python_ci.yaml | 8 -------- .../__init__.py | 0 .../cow_client.py | 12 ++++++------ .../encoding.py | 2 +- {cowswap_python_client => cowswap_client}/gtypes.py | 0 {cowswap_python_client => cowswap_client}/models.py | 0 {cowswap_python_client => cowswap_client}/utils.py | 0 mypy.ini | 6 ++---- pyproject.toml | 4 ++-- tests/conftest.py | 4 ++-- tests/test_cow_client.py | 8 ++++---- 11 files changed, 17 insertions(+), 27 deletions(-) rename {cowswap_python_client => cowswap_client}/__init__.py (100%) rename {cowswap_python_client => cowswap_client}/cow_client.py (93%) rename {cowswap_python_client => cowswap_client}/encoding.py (96%) rename {cowswap_python_client => cowswap_client}/gtypes.py (100%) rename {cowswap_python_client => cowswap_client}/models.py (100%) rename {cowswap_python_client => cowswap_client}/utils.py (100%) diff --git a/.github/workflows/python_ci.yaml b/.github/workflows/python_ci.yaml index e5bbc2b..39afedf 100644 --- a/.github/workflows/python_ci.yaml +++ b/.github/workflows/python_ci.yaml @@ -7,14 +7,6 @@ on: workflow_dispatch: env: - MANIFOLD_API_KEY: ${{ secrets.MANIFOLD_API_KEY }} - SERP_API_KEY: ${{ secrets.SERP_API_KEY }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - BET_FROM_ADDRESS: ${{ secrets.BET_FROM_ADDRESS }} - BET_FROM_PRIVATE_KEY: ${{ secrets.BET_FROM_PRIVATE_KEY }} - GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} - GNOSIS_RPC_URL: ${{ secrets.GNOSIS_RPC_URL }} - GRAPH_API_KEY: ${{ secrets.GRAPH_API_KEY }} COWSWAP_TEST_PRIVATE_KEY: ${{ secrets.COWSWAP_TEST_PRIVATE_KEY }} jobs: diff --git a/cowswap_python_client/__init__.py b/cowswap_client/__init__.py similarity index 100% rename from cowswap_python_client/__init__.py rename to cowswap_client/__init__.py diff --git a/cowswap_python_client/cow_client.py b/cowswap_client/cow_client.py similarity index 93% rename from cowswap_python_client/cow_client.py rename to cowswap_client/cow_client.py index 111279f..8410337 100644 --- a/cowswap_python_client/cow_client.py +++ b/cowswap_client/cow_client.py @@ -7,13 +7,13 @@ from loguru import logger from web3 import Web3 -from cowswap_python_client.encoding import ( +from cowswap_client.encoding import ( DOMAIN, MESSAGE_TYPES, MESSAGE_TYPES_CANCELLATION, ) -from cowswap_python_client.gtypes import Wei -from cowswap_python_client.models import ( +from cowswap_client.gtypes import Wei +from cowswap_client.models import ( CowServer, OrderKind, OrderStatus, @@ -52,9 +52,9 @@ def build_swap_params( def _if_error_log_and_raise(r: requests.Response) -> None: try: r.raise_for_status() - except: - logger.error(f"Error occured on response: {r.text}") - r.raise_for_status() + except Exception as e: + logger.error(f"Error occured on response: {r.text}, Exception - {e}") + raise def post_quote(self, quote: QuoteInput) -> QuoteOutput: quote_dict = quote.dict(by_alias=True, exclude_none=True) diff --git a/cowswap_python_client/encoding.py b/cowswap_client/encoding.py similarity index 96% rename from cowswap_python_client/encoding.py rename to cowswap_client/encoding.py index 356a80e..7d602d5 100644 --- a/cowswap_python_client/encoding.py +++ b/cowswap_client/encoding.py @@ -1,6 +1,6 @@ from eth_typing import ChecksumAddress from web3 import Web3 -from cowswap_python_client.gtypes import ChainID +from cowswap_client.gtypes import ChainID MESSAGE_TYPES_CANCELLATION = { "OrderCancellations": [ diff --git a/cowswap_python_client/gtypes.py b/cowswap_client/gtypes.py similarity index 100% rename from cowswap_python_client/gtypes.py rename to cowswap_client/gtypes.py diff --git a/cowswap_python_client/models.py b/cowswap_client/models.py similarity index 100% rename from cowswap_python_client/models.py rename to cowswap_client/models.py diff --git a/cowswap_python_client/utils.py b/cowswap_client/utils.py similarity index 100% rename from cowswap_python_client/utils.py rename to cowswap_client/utils.py diff --git a/mypy.ini b/mypy.ini index 68fa2a3..0b99e0f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,6 +1,6 @@ [mypy] python_version = 3.10 -files = cowswap_python_client/, tests/ +files = cowswap_client/, tests/ plugins = pydantic.mypy warn_redundant_casts = True warn_unused_ignores = True @@ -19,9 +19,7 @@ ignore_missing_imports = True # We don't want to ignore all missing imports as we want to catch those in our own code # But for certain libraries they don't have a stub file, so we only enforce import checking for our own libraries. # Another alternative would be to list out every single dependency that does not have a stub. -[mypy-prediction_market_agent.*] -ignore_missing_imports = False -[mypy-scripts.*] +[mypy-cowswap_client.*] ignore_missing_imports = False [mypy-tests.*] ignore_missing_imports = False diff --git a/pyproject.toml b/pyproject.toml index 2ce6cad..5fef7ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] -name = "cowswap-python-client" -version = "0.1.1" +name = "cowswap-client" +version = "0.1.2" description = "" authors = ["gabrielfior "] readme = "README.md" diff --git a/tests/conftest.py b/tests/conftest.py index 9e5dc49..f8d9ece 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,8 +5,8 @@ from eth_account.signers.local import LocalAccount from pydantic_settings import BaseSettings, SettingsConfigDict -from cowswap_python_client.gtypes import PrivateKey -from cowswap_python_client.utils import check_not_none +from cowswap_client.gtypes import PrivateKey +from cowswap_client.utils import check_not_none class CowswapKey(BaseSettings): diff --git a/tests/test_cow_client.py b/tests/test_cow_client.py index f3a7597..c935e72 100644 --- a/tests/test_cow_client.py +++ b/tests/test_cow_client.py @@ -5,9 +5,9 @@ from eth_account.signers.local import LocalAccount from web3 import Web3 -from cowswap_python_client.cow_client import CowClient, CowServer -from cowswap_python_client.models import OrderKind, OrderStatus, QuoteInput, QuoteOutput -from cowswap_python_client.utils import check_not_none +from cowswap_client.cow_client import CowClient, CowServer +from cowswap_client.models import OrderKind, OrderStatus, QuoteInput, QuoteOutput +from cowswap_client.utils import check_not_none wxDAI = Web3.to_checksum_address("0xe91d153e0b41518a2ce8dd3d7944fa863463a97d") COW = Web3.to_checksum_address("0x177127622c4A00F3d409B75571e12cB3c8973d3c") @@ -62,7 +62,7 @@ def test_post_order( test_mock_client: CowClient, test_quote: QuoteInput, id_holder_fixture: IdHolder ) -> None: with patch( - "cowswap_python_client.cow_client.CowClient.build_order_with_fee_and_sell_amounts", + "cowswap_client.cow_client.CowClient.build_order_with_fee_and_sell_amounts", Mock(side_effect=fake_build_quote), ): quote = test_mock_client.post_quote(test_quote)