From c1f42257ebae535541f91485fe3fc8fd66fc2573 Mon Sep 17 00:00:00 2001 From: antazoey Date: Tue, 19 Dec 2023 10:28:40 -0600 Subject: [PATCH] feat!: ape 0.7 upgrade (#11) --- .mdformat.toml | 1 - .pre-commit-config.yaml | 10 +++++----- ape_tenderly/client.py | 6 +++--- ape_tenderly/provider.py | 3 ++- pyproject.toml | 3 +++ setup.py | 20 ++++++++++++-------- tests/test_client.py | 1 + 7 files changed, 26 insertions(+), 18 deletions(-) delete mode 100644 .mdformat.toml diff --git a/.mdformat.toml b/.mdformat.toml deleted file mode 100644 index 01b2fb0..0000000 --- a/.mdformat.toml +++ /dev/null @@ -1 +0,0 @@ -number = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 06bd160..3688199 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.5.0 hooks: - id: check-yaml @@ -10,24 +10,24 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.12.0 hooks: - id: black name: black - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.991 + rev: v1.7.1 hooks: - id: mypy additional_dependencies: [types-requests, types-setuptools, pydantic] - repo: https://github.com/executablebooks/mdformat - rev: 0.7.14 + rev: 0.7.17 hooks: - id: mdformat additional_dependencies: [mdformat-gfm, mdformat-frontmatter] diff --git a/ape_tenderly/client.py b/ape_tenderly/client.py index fe76418..82d02d1 100644 --- a/ape_tenderly/client.py +++ b/ape_tenderly/client.py @@ -4,7 +4,7 @@ import requests from ape.exceptions import ConfigError from ape.utils import cached_property -from pydantic import BaseModel, parse_obj_as +from ethpm_types import BaseModel TENDERLY_PROJECT = "TENDERLY_PROJECT" TENDERLY_ACCESS_KEY = "TENDERLY_ACCESS_KEY" @@ -53,7 +53,7 @@ def get_forks(self) -> List[Fork]: raise TenderlyClientError(f"Error processing request: {response.text}") if forks := response.json(): - return parse_obj_as(List[Fork], forks) + return [Fork.model_validate_json(x) for x in forks] else: return [] @@ -71,7 +71,7 @@ def create_fork(self, chain_id: int) -> Fork: if not response.ok: raise TenderlyClientError(f"Error processing request: {response.text}") - return parse_obj_as(Fork, response.json().get("fork")) + return Fork.model_validate_json(response.json().get("fork")) def remove_fork(self, fork_id: str): response = self._authenticated_session.delete(f"{self._api_uri}/forks/{fork_id}") diff --git a/ape_tenderly/provider.py b/ape_tenderly/provider.py index b5310ab..8373921 100644 --- a/ape_tenderly/provider.py +++ b/ape_tenderly/provider.py @@ -1,9 +1,10 @@ import atexit -from ape.api import PluginConfig, UpstreamProvider, Web3Provider +from ape.api import PluginConfig, UpstreamProvider from ape.exceptions import ProviderError from ape.logging import logger from ape.utils import cached_property +from ape_ethereum.provider import Web3Provider from web3 import HTTPProvider, Web3 from web3.gas_strategies.rpc import rpc_gas_price_strategy from web3.middleware import geth_poa_middleware diff --git a/pyproject.toml b/pyproject.toml index da01fa7..1fda1f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,3 +37,6 @@ force_grid_wrap = 0 include_trailing_comma = true multi_line_output = 3 use_parentheses = true + +[tool.mdformat] +number = true diff --git a/setup.py b/setup.py index d1fb59e..1af58cc 100644 --- a/setup.py +++ b/setup.py @@ -5,20 +5,23 @@ extras_require = { "test": [ # `test` GitHub Action jobs uses this "pytest>=6.0", # Core testing package - "pytest-xdist", # multi-process runner + "pytest-xdist", # Multi-process runner "pytest-cov", # Coverage analyzer plugin "hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer ], "lint": [ - "black>=23.3.0,<24", # Auto-formatter and linter - "mypy>=0.991,<1", # Static type analyzer + "black>=23.12.0,<24", # Auto-formatter and linter + "mypy>=1.7.1,<2", # Static type analyzer "types-setuptools", # Needed for mypy type shed - "types-requests", # Needed for mypy typeshed - "flake8>=6.0.0,<7", # Style linter + "types-requests", # Needed for mypy type shed + "flake8>=6.1.0,<7", # Style linter + "flake8-breakpoint>=1.1.0,<2", # Detect breakpoints left in code + "flake8-print>=5.0.0,<6", # Detect print statements left in code "isort>=5.10.1,<6", # Import sorting linter - "mdformat>=0.7.16", # Auto-formatter for markdown + "mdformat>=0.7.17", # Auto-formatter for markdown "mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown "mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates + "mdformat-pyproject>=0.0.1", # Allows configuring in pyproject.toml ], "release": [ # `release` GitHub Action job uses this "setuptools", # Installation tool @@ -58,8 +61,9 @@ url="https://github.com/ApeWorX/ape-tenderly", include_package_data=True, install_requires=[ - "eth-ape>=0.6.0,<0.7", - "requests>=2.28.1,<3", + "eth-ape>=0.7.0,<0.8", + "eth-pydantic-types", # Use same version as eth-ape + "requests", # Use same version as eth-ape ], python_requires=">=3.8,<4", extras_require=extras_require, diff --git a/tests/test_client.py b/tests/test_client.py index 73810bc..e5e0366 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -48,6 +48,7 @@ def test_missing_gateway_secret(client): client.get_gateway_rpc_uri("doesnt", "matter") +@pytest.mark.skip(reason="Requires a subscription to Tenderly's premium service.") def test_create_fork(client): assert len(client.get_forks()) == 0 fork = client.create_fork(1)