From f556715e90db6a94e058ad899b503ae6ba3b2a7b Mon Sep 17 00:00:00 2001 From: antazoey Date: Mon, 11 Dec 2023 22:05:46 -0600 Subject: [PATCH] fix: migrate pydantic config (#38) --- .pre-commit-config.yaml | 6 +++--- setup.py | 8 ++++---- tokenlists/typing.py | 9 +++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2001bc4..7c4296e 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.4.0 + rev: v4.5.0 hooks: - id: check-yaml @@ -10,7 +10,7 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.11.0 hooks: - id: black name: black @@ -21,7 +21,7 @@ repos: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 + rev: v1.7.1 hooks: - id: mypy additional_dependencies: [types-setuptools, types-requests] diff --git a/setup.py b/setup.py index 5faacd6..45cac87 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ "hypothesis-jsonschema==0.19.0", # Fuzzes based on a json schema ], "lint": [ - "black>=23.9.1,<24", # auto-formatter and linter - "mypy>=1.5.1,<2", # Static type analyzer + "black>=23.11.0,<24", # auto-formatter and linter + "mypy>=1.7.1,<2", # Static type analyzer "types-requests", # Needed due to mypy typeshed "types-setuptools", # Needed due to mypy typeshed "flake8>=6.1.0,<7", # Style linter @@ -68,8 +68,8 @@ python_requires=">=3.8,<4", install_requires=[ "importlib-metadata ; python_version<'3.8'", - "click>=8.1.3,<9", - "pydantic>=2.3.0,<3", + "click>=8.1.7,<9", + "pydantic>=2.5.2,<3", "pyyaml>=6.0,<7", "requests>=2.28.1,<3", ], diff --git a/tokenlists/typing.py b/tokenlists/typing.py index bc9afee..57eb828 100644 --- a/tokenlists/typing.py +++ b/tokenlists/typing.py @@ -3,7 +3,7 @@ from pydantic import AnyUrl from pydantic import BaseModel as _BaseModel -from pydantic import PastDatetime, field_validator +from pydantic import ConfigDict, PastDatetime, field_validator ChainId = int TagId = str @@ -20,8 +20,7 @@ def model_dump(self, *args, **kwargs): return super().model_dump(*args, **kwargs) - class Config: - froze = True + model_config = ConfigDict(frozen=True) class BridgeInfo(BaseModel): @@ -177,9 +176,7 @@ def __init__(self, *args, **kwargs): f"Missing reference tags in tokenlist: {token_ref_tags - tokenlist_tags}" ) - class Config: - # NOTE: Not frozen as we may need to dynamically modify this - froze = False + model_config = ConfigDict(frozen=False) @field_validator("logoURI") def validate_uri(cls, v: Optional[str]) -> Optional[str]: