From b7e74aea02f104122e03bd1b723ade735e5bacb1 Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Wed, 21 Aug 2024 10:20:34 +0200 Subject: [PATCH] Update python to 3.12 (#389) There seem to be issues with old versions of dependencies due to using python 3.11. This PR updates to python 3.12. --- .github/workflows/postgres.yaml | 4 ++-- .github/workflows/pull-request.yaml | 4 ++-- Dockerfile | 4 ++-- mypy.ini | 2 +- requirements.txt | 8 ++++---- src/abis/load.py | 1 + src/constants.py | 1 + src/fetch/dune.py | 1 + src/fetch/payouts.py | 16 ++++++++++------ src/fetch/prices.py | 1 + src/fetch/token_list.py | 1 + src/fetch/transfer_file.py | 1 + src/logger.py | 1 + src/models/accounting_period.py | 1 + src/models/overdraft.py | 1 + src/models/token.py | 1 + src/models/transfer.py | 1 + src/multisend.py | 1 + src/pg_client.py | 1 + src/queries.py | 1 + src/scripts/gap_detector.py | 1 + src/slack_utils.py | 1 + src/utils/dataset.py | 1 + src/utils/print_store.py | 1 + src/utils/query_file.py | 1 + src/utils/script_args.py | 1 + src/utils/token_details.py | 1 + 27 files changed, 42 insertions(+), 17 deletions(-) diff --git a/.github/workflows/postgres.yaml b/.github/workflows/postgres.yaml index bae86055..3640094f 100644 --- a/.github/workflows/postgres.yaml +++ b/.github/workflows/postgres.yaml @@ -22,10 +22,10 @@ jobs: - ${{ github.workspace }}:/repo steps: - uses: actions/checkout@v3 - - name: Setup Python 3.11 + - name: Setup Python 3.12 uses: actions/setup-python@v3 with: - python-version: '3.11' + python-version: '3.12' - name: Install Requirements run: pip install -r requirements.txt - name: Tests diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 69a90d20..4244b3a0 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -8,10 +8,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Setup Python 3.11 + - name: Setup Python 3.12 uses: actions/setup-python@v3 with: - python-version: '3.11' + python-version: '3.12' - name: Install Requirements run: pip install -r requirements.txt diff --git a/Dockerfile b/Dockerfile index 5505266e..21481f93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11 +FROM python:3.12 COPY . . RUN pip install -r requirements.txt -ENTRYPOINT [ "python3", "-m"] +ENTRYPOINT [ "python", "-m"] diff --git a/mypy.ini b/mypy.ini index 0c697237..e9d467ac 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,5 @@ [mypy] -python_version = 3.11 +python_version = 3.12 ignore_missing_imports = True [mypy-src.*] diff --git a/requirements.txt b/requirements.txt index 8580fa40..031bcb7a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,7 @@ -black==23.3.0 certifi==2022.6.15 duneapi==8.0.0 dune-client==1.1.1 -mypy<1.0.0 psycopg2-binary>=2.9.6 -pylint==2.17.4 -pytest==7.4.0 python-dotenv>=0.20.0 coinpaprika>=0.1.0 requests>=2.28.1 @@ -18,3 +14,7 @@ sqlalchemy-stubs==0.4 pandas==2.0.3 pandas-stubs==2.0.2.230605 numpy==1.26.4 +black +mypy +pylint +pytest diff --git a/src/abis/load.py b/src/abis/load.py index 742b1371..a9ec698a 100644 --- a/src/abis/load.py +++ b/src/abis/load.py @@ -1,4 +1,5 @@ """Basic Contract ABI loader (from json files)""" + import json import os from enum import Enum diff --git a/src/constants.py b/src/constants.py index c7afafec..4ff3884d 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1,4 +1,5 @@ """Project Global Constants. """ + import os from pathlib import Path diff --git a/src/fetch/dune.py b/src/fetch/dune.py index 3b0aad44..3ffbff80 100644 --- a/src/fetch/dune.py +++ b/src/fetch/dune.py @@ -1,4 +1,5 @@ """All Dune related query fetching is defined here in the DuneFetcherClass""" + from typing import Optional from dune_client.client import DuneClient diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index 79f0c953..5c70a74c 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -189,9 +189,11 @@ def as_payouts(self) -> list[Transfer]: result.append( Transfer( token=None, - recipient=self.reward_target - if self.bonding_pool == COW_BONDING_POOL - else self.solver, + recipient=( + self.reward_target + if self.bonding_pool == COW_BONDING_POOL + else self.solver + ), amount_wei=reimbursement_eth + total_eth_reward, ) ) @@ -227,9 +229,11 @@ def as_payouts(self) -> list[Transfer]: result.append( Transfer( token=None, - recipient=self.reward_target - if self.bonding_pool == COW_BONDING_POOL - else self.solver, + recipient=( + self.reward_target + if self.bonding_pool == COW_BONDING_POOL + else self.solver + ), amount_wei=reimbursement_eth, ) ) diff --git a/src/fetch/prices.py b/src/fetch/prices.py index ddd03c6d..97442d87 100644 --- a/src/fetch/prices.py +++ b/src/fetch/prices.py @@ -2,6 +2,7 @@ An interface for fetching prices. Currently, only price feed is CoinPaprika's Free tier API. """ + import functools import logging.config from datetime import datetime diff --git a/src/fetch/token_list.py b/src/fetch/token_list.py index 6e2de0f8..101c3cde 100644 --- a/src/fetch/token_list.py +++ b/src/fetch/token_list.py @@ -2,6 +2,7 @@ Standalone script for fetching the trusted token list and pushing the data to a dune user generated view. """ + from __future__ import annotations import json diff --git a/src/fetch/transfer_file.py b/src/fetch/transfer_file.py index a7355e26..ac37fe0f 100644 --- a/src/fetch/transfer_file.py +++ b/src/fetch/transfer_file.py @@ -1,6 +1,7 @@ """ Script to generate the CSV Airdrop file for Solver Rewards over an Accounting Period """ + from __future__ import annotations import os diff --git a/src/logger.py b/src/logger.py index d49bb9cf..89bee054 100644 --- a/src/logger.py +++ b/src/logger.py @@ -1,4 +1,5 @@ """Easy universal log configuration """ + import logging.config from logging import Logger diff --git a/src/models/accounting_period.py b/src/models/accounting_period.py index 7727be10..8c7f7247 100644 --- a/src/models/accounting_period.py +++ b/src/models/accounting_period.py @@ -1,6 +1,7 @@ """ Common location for shared resources throughout the project. """ + from __future__ import annotations import urllib.parse diff --git a/src/models/overdraft.py b/src/models/overdraft.py index 9495cabe..f672d950 100644 --- a/src/models/overdraft.py +++ b/src/models/overdraft.py @@ -1,4 +1,5 @@ """Overdraft Class""" + from __future__ import annotations from dataclasses import dataclass diff --git a/src/models/token.py b/src/models/token.py index ded6faed..6afc2b96 100644 --- a/src/models/token.py +++ b/src/models/token.py @@ -1,6 +1,7 @@ """ Common location for shared resources throughout the project. """ + from __future__ import annotations from enum import Enum diff --git a/src/models/transfer.py b/src/models/transfer.py index cb172837..48d84803 100644 --- a/src/models/transfer.py +++ b/src/models/transfer.py @@ -1,6 +1,7 @@ """ Script to generate the CSV Airdrop file for Solver Rewards over an Accounting Period """ + from __future__ import annotations from dataclasses import dataclass diff --git a/src/multisend.py b/src/multisend.py index b50c221c..5e1e7e26 100644 --- a/src/multisend.py +++ b/src/multisend.py @@ -2,6 +2,7 @@ All the tools necessary to compose and encode a Safe Multisend transaction consisting of Transfers """ + import logging.config from eth_typing.evm import ChecksumAddress diff --git a/src/pg_client.py b/src/pg_client.py index a6ac5df5..caaa4166 100644 --- a/src/pg_client.py +++ b/src/pg_client.py @@ -1,4 +1,5 @@ """Basic client for connecting to postgres database with login credentials""" + from __future__ import annotations diff --git a/src/queries.py b/src/queries.py index 0851eaf3..50697777 100644 --- a/src/queries.py +++ b/src/queries.py @@ -1,6 +1,7 @@ """ Localized account of all Queries related to this project's main functionality """ + from __future__ import annotations from copy import copy diff --git a/src/scripts/gap_detector.py b/src/scripts/gap_detector.py index 6f572483..c143e3bd 100644 --- a/src/scripts/gap_detector.py +++ b/src/scripts/gap_detector.py @@ -2,6 +2,7 @@ Gap detection script for finding missing transaction hashes of settlements. Uses a form of binary search to minimize/reduce API requests. """ + from __future__ import annotations import argparse import os diff --git a/src/slack_utils.py b/src/slack_utils.py index 52c95da1..c780fc5d 100644 --- a/src/slack_utils.py +++ b/src/slack_utils.py @@ -1,6 +1,7 @@ """ Basic Slack Post functionality. Sends a message thread to a specified channel. """ + from slack.web.client import WebClient from slack.web.slack_response import SlackResponse diff --git a/src/utils/dataset.py b/src/utils/dataset.py index d47b0bb0..12b35570 100644 --- a/src/utils/dataset.py +++ b/src/utils/dataset.py @@ -1,4 +1,5 @@ """Generic tools for manipulating datasets""" + from dataclasses import fields, is_dataclass from typing import Any diff --git a/src/utils/print_store.py b/src/utils/print_store.py index 115f19ee..6e81dfe0 100644 --- a/src/utils/print_store.py +++ b/src/utils/print_store.py @@ -1,6 +1,7 @@ """ Simple wrapper for print statements that saves all the messages chronologically in a list """ + from collections import defaultdict from enum import Enum diff --git a/src/utils/query_file.py b/src/utils/query_file.py index 821871c5..ec170de1 100644 --- a/src/utils/query_file.py +++ b/src/utils/query_file.py @@ -3,6 +3,7 @@ It causes problems when people are not necessarily running the scripts from the project root These utilities eliminate the need to use relative paths. """ + import os from src.constants import QUERY_PATH, DASHBOARD_PATH diff --git a/src/utils/script_args.py b/src/utils/script_args.py index 01f4ee90..c6ab4d7b 100644 --- a/src/utils/script_args.py +++ b/src/utils/script_args.py @@ -1,4 +1,5 @@ """Common method for initializing setup for scripts""" + import argparse import os from datetime import date, timedelta diff --git a/src/utils/token_details.py b/src/utils/token_details.py index 8f6c2935..13893685 100644 --- a/src/utils/token_details.py +++ b/src/utils/token_details.py @@ -1,6 +1,7 @@ """ Very basic Token Info Fetcher that gets token decimals """ + import functools import logging.config