diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e309acb..0ab2d91 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.2.0 + rev: v4.5.0 hooks: - id: check-yaml @@ -10,24 +10,24 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.9.1 hooks: - id: black name: black - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.991 + rev: v1.6.0 hooks: - id: mypy additional_dependencies: [types-requests, types-setuptools, pydantic, types-pkg-resources] - repo: https://github.com/executablebooks/mdformat - rev: 0.7.14 + rev: 0.7.17 hooks: - id: mdformat additional_dependencies: [mdformat-gfm, mdformat-frontmatter] diff --git a/ape_solidity/_utils.py b/ape_solidity/_utils.py index 9c03891..f197554 100644 --- a/ape_solidity/_utils.py +++ b/ape_solidity/_utils.py @@ -10,7 +10,7 @@ from ape.logging import logger from packaging.version import InvalidVersion from packaging.version import Version as _Version -from pydantic import BaseModel, validator +from pydantic import BaseModel, field_validator from semantic_version import NpmSpec, Version # type: ignore from solcx.exceptions import SolcError # type: ignore from solcx.install import get_executable # type: ignore @@ -37,7 +37,7 @@ class ImportRemapping(BaseModel): entry: str packages_cache: Path - @validator("entry") + @field_validator("entry", mode="before") def validate_entry(cls, value): if len((value or "").split("=")) != 2: raise IncorrectMappingFormatError() diff --git a/ape_solidity/compiler.py b/ape_solidity/compiler.py index b92fa38..194bf8f 100644 --- a/ape_solidity/compiler.py +++ b/ape_solidity/compiler.py @@ -196,7 +196,7 @@ def get_import_remapping(self, base_path: Optional[Path] = None) -> Dict[str, st logger.debug(f"Unable to find dependency '{package_id}'.") else: - manifest = PackageManifest.parse_file(cached_manifest_file) + manifest = PackageManifest.model_validate_json(cached_manifest_file.read_text()) self._add_dependencies(manifest, sub_contracts_cache, builder) # Update cache and hash @@ -280,7 +280,7 @@ def _add_dependencies( / f"{dependency_name}.json" ) if dependency_path.is_file(): - sub_manifest = PackageManifest.parse_file(dependency_path) + sub_manifest = PackageManifest.model_validate_json(dependency_path.read_text()) dep_id = Path(dependency_name) / version if dep_id not in builder.dependencies_added: builder.dependencies_added.add(dep_id) @@ -422,7 +422,7 @@ def classify_ast(_node: ASTNode): for source_id, contracts_out in contracts.items(): ast_data = output["sources"][source_id]["ast"] - ast = ASTNode.parse_obj(ast_data) + ast = ASTNode.model_validate(ast_data) classify_ast(ast) for contract_name, ct_data in contracts_out.items(): @@ -470,7 +470,7 @@ def classify_ast(_node: ASTNode): ct_data["devdoc"] = load_dict(ct_data["devdoc"]) ct_data["sourcemap"] = evm_data["bytecode"]["sourceMap"] ct_data["ast"] = ast - contract_type = ContractType.parse_obj(ct_data) + contract_type = ContractType.model_validate(ct_data) contract_types.append(contract_type) solc_versions_by_contract_name[contract_name] = solc_version @@ -778,7 +778,7 @@ def flatten_contract(self, path: Path, **kwargs) -> Content: source = "\n".join([pragma, source]) lines = source.splitlines() line_dict = {i + 1: line for i, line in enumerate(lines)} - return Content(__root__=line_dict) + return Content(root=line_dict) def remove_imports(flattened_contract: str) -> str: diff --git a/setup.py b/setup.py index 848d459..e187c26 100644 --- a/setup.py +++ b/setup.py @@ -11,14 +11,14 @@ "hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer ], "lint": [ - "black>=23.3.0,<24", # Auto-formatter and linter - "mypy>=0.991,<1", # Static type analyzer + "black>=23.9.1,<24", # Auto-formatter and linter + "mypy>=1.6.0,<2", # Static type analyzer "types-requests", # Needed due to mypy typeshed "types-setuptools", # Needed due to mypy typeshed "types-pkg-resources", # Needed for type checking tests - "flake8>=6.0.0,<7", # Style linter + "flake8>=6.1.0,<7", # Style linter "isort>=5.10.1,<6", # Import sorting linter - "mdformat>=0.7.16", # Auto-formatter for markdown + "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 ],