Skip to content

Commit

Permalink
perf: plugin load time (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Nov 14, 2024
1 parent 948df19 commit 8e136ae
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 40 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml

Expand All @@ -10,7 +10,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
name: black
Expand All @@ -21,13 +21,13 @@ repos:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-requests, 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
47 changes: 14 additions & 33 deletions ape_infura/__init__.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,22 @@
from ape import plugins

from .provider import Infura

NETWORKS = {
"arbitrum": [
"mainnet",
"sepolia",
],
"avalanche": [
"fuji",
"mainnet",
],
"blast": [
"mainnet",
"sepolia",
],
"ethereum": [
"mainnet",
"sepolia",
],
# TODO: Comment out after ape-linea supports 0.7
# "linea": [
# "mainnet",
# ],
"optimism": [
"mainnet",
"sepolia",
],
"polygon": [
"mainnet",
"amoy",
],
}


@plugins.register(plugins.ProviderPlugin)
def providers():
from ape_infura.provider import Infura
from ape_infura.utils import NETWORKS

for ecosystem_name in NETWORKS:
for network_name in NETWORKS[ecosystem_name]:
yield ecosystem_name, network_name, Infura


def __getattr__(name: str):
if name == "NETWORKS":
from ape_infura.utils import NETWORKS

return NETWORKS

import ape_infura.provider as module

return getattr(module, name)
30 changes: 30 additions & 0 deletions ape_infura/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
NETWORKS = {
"arbitrum": [
"mainnet",
"sepolia",
],
"avalanche": [
"fuji",
"mainnet",
],
"blast": [
"mainnet",
"sepolia",
],
"ethereum": [
"mainnet",
"sepolia",
],
# TODO: Comment out after ape-linea supports 0.7
# "linea": [
# "mainnet",
# ],
"optimism": [
"mainnet",
"sepolia",
],
"polygon": [
"mainnet",
"amoy",
],
}
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[flake8]
max-line-length = 100
ignore = E704,W503,PYD002,TC003,TC006
exclude =
venv*
docs
build
type-checking-pydantic-enabled = True
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
"websocket-client", # Used for web socket integration testing
],
"lint": [
"black>=24.8.0,<25", # Auto-formatter and linter
"mypy>=1.11.1,<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.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

0 comments on commit 8e136ae

Please sign in to comment.