Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: plugin load time #35

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml

- repo: https://github.com/PyCQA/isort
rev: v5.13.2
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.10.0
hooks:
- id: black
name: black

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [types-setuptools, pydantic]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
rev: 0.7.18
hooks:
- id: mdformat
additional_dependencies: [mdformat-gfm, mdformat-frontmatter]
Expand Down
24 changes: 19 additions & 5 deletions ape_optimism/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
from ape import plugins
from ape.api.networks import LOCAL_NETWORK_NAME, ForkedNetworkAPI, NetworkAPI, create_network_type
from ape_node import Node
from ape_test import LocalProvider

from .ecosystem import NETWORKS, Optimism, OptimismConfig


@plugins.register(plugins.Config)
def config_class():
from ape_optimism.ecosystem import OptimismConfig

return OptimismConfig


@plugins.register(plugins.EcosystemPlugin)
def ecosystems():
from ape_optimism.ecosystem import Optimism

yield Optimism


@plugins.register(plugins.NetworkPlugin)
def networks():
from ape.api.networks import (
LOCAL_NETWORK_NAME,
ForkedNetworkAPI,
NetworkAPI,
create_network_type,
)

from ape_optimism.ecosystem import NETWORKS

for network_name, network_params in NETWORKS.items():
yield "optimism", network_name, create_network_type(*network_params)
yield "optimism", f"{network_name}-fork", ForkedNetworkAPI
Expand All @@ -28,6 +36,12 @@ def networks():

@plugins.register(plugins.ProviderPlugin)
def providers():
from ape.api.networks import LOCAL_NETWORK_NAME
from ape_node import Node
from ape_test import LocalProvider

from ape_optimism.ecosystem import NETWORKS

for network_name in NETWORKS:
yield "optimism", network_name, Node

Expand Down
8 changes: 5 additions & 3 deletions ape_optimism/ecosystem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import cast
from typing import TYPE_CHECKING, cast

from ape.api import TransactionAPI
from ape.exceptions import ApeException, APINotImplementedError
Expand All @@ -8,7 +8,9 @@
NetworkConfig,
create_network_config,
)
from eth_pydantic_types import HexBytes

if TYPE_CHECKING:
from eth_pydantic_types import HexBytes

NETWORKS = {
# chain_id, network_id
Expand All @@ -34,7 +36,7 @@ class SystemTransaction(TransactionAPI):
type: int = SYSTEM_TRANSACTION

@property
def txn_hash(self) -> HexBytes:
def txn_hash(self) -> "HexBytes":
raise APINotImplementedError("Unable to calculate the hash of system transactions.")

def serialize_transaction(self) -> bytes:
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[flake8]
max-line-length = 100
ignore = E704,W503,PYD002,TC003,TC006
exclude =
venv*
.eggs
docs
build
type-checking-pydantic-enabled = True
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
],
"lint": [
"black>=24.4.2,<25", # Auto-formatter and linter
"mypy>=1.10.0,<2", # Static type analyzer
"black>=24.10.0,<25", # Auto-formatter and linter
"mypy>=1.13.0,<2", # Static type analyzer
"types-setuptools", # Needed for mypy type shed
"flake8>=7.0.0,<8", # Style linter
"flake8>=7.1.1,<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
"isort>=5.13.2,<6", # Import sorting linter
"mdformat>=0.7.17", # Auto-formatter for markdown
"mdformat>=0.7.18", # 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.1", # Allows configuring in pyproject.toml
Expand Down
Loading