From 3ef96deb7a6ea0a032f87b5c6a5ecdad23821013 Mon Sep 17 00:00:00 2001 From: NotPeopling2day <32708219+NotPeopling2day@users.noreply.github.com> Date: Tue, 19 Dec 2023 00:03:32 -0500 Subject: [PATCH] feat!: Handle 0.7 breaking changes and updates [APE-1544] (#15) Co-authored-by: Juliya Smith --- .mdformat.toml | 1 - ape_addressbook/addressbook.py | 13 +++++++------ pyproject.toml | 3 +++ setup.py | 12 ++++++++---- 4 files changed, 18 insertions(+), 11 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/ape_addressbook/addressbook.py b/ape_addressbook/addressbook.py index c30adbe..461d653 100644 --- a/ape_addressbook/addressbook.py +++ b/ape_addressbook/addressbook.py @@ -1,11 +1,12 @@ from typing import Dict, Iterator, cast -from ape._pydantic_compat import root_validator from ape.api import PluginConfig from ape.logging import logger from ape.types import AddressType from ape.utils import ManagerAccessMixin from eth_utils import is_checksum_address, to_checksum_address +from pydantic import model_validator +from pydantic_settings import SettingsConfigDict def _validate_entries(entries: Dict) -> Dict: @@ -26,15 +27,15 @@ def _validate_entries(entries: Dict) -> Dict: class AddressBookConfig(PluginConfig): - @root_validator(pre=True) + @model_validator(mode="before") + @classmethod def validate_entries(cls, entries): return _validate_entries(entries) def __len__(self) -> int: - return len(self.dict()) + return len(self.model_dump()) - class Config: - extra = "allow" + model_config = SettingsConfigDict(extra="allow") class AddressBook(ManagerAccessMixin): @@ -71,7 +72,7 @@ def registry(self) -> Dict[str, AddressType]: and project addresses. """ - data = self.config.dict() + data = self.config.model_dump() # Sorted for consistency's sake. return {k: data[k] for k in sorted(data)} diff --git a/pyproject.toml b/pyproject.toml index 8b8524a..ea5abe8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,3 +38,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 0839db1..8392d54 100644 --- a/setup.py +++ b/setup.py @@ -5,19 +5,22 @@ 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.12.0,<24", # auto-formatter and linter + "black>=23.12.0,<24", # Auto-formatter and linter "mypy>=1.7.1,<2", # Static type analyzer - "types-setuptools", # Needed due to mypy typeshed + "types-setuptools", # 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.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 @@ -57,8 +60,9 @@ url="https://github.com/ApeWorX/ape-addressbook", include_package_data=True, install_requires=[ - "eth-ape>=0.6.0,<0.7", + "eth-ape>=0.7.0,<0.8", "pydantic", # Use same version as eth-ape. + "pydantic-settings", # Use same version as eth-ape. ], python_requires=">=3.8,<4", extras_require=extras_require,