From b2355ef8229c6d8c0e3b17131d4515bd5ef61b9e Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Fri, 1 Nov 2024 12:22:50 -0500 Subject: [PATCH] perf: make console help fast --- src/ape/cli/commands.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ape/cli/commands.py b/src/ape/cli/commands.py index ea6110d42c..e695bbc908 100644 --- a/src/ape/cli/commands.py +++ b/src/ape/cli/commands.py @@ -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 @@ -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)