From c910cfee3147e4c0bc00bccc4fa47bfdda269d65 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 08:37:11 -0700 Subject: [PATCH 01/10] puts back linting on all files --- .github/workflows/lint.yml | 12 ++++++------ .github/workflows/static.yml | 2 +- .github/workflows/test.yml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a27132ee39..6cb8ed9620 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -36,18 +36,18 @@ jobs: - name: Run black run: python -m black --check --diff . - - name: Get changed Python files - id: changed_files + - name: Get all Python files + id: list_files run: | - echo "files=$(git diff --name-only HEAD^ HEAD | grep '.py$' | xargs)" >> $GITHUB_OUTPUT + echo "files=$(git ls-files '*.py' '*.pyi')" >> $GITHUB_OUTPUT - - name: Run Pylint on changed files + - name: Run Pylint on files run: | - files="${{ steps.changed_files.outputs.files }}" + files="${{ steps.list_files.outputs.files }}" if [ -n "$files" ]; then pylint --rcfile=.pylintrc $files else - echo "No Python files have changed." + echo "No Python files found." fi - name: Check GitHub rate limit at end diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 27ca12ad2e..dd7ef01edc 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -31,7 +31,7 @@ jobs: python -m pip install .[with-dependencies,ape] - name: Analysing code with pyright - run: python -m pyright $(git ls-files '*.py') + run: python -m pyright $(git ls-files '*.py' '*.pyi') - name: Check GitHub rate limit at end uses: wakamex/rate-limit-action@master diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a6e8c404a5..6a86ad36b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,7 +47,7 @@ jobs: token: ${{ secrets.GH_GITHUB_COM_TOKEN || github.token}} - run: | python -m pip install --upgrade pip - python -m pip install .[with-dependencies,postgres,ape] + python -m pip install .[with-dependencies,postgres] python -m pip install coverage - name: Run pytest with coverage From 4071362f1276e2a96f0b63b18752da921bd9f3f5 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 08:47:43 -0700 Subject: [PATCH 02/10] fix? --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6cb8ed9620..5415c604c8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,7 +39,7 @@ jobs: - name: Get all Python files id: list_files run: | - echo "files=$(git ls-files '*.py' '*.pyi')" >> $GITHUB_OUTPUT + echo "::set-output name=files::$(git ls-files '*.py' '*.pyi')" - name: Run Pylint on files run: | From fdf4c26e8b4b907e53c9461e5750e4a2516dfa58 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 08:54:41 -0700 Subject: [PATCH 03/10] store files in github outputs --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5415c604c8..6cb8ed9620 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,7 +39,7 @@ jobs: - name: Get all Python files id: list_files run: | - echo "::set-output name=files::$(git ls-files '*.py' '*.pyi')" + echo "files=$(git ls-files '*.py' '*.pyi')" >> $GITHUB_OUTPUT - name: Run Pylint on files run: | From 7029f50c65a2a6e28f161b7b2e2d492c2780b809 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 09:05:40 -0700 Subject: [PATCH 04/10] adds xargs back --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6cb8ed9620..ff521c56b4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,7 +39,7 @@ jobs: - name: Get all Python files id: list_files run: | - echo "files=$(git ls-files '*.py' '*.pyi')" >> $GITHUB_OUTPUT + echo "files=$(git ls-files '*.py' '*.pyi' | xargs)" >> $GITHUB_OUTPUT - name: Run Pylint on files run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6a86ad36b9..24db49dc01 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,12 +47,12 @@ jobs: token: ${{ secrets.GH_GITHUB_COM_TOKEN || github.token}} - run: | python -m pip install --upgrade pip - python -m pip install .[with-dependencies,postgres] + python -m pip install .[with-dependencies] python -m pip install coverage - name: Run pytest with coverage run: | - coverage run -m pytest --ignore=tests/cross_platform + coverage run -m pytest - name: Generate coverage report run: | From 812c0fc08b8632066e57afa4f9e1d312d40871ca Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 09:25:18 -0700 Subject: [PATCH 05/10] turn off new checks --- .pylintrc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.pylintrc b/.pylintrc index 2b89262e8e..3ea76ac3b5 100644 --- a/.pylintrc +++ b/.pylintrc @@ -617,26 +617,28 @@ variable-naming-style=snake_case # naming-style. If left empty, variable names will be checked with the set # naming style. #variable-rgx= + +# TODO: Turn these back on after trading competition [tool.pylint.parameter_documentation] # Whether to accept totally missing parameter documentation # in the docstring of a function that has parameters. -accept-no-param-doc = false +# accept-no-param-doc = false # Whether to accept totally missing raises documentation # in the docstring of a function that raises an exception. -accept-no-raise-doc = true +# accept-no-raise-doc = true # Whether to accept totally missing return documentation in # the docstring of a function that returns a statement. -accept-no-return-doc = false +# accept-no-return-doc = false # Whether to accept totally missing yields documentation # in the docstring of a generator. -accept-no-yields-doc = false +# accept-no-yields-doc = false # If the docstring type cannot be guessed the # specified docstring type will be used. -default-docstring-type = numpy +# default-docstring-type = numpy [pylint.'test_*.py'] disable = missing-param-doc, missing-return-doc, missing-return-type-doc, too-few-public-methods, missing-type-doc \ No newline at end of file From 4d5d354b4caac11a73dc32f80fa3998900c9ba03 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 09:34:52 -0700 Subject: [PATCH 06/10] another attempt to turn off new checks --- .pylintrc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 3ea76ac3b5..faa3ec7e0b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -77,7 +77,9 @@ limit-inference-results=100 # List of plugins (as comma separated values of python module names) to load, # usually to register additional checkers. -load-plugins=pylint.extensions.docparams, pylint.extensions.docstyle +load-plugins= +# TODO: Turn this back on after trading competition +#load-plugins=pylint.extensions.docparams, pylint.extensions.docstyle # Pickle collected data for later comparisons. persistent=yes @@ -619,7 +621,7 @@ variable-naming-style=snake_case #variable-rgx= # TODO: Turn these back on after trading competition -[tool.pylint.parameter_documentation] +# [tool.pylint.parameter_documentation] # Whether to accept totally missing parameter documentation # in the docstring of a function that has parameters. # accept-no-param-doc = false From b61bc5550939a11104989af5caf327fbc091ceba Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 09:42:04 -0700 Subject: [PATCH 07/10] fix --- .pylintrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index faa3ec7e0b..4da8b78cf2 100644 --- a/.pylintrc +++ b/.pylintrc @@ -642,5 +642,6 @@ variable-naming-style=snake_case # specified docstring type will be used. # default-docstring-type = numpy -[pylint.'test_*.py'] -disable = missing-param-doc, missing-return-doc, missing-return-type-doc, too-few-public-methods, missing-type-doc \ No newline at end of file +# TODO: Turn these back on after trading competition +#[pylint.'test_*.py'] +#disable = missing-param-doc, missing-return-doc, missing-return-type-doc, too-few-public-methods, missing-type-doc \ No newline at end of file From 589c180e98dad37d6f1d4acedf1cee41724438fa Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 09:45:58 -0700 Subject: [PATCH 08/10] turns on less linting for tests --- .pylintrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 4da8b78cf2..21951df5d8 100644 --- a/.pylintrc +++ b/.pylintrc @@ -643,5 +643,6 @@ variable-naming-style=snake_case # default-docstring-type = numpy # TODO: Turn these back on after trading competition -#[pylint.'test_*.py'] -#disable = missing-param-doc, missing-return-doc, missing-return-type-doc, too-few-public-methods, missing-type-doc \ No newline at end of file +[pylint.'test_*.py'] +#disable = missing-param-doc, missing-return-doc, missing-return-type-doc, too-few-public-methods, missing-type-doc +disable = too-few-public-methods \ No newline at end of file From 865d19893c445691fb55467faf4aab274a1d6567 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 09:46:06 -0700 Subject: [PATCH 09/10] lint fixes --- elfpy/eth/errors/types.py | 1 + examples/eth_bots/execute_agent_trades.py | 4 ++-- examples/eth_bots/trade_loop.py | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elfpy/eth/errors/types.py b/elfpy/eth/errors/types.py index ac802f3df9..62f3a9449b 100644 --- a/elfpy/eth/errors/types.py +++ b/elfpy/eth/errors/types.py @@ -1,3 +1,4 @@ +"""Error types from Web3""" from typing import Literal, Sequence, TypedDict from web3.types import ABIFunctionParams diff --git a/examples/eth_bots/execute_agent_trades.py b/examples/eth_bots/execute_agent_trades.py index 5a1784c39a..b0e477d237 100644 --- a/examples/eth_bots/execute_agent_trades.py +++ b/examples/eth_bots/execute_agent_trades.py @@ -139,9 +139,9 @@ def execute_agent_trades( account.agent.wallet.update(wallet_deltas) -def assert_never(x: NoReturn) -> NoReturn: +def assert_never(arg: NoReturn) -> NoReturn: """Helper function for exhaustive matching on ENUMS""" - assert False, "Unhandled type: {}".format(type(x).__name__) + assert False, f"Unhandled type: {type(arg).__name__}" def match_contract_call_to_trade( diff --git a/examples/eth_bots/trade_loop.py b/examples/eth_bots/trade_loop.py index 2698004b10..04c06bea16 100644 --- a/examples/eth_bots/trade_loop.py +++ b/examples/eth_bots/trade_loop.py @@ -8,7 +8,6 @@ from web3.contract.contract import Contract from web3.types import RPCEndpoint -from elfpy import eth from elfpy.eth.accounts import EthAccount from examples.eth_bots.execute_agent_trades import execute_agent_trades From 8067b17489b2ab4f7eaa9bc2bf9dd6d708cdbef4 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 24 Jul 2023 10:22:17 -0700 Subject: [PATCH 10/10] fixes lint bug --- elfpy/hyperdrive_interface/hyperdrive_interface.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/elfpy/hyperdrive_interface/hyperdrive_interface.py b/elfpy/hyperdrive_interface/hyperdrive_interface.py index 56133c5084..7067decf7a 100644 --- a/elfpy/hyperdrive_interface/hyperdrive_interface.py +++ b/elfpy/hyperdrive_interface/hyperdrive_interface.py @@ -15,11 +15,12 @@ from web3.contract.contract import Contract from web3.types import BlockData -from elfpy import eth, hyperdrive_interface +from elfpy import eth from elfpy import time as elftime from elfpy.markets.hyperdrive import HyperdriveMarket, HyperdriveMarketState, HyperdrivePricingModel from .hyperdrive_addresses import HyperdriveAddresses +from .hyperdrive_assets import AssetIdPrefix, encode_asset_id RETRY_COUNT = 10 @@ -108,9 +109,7 @@ def get_hyperdrive_pool_info(web3: Web3, hyperdrive_contract: Contract, block_nu # add position duration to the data dict position_duration = eth.smart_contract_read(hyperdrive_contract, "getPoolConfig").get("positionDuration", None) if position_duration is not None: - asset_id = hyperdrive_interface.encode_asset_id( - hyperdrive_interface.AssetIdPrefix.WITHDRAWAL_SHARE, position_duration - ) + asset_id = encode_asset_id(AssetIdPrefix.WITHDRAWAL_SHARE, position_duration) pool_info["totalSupplyWithdrawalShares"] = eth.smart_contract_read( hyperdrive_contract, "balanceOf", asset_id, hyperdrive_contract.address )["value"]