Skip to content

Commit

Permalink
perf: make console help fast
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Nov 1, 2024
1 parent 93bd182 commit b2355ef
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ape/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def parse_args(self, ctx: "Context", args: list[str]) -> list[str]:
from ape.api.providers import ProviderAPI

arguments = args # Renamed for better pdb support.
base_type = ProviderAPI if self._use_cls_types else str
base_type = None if self._use_cls_types else str
if existing_option := next(
iter(
x
Expand All @@ -85,13 +83,20 @@ def parse_args(self, ctx: "Context", args: list[str]) -> list[str]:
),
None,
):
if base_type is None:
from ape.api.providers import ProviderAPI

base_type = ProviderAPI

# Checking instance above, not sure why mypy still mad.
existing_option.type.base_type = base_type # type: ignore

else:
# Add the option automatically.
# NOTE: Local import here only avoids circular import issues.
from ape.cli.options import NetworkOption

# NOTE: None base-type will default to `ProviderAPI`.
option = NetworkOption(base_type=base_type, callback=self._network_callback)
self.params.append(option)

Expand Down

0 comments on commit b2355ef

Please sign in to comment.