Skip to content

Commit

Permalink
refactor: make not optional
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Nov 1, 2023
1 parent f318f28 commit cbd6594
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/ape/api/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ def upstream_network(self) -> NetworkAPI:
return self.ecosystem.get_network(network_name)

@property
def upstream_provider(self) -> Optional["UpstreamProvider"]:
def upstream_provider(self) -> "UpstreamProvider":
"""
The provider used when requesting data before the local fork.
Set this in your config under the network settings.
Expand All @@ -1068,7 +1068,7 @@ def upstream_provider(self) -> Optional["UpstreamProvider"]:
if provider_name := config_choice or self.upstream_network.default_provider:
return self.get_provider(provider_name)

return None
raise NetworkError(f"Upstream network '{self.upstream_network}' has no providers.")

@property
def upstream_chain_id(self) -> int:
Expand All @@ -1088,10 +1088,7 @@ def use_upstream_provider(self) -> ProviderContextManager:
Returns:
:class:`~ape.api.networks.ProviderContextManager`
"""
if provider := self.upstream_provider:
return self.upstream_network.use_provider(provider.name)

raise NetworkError(f"Network {self.upstream_network.name} has no providers.")
return self.upstream_network.use_provider(self.upstream_provider.name)


def create_network_type(chain_id: int, network_id: int) -> Type[NetworkAPI]:
Expand Down

0 comments on commit cbd6594

Please sign in to comment.