Skip to content

Commit

Permalink
perf: plugin load time (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Nov 14, 2024
1 parent d8f8e73 commit 0ea5350
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
23 changes: 18 additions & 5 deletions ape_hardhat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
"""

from ape import plugins
from ape.api.networks import LOCAL_NETWORK_NAME
from ape_ethereum.ecosystem import NETWORKS

from .exceptions import HardhatProviderError, HardhatSubprocessError
from .provider import HardhatForkProvider, HardhatNetworkConfig, HardhatProvider


@plugins.register(plugins.Config)
def config_class():
from .provider import HardhatNetworkConfig

return HardhatNetworkConfig


@plugins.register(plugins.ProviderPlugin)
def providers():
from ape.api.networks import LOCAL_NETWORK_NAME
from ape_ethereum.ecosystem import NETWORKS

from .provider import HardhatForkProvider, HardhatProvider

yield "ethereum", LOCAL_NETWORK_NAME, HardhatProvider

for network in NETWORKS:
Expand Down Expand Up @@ -57,6 +59,17 @@ def providers():
yield "gnosis", "chaido-fork", HardhatForkProvider


def __getattr__(name: str):
if name.endswith("Error"):
import ape_hardhat.exceptions as err_module

return getattr(err_module, name)

import ape_hardhat.provider as module

return getattr(module, name)


__all__ = [
"HardhatNetworkConfig",
"HardhatProvider",
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ exclude =
docs
build
node_modules
ignore = E704,W503,PYD002
ignore = E704,W503,PYD002,TC003,TC006
per-file-ignores =
# The traces have to be formatted this way for the tests.
tests/expected_traces.py: E501
type-checking-pydantic-enabled = True

0 comments on commit 0ea5350

Please sign in to comment.