Skip to content

Commit

Permalink
refactor: check isinstance and others
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 2, 2024
1 parent 70096c3 commit 52eb480
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ repos:
rev: 7.1.0
hooks:
- id: flake8
additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
Expand Down
26 changes: 24 additions & 2 deletions ape_foundry/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@
from yarl import URL

from ape_foundry.constants import EVM_VERSION_BY_NETWORK
from ape_foundry.exceptions import (
FoundryNotInstalledError,
FoundryProviderError,
FoundrySubprocessError,
)

from .exceptions import FoundryNotInstalledError, FoundryProviderError, FoundrySubprocessError
try:
from ape_optimism import Optimism
except ImportError:
Optimism = None

EPHEMERAL_PORTS_START = 49152
EPHEMERAL_PORTS_END = 60999
Expand Down Expand Up @@ -104,6 +112,13 @@ class FoundryNetworkConfig(PluginConfig):
rather than only when a new transaction is submitted.
"""

use_optimism: Optional[bool] = None
"""
Configure the node to run with the `--optimism` flag.
NOTE: When using Optimism-based networks (including Base),
this flag is automatically added.
"""

model_config = SettingsConfigDict(extra="allow")

@field_validator("fork", mode="before")
Expand Down Expand Up @@ -457,7 +472,14 @@ def build_command(self) -> list[str]:
if evm_version := self.evm_version:
cmd.extend(("--hardfork", evm_version))

if self.network.ecosystem.name in ("optimism", "base"):
# Optimism-based networks are different; Anvil provides a flag to make
# testing more like the real network(s).
if self.settings.use_optimism or (
Optimism is not None
and isinstance(
self.network.ecosystem, Optimism and self.settings.use_optimism is not False
)
):
cmd.append("--optimism")

return cmd
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exclude =
venv*
docs
build
ignore = E704,W503,PYD002
per-file-ignores =
# The traces have to be formatted this way for the tests.
tests/expected_traces.py: E501
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"flake8>=7.1.0,<8", # 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
"flake8-pydantic", # For detecting issues with Pydantic models
"isort>=5.13.2,<6", # Import sorting linter
"mdformat>=0.7.17", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown
Expand Down

0 comments on commit 52eb480

Please sign in to comment.