Skip to content

Commit

Permalink
feat: support Pydantic 2.10 (#2383)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Nov 21, 2024
1 parent 2073b52 commit 9cc65bb
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"packaging>=23.0,<24",
"pandas>=2.2.2,<3",
"pluggy>=1.3,<2",
"pydantic>=2.6.4,<2.10",
"pydantic>=2.10.0,<3",
"pydantic-settings>=2.5.2,<3",
"pytest>=8.0,<9.0",
"python-dateutil>=2.8.2,<3",
Expand All @@ -128,7 +128,7 @@
"web3[tester]>=6.17.2,<7",
# ** Dependencies maintained by ApeWorX **
"eip712>=0.2.10,<0.3",
"ethpm-types>=0.6.17,<0.7",
"ethpm-types>=0.6.19,<0.7",
"eth_pydantic_types>=0.1.3,<0.2",
"evmchains>=0.1.0,<0.2",
"evm-trace>=0.2.3,<0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/ape/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

@cache
def _basic_columns(Model: type[BaseInterfaceModel]) -> set[str]:
columns = set(Model.model_fields)
columns = set(Model.__pydantic_fields__)

# TODO: Remove once `ReceiptAPI` fields cleaned up for better processing
if Model == ReceiptAPI:
Expand Down
4 changes: 2 additions & 2 deletions src/ape/contracts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def query(
f"the chain length ({self.chain_manager.blocks.height})."
)
query: dict = {
"columns": list(ContractLog.model_fields) if columns[0] == "*" else columns,
"columns": list(ContractLog.__pydantic_fields__) if columns[0] == "*" else columns,
"event": self.abi,
"start_block": start_block,
"stop_block": stop_block,
Expand Down Expand Up @@ -720,7 +720,7 @@ def range(

addresses = list(set([contract_address] + (extra_addresses or [])))
contract_event_query = ContractEventQuery(
columns=list(ContractLog.model_fields.keys()),
columns=list(ContractLog.__pydantic_fields__),
contract=addresses,
event=self.abi,
search_topics=search_topics,
Expand Down
4 changes: 2 additions & 2 deletions src/ape/managers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def __getitem_int(self, index: int) -> ReceiptAPI:
next(
self.query_manager.query(
AccountTransactionQuery(
columns=list(ReceiptAPI.model_fields),
columns=list(ReceiptAPI.__pydantic_fields__),
account=self.address,
start_nonce=index,
stop_nonce=index,
Expand Down Expand Up @@ -471,7 +471,7 @@ def __getitem_slice(self, indices: slice) -> list[ReceiptAPI]:
list(
self.query_manager.query(
AccountTransactionQuery(
columns=list(ReceiptAPI.model_fields),
columns=list(ReceiptAPI.__pydantic_fields__),
account=self.address,
start_nonce=start,
stop_nonce=stop - 1,
Expand Down
2 changes: 1 addition & 1 deletion src/ape/managers/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def convert_method_args(
return converted_arguments

def convert_method_kwargs(self, kwargs) -> dict:
fields = TransactionAPI.model_fields
fields = TransactionAPI.__pydantic_fields__

def get_real_type(type_):
all_types = getattr(type_, "_typevar_types", [])
Expand Down
4 changes: 2 additions & 2 deletions src/ape/utils/basemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import inspect
from abc import ABC
from collections.abc import Callable, Iterator, Sequence
from collections.abc import Callable, Iterator, Mapping, Sequence
from importlib import import_module
from pathlib import Path
from sys import getrecursionlimit
Expand Down Expand Up @@ -413,7 +413,7 @@ class BaseModel(EthpmTypesBaseModel):
def model_copy(
self: "Model",
*,
update: Optional[dict[str, Any]] = None,
update: Optional[Mapping[str, Any]] = None,
deep: bool = False,
cache_clear: Optional[Sequence[str]] = None,
) -> "Model":
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from eth_utils import to_hex
from ethpm_types import Compiler, ContractType, PackageManifest, Source
from ethpm_types.manifest import PackageName
from pydantic_core import Url

import ape
from ape import Project
Expand Down Expand Up @@ -305,7 +304,8 @@ def test_meta(project):
assert project.meta.license == "MIT"
assert project.meta.description == "Zoologist meme protocol"
assert project.meta.keywords == ["Indiana", "Knight's Templar"]
assert project.meta.links == {"apeworx.io": Url("https://apeworx.io")}
assert len(project.meta.links) == 1
assert f"{project.meta.links['apeworx.io']}" == "https://apeworx.io/"


def test_extract_manifest(tmp_project, mock_sepolia, vyper_contract_instance):
Expand Down

0 comments on commit 9cc65bb

Please sign in to comment.