Skip to content

Commit

Permalink
chore: upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 9, 2024
1 parent 275e727 commit 87d2a0a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -19,15 +19,16 @@ 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-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, mdformat-pyproject]
Expand Down
8 changes: 5 additions & 3 deletions eth_pydantic_types/bip122.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from enum import Enum
from functools import cached_property
from typing import Any, Optional
from typing import TYPE_CHECKING, Any, Optional

from pydantic_core import CoreSchema
from pydantic_core.core_schema import (
ValidationInfo,
str_schema,
Expand All @@ -12,6 +11,9 @@
from eth_pydantic_types._error import Bip122UriFormatError
from eth_pydantic_types.hex import validate_hex_str

if TYPE_CHECKING:
from pydantic_core import CoreSchema


class Bip122UriType(Enum):
TX = "tx"
Expand All @@ -35,7 +37,7 @@ def __get_pydantic_json_schema__(cls, core_schema, handler):
return json_schema

@classmethod
def __get_pydantic_core_schema__(cls, value, handler=None) -> CoreSchema:
def __get_pydantic_core_schema__(cls, value, handler=None) -> "CoreSchema":
return with_info_before_validator_function(
value.__eth_pydantic_validate__,
str_schema(),
Expand Down
8 changes: 5 additions & 3 deletions eth_pydantic_types/hex.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Any, ClassVar, Optional, Union, cast
from typing import TYPE_CHECKING, Any, ClassVar, Optional, Union, cast

from eth_typing import HexStr as EthTypingHexStr
from eth_utils import add_0x_prefix
from hexbytes import HexBytes as BaseHexBytes
from pydantic_core import CoreSchema
from pydantic_core.core_schema import (
ValidationInfo,
bytes_schema,
Expand All @@ -15,6 +14,9 @@
from eth_pydantic_types._error import HexValueError
from eth_pydantic_types.serializers import hex_serializer

if TYPE_CHECKING:
from pydantic_core import CoreSchema

schema_pattern = "^0x([0-9a-f][0-9a-f])*$"
schema_examples = (
"0x", # empty bytes
Expand Down Expand Up @@ -47,7 +49,7 @@ class HexBytes(BaseHexBytes, BaseHex):
"""

@classmethod
def __get_pydantic_core_schema__(cls, value, handle=None) -> CoreSchema:
def __get_pydantic_core_schema__(cls, value, handle=None) -> "CoreSchema":
schema = with_info_before_validator_function(cls.__eth_pydantic_validate__, bytes_schema())
schema["serialization"] = hex_serializer
return schema
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0,<8"]
requires = ["setuptools>=75.6.0", "wheel", "setuptools_scm[toml]>=5.0"]

[tool.mypy]
exclude = ["build/", "dist/", "docs/"]
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[flake8]
max-line-length = 100
ignore = E704,W503,PYD002,TC003,TC006
exclude =
venv*
docs
build
.eggs
type-checking-pydantic-enabled = True
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
"eth-hash[pycryptodome]", # For backends to work
],
"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-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
],
"doc": [
"myst-parser>=1.0.0,<2", # Parse markdown docs
Expand All @@ -35,7 +37,7 @@
"packaging>=23.1,<24", # Used for docs-version directory sorting
],
"release": [ # `release` GitHub Action job uses this
"setuptools", # Installation tool
"setuptools>=75.6.0", # Installation tool
"wheel", # Packaging tool
"twine==3.8.0", # Package upload tool
"packaging>=23.1,<24", # Needed for twine
Expand Down

0 comments on commit 87d2a0a

Please sign in to comment.