From 52f9f852b989eb2c636db0b083b4d8fc444fa4b8 Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Wed, 20 Apr 2022 15:57:57 +0200 Subject: [PATCH] remove exceptions from pylintrc --- .pylintrc | 2 +- src/models/order.py | 11 ++++++++--- src/models/solver_args.py | 2 ++ src/models/token.py | 4 ++-- src/models/uniswap.py | 2 ++ src/util/constants.py | 20 ++++++++------------ src/util/exec_plan_coords.py | 4 +++- src/util/schema.py | 2 ++ 8 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.pylintrc b/.pylintrc index 70a75fc..ef7793f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,4 +1,4 @@ [MASTER] -disable=fixme,too-few-public-methods,too-many-instance-attributes,too-many-arguments,logging-fstring-interpolation,too-many-locals,duplicate-code, def buy_amount(self) -> Decimal: +disable=fixme,logging-fstring-interpolation,too-many-arguments extension-pkg-allow-list=pydantic diff --git a/src/models/order.py b/src/models/order.py index 8be9202..bfd9c8b 100644 --- a/src/models/order.py +++ b/src/models/order.py @@ -11,7 +11,10 @@ from src.models.exchange_rate import ExchangeRate as XRate from src.models.token import Token, TokenBalance from src.models.types import NumericType -from src.util.constants import Constants +from src.util.constants import ( + RAISE_ON_MAX_SELL_AMOUNT_VIOLATION, + RAISE_ON_LIMIT_XRATE_VIOLATION, +) from src.util.numbers import decimal_to_str OrderSerializedType = dict[str, Any] @@ -39,6 +42,8 @@ class Order: a cost-bounded {buy|sell} order or a {buy|sell} market order. """ + # pylint: disable=too-many-instance-attributes + def __init__( self, order_id: str, @@ -303,7 +308,7 @@ def execute( f"sell (max) : {ymax.balance}" ) logging.error(message) - if Constants.RAISE_ON_MAX_SELL_AMOUNT_VIOLATION: + if RAISE_ON_MAX_SELL_AMOUNT_VIOLATION: raise ValueError(message) sell_amount = min(sell_amount, ymax) @@ -330,7 +335,7 @@ def execute( f"limit (max): {self.max_limit}" ) logging.error(message) - if Constants.RAISE_ON_LIMIT_XRATE_VIOLATION: + if RAISE_ON_LIMIT_XRATE_VIOLATION: raise ValueError(message) # Store execution information. diff --git a/src/models/solver_args.py b/src/models/solver_args.py index f33ea9c..2d61f9c 100644 --- a/src/models/solver_args.py +++ b/src/models/solver_args.py @@ -13,6 +13,8 @@ class SolverArgs: """Parameters passed in POST URL""" + # pylint: disable=too-many-instance-attributes + auction_id: Optional[str] instance_name: str time_limit: int diff --git a/src/models/token.py b/src/models/token.py index 1922c71..58dc62a 100644 --- a/src/models/token.py +++ b/src/models/token.py @@ -6,7 +6,7 @@ from typing import Optional, Union from src.models.types import NumericType -from src.util.constants import Constants +from src.util.constants import DECIMAL_STR_PREC class Token: @@ -101,7 +101,7 @@ def __str__(self) -> str: "external_price", "internal_buffer", ]: - value = value.quantize(Constants.DECIMAL_STR_PREC) + value = value.quantize(DECIMAL_STR_PREC) _str += f"\n-- {attr} : {value}" return _str diff --git a/src/models/uniswap.py b/src/models/uniswap.py index 3bbdb70..112e902 100644 --- a/src/models/uniswap.py +++ b/src/models/uniswap.py @@ -24,6 +24,8 @@ class Uniswap: An Uniswap pool is represented by two token balances. """ + # pylint: disable=too-many-instance-attributes + def __init__( self, pool_id: str, diff --git a/src/util/constants.py b/src/util/constants.py index a2c27d7..e4476e9 100644 --- a/src/util/constants.py +++ b/src/util/constants.py @@ -2,17 +2,13 @@ from decimal import Decimal +# Precision of Decimal in strings (to be used as x.quantize(DECIMAL_STR_PREC)). +DECIMAL_STR_PREC = Decimal("1e-10") -class Constants: - """Configuration parameters for the solver.""" +# Should an exception be raised when the solution violates the +# max sell amount constraint. +RAISE_ON_MAX_SELL_AMOUNT_VIOLATION = False - # Precision of Decimal in strings (to be used as x.quantize(DECIMAL_STR_PREC)). - DECIMAL_STR_PREC = Decimal("1e-10") - - # Should an exception be raised when the solution violates the - # max sell amount constraint. - RAISE_ON_MAX_SELL_AMOUNT_VIOLATION = False - - # Should an exception be raised when the solution violates the - # limit exchange rate constraint. - RAISE_ON_LIMIT_XRATE_VIOLATION = False +# Should an exception be raised when the solution violates the +# limit exchange rate constraint. +RAISE_ON_LIMIT_XRATE_VIOLATION = False diff --git a/src/util/exec_plan_coords.py b/src/util/exec_plan_coords.py index befc26b..1bb053e 100644 --- a/src/util/exec_plan_coords.py +++ b/src/util/exec_plan_coords.py @@ -2,13 +2,15 @@ class ExecPlanCoords: - """The position coordinates of the uniswap in the execution plan. + """The position coordinates of the AMM in the execution plan. The position is defined by a pair of integers: * Id of the sequence. * Position within that sequence. """ + # pylint: disable=too-few-public-methods + def __init__(self, sequence: int, position: int): self.sequence = sequence self.position = position diff --git a/src/util/schema.py b/src/util/schema.py index 47de6bd..85263c9 100644 --- a/src/util/schema.py +++ b/src/util/schema.py @@ -251,6 +251,7 @@ class OrderModel(BaseModel): class Config: """Includes example in generated openapi file""" + # pylint: disable=too-few-public-methods schema_extra = { "example": { "sell_token": "0x6b175474e89094c44da98b954eedeac495271d0f", @@ -326,6 +327,7 @@ class BatchAuctionModel(BaseModel): class Config: """Includes example in generated openapi file""" + # pylint: disable=too-few-public-methods schema_extra = {"example": example_instance}