diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a89bd1..8351d04 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.6.0 + rev: v5.0.0 hooks: - id: check-yaml @@ -10,7 +10,7 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black name: black @@ -19,18 +19,19 @@ repos: rev: 7.1.1 hooks: - id: flake8 + additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.13.0 hooks: - id: mypy additional_dependencies: [types-PyYAML, types-requests, types-setuptools, pydantic] - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.19 hooks: - id: mdformat - additional_dependencies: [mdformat-gfm, mdformat-frontmatter] + additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject] default_language_version: python: python3 diff --git a/evm_trace/gas.py b/evm_trace/gas.py index 452a4a3..fae5b1a 100644 --- a/evm_trace/gas.py +++ b/evm_trace/gas.py @@ -1,14 +1,15 @@ import copy -from typing import TypeVar +from typing import TYPE_CHECKING, TypeVar -from evm_trace.base import CallTreeNode +if TYPE_CHECKING: + from evm_trace.base import CallTreeNode ContractID = TypeVar("ContractID") MethodID = TypeVar("MethodID") GasReport = dict[ContractID, dict[MethodID, list[int]]] -def get_gas_report(calltree: CallTreeNode) -> GasReport: +def get_gas_report(calltree: "CallTreeNode") -> GasReport: """ Extracts a gas report object from a :class:`~evm_trace.base.CallTreeNode`. diff --git a/pyproject.toml b/pyproject.toml index 968a088..0586125 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ write_to = "evm_trace/version.py" [tool.black] line-length = 100 -target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] +target-version = ['py39', 'py310', 'py311', 'py312', 'py313'] include = '\.pyi?$' [tool.pytest.ini_options] diff --git a/setup.cfg b/setup.cfg index aebe88d..71847f7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,8 @@ exclude = docs build evm_trace/version.py -ignore = E704,W503,PYD002 +ignore = E704,W503,PYD002,TC003,TC006 per-file-ignores = # The traces have to be formatted this way for the tests. tests/expected_traces.py: E501 +type-checking-pydantic-enabled = True diff --git a/setup.py b/setup.py index 93346ad..992b1b0 100644 --- a/setup.py +++ b/setup.py @@ -10,17 +10,19 @@ "eth-hash[pysha3]", # For eth-utils address checksumming ], "lint": [ - "black>=24.8.0,<25", # Auto-formatter and linter - "mypy>=1.11.1,<2", # Static type analyzer + "black>=24.10.0,<25", # Auto-formatter and linter + "mypy>=1.13.0,<2", # Static type analyzer "types-setuptools", # Needed for mypy type shed "flake8>=7.1.1,<8", # 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 + "flake8-print>=4.0.1,<5", # Detect print statements left in code + "flake8-pydantic", # For detecting issues with Pydantic models + "flake8-type-checking", # Detect imports to move in/out of type-checking blocks "isort>=5.10.1,<6", # Import sorting linter - "mdformat>=0.7.17", # Auto-formatter for markdown + "mdformat>=0.7.19", # 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 + "mdformat-pyproject>=0.0.2", # Allows configuring in pyproject.toml ], "release": [ # `release` GitHub Action job uses this "setuptools>=75.6.0", # Installation tool @@ -60,12 +62,12 @@ url="https://github.com/ApeWorX/evm-trace", include_package_data=True, install_requires=[ - "pydantic>=2.5.2,<3", - "py-evm>=0.10.1b1,<0.11", + "cchecksum>=0.0.3,<1", + "eth-pydantic-types>=0.1.3,<0.2", "eth-utils>=2.3.1,<6", "msgspec>=0.8; python_version < '3.13'", - "eth-pydantic-types>=0.1.3,<0.2", - "cchecksum>=0.0.3,<1", + "pydantic>=2.5.2,<3", + "py-evm>=0.10.1b1,<0.11", ], python_requires=">=3.9,<4", extras_require=extras_require, diff --git a/tests/test_geth.py b/tests/test_geth.py index 24d1263..80f6071 100644 --- a/tests/test_geth.py +++ b/tests/test_geth.py @@ -1,8 +1,9 @@ import re import pytest +from cchecksum import to_checksum_address from eth_pydantic_types import HexBytes -from eth_utils import to_checksum_address, to_hex +from eth_utils import to_hex from pydantic import ValidationError from evm_trace.enums import CallType