diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba43032..58166e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,30 +5,30 @@ repos: - id: check-yaml - repo: https://github.com/PyCQA/isort - rev: 5.13.2 + rev: 6.0.0 hooks: - id: isort - repo: https://github.com/psf/black - rev: 24.10.0 + rev: 25.1.0 hooks: - id: black name: black - repo: https://github.com/pycqa/flake8 - rev: 7.1.1 + rev: 7.1.2 hooks: - id: flake8 additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.13.0 + rev: v1.15.0 hooks: - id: mypy additional_dependencies: [types-requests, types-setuptools] - repo: https://github.com/executablebooks/mdformat - rev: 0.7.19 + rev: 0.7.22 hooks: - id: mdformat additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject] diff --git a/ape_solidity/compiler.py b/ape_solidity/compiler.py index 246f51e..dcfaecb 100644 --- a/ape_solidity/compiler.py +++ b/ape_solidity/compiler.py @@ -64,6 +64,11 @@ DEFAULT_OPTIMIZATION_RUNS = 200 +def _install_solc(version: Version) -> Version: + logger.info(f"Installing solc '{version}'.") + return install_solc(version, show_progress=True) + + class ImportRemapping(PluginConfig): """ A remapped import set in the config. @@ -222,7 +227,7 @@ def _get_configured_version( specified_commit_hash = "+" in version base_version = strip_commit_hash(version) if base_version not in installed_versions: - install_solc(base_version, show_progress=True) + _install_solc(base_version) settings_version = add_commit_hash(base_version) if specified_commit_hash and settings_version != version: @@ -608,7 +613,7 @@ def compile_code( else: if selected_version := select_version(pragma, self.available_versions): version = selected_version - install_solc(version, show_progress=True) + _install_solc(version) else: raise SolcInstallError() @@ -616,7 +621,7 @@ def compile_code( version = latest_installed elif latest := self.latest_version: - install_solc(latest, show_progress=True) + _install_solc(latest) version = latest else: @@ -713,7 +718,7 @@ def get_version_map_from_imports( and not any(pragma_map.values()) and (latest := self.latest_version) ): - install_solc(latest, show_progress=True) + _install_solc(latest) # Adjust best-versions based on imports. files_by_solc_version: dict[Version, set[Path]] = {} @@ -794,7 +799,7 @@ def _get_pramga_spec_from_str(self, source_str: str) -> Optional["SpecifierSet"] return pragma_spec elif compiler_version := select_version(pragma_spec, self.available_versions): - install_solc(compiler_version, show_progress=True) + _install_solc(compiler_version) else: # Attempt to use the best-installed version. @@ -837,7 +842,7 @@ def _get_best_version(self, path: Path, source_by_pragma_spec: dict) -> Version: elif selected := select_version(pragma_spec, self.available_versions): # Install missing version. # NOTE: Must be installed before adding commit hash. - install_solc(selected, show_progress=True) + _install_solc(selected) compiler_version = add_commit_hash(selected) elif latest_installed := self.latest_installed_version: @@ -845,7 +850,7 @@ def _get_best_version(self, path: Path, source_by_pragma_spec: dict) -> Version: elif latest := self.latest_version: # Download latest version. - install_solc(latest, show_progress=True) + _install_solc(latest) compiler_version = latest else: diff --git a/setup.cfg b/setup.cfg index 1c41709..0bcc87f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,7 @@ max-line-length = 100 ignore = E704,W503,PYD002,TC003,TC006 exclude = + *.venv* venv* docs build diff --git a/setup.py b/setup.py index 0f5809c..1e464d4 100644 --- a/setup.py +++ b/setup.py @@ -12,15 +12,15 @@ "pytest-benchmark", # For performance tests ], "lint": [ - "black>=24.10.0,<25", # Auto-formatter and linter - "mypy>=1.13.0,<2", # Static type analyzer + "black>=25.1.0,<26", # Auto-formatter and linter + "mypy>=1.15.0,<2", # Static type analyzer "types-requests", # Needed for mypy type shed "types-setuptools", # Needed for mypy type shed - "flake8>=7.1.1,<8", # Style linter + "flake8>=7.1.2,<8", # Style linter "flake8-pydantic", # For detecting issues with Pydantic models "flake8-type-checking", # Detect imports to move in/out of type-checking blocks "isort>=5.13.2,<6", # Import sorting linter - "mdformat>=0.7.19", # Auto-formatter for markdown + "mdformat>=0.7.22", # 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.2", # Allows configuring in pyproject.toml