Skip to content

Commit

Permalink
fix: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Oct 10, 2023
1 parent 5b060bb commit 1064516
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/ape/api/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ class ProviderAPI(BaseInterfaceModel):
network: NetworkAPI
"""A reference to the network this provider provides."""

provider_settings: dict
provider_settings: Dict
"""The settings for the provider, as overrides to the configuration."""

data_folder: Path
"""The path to the ``.ape`` directory."""

request_header: dict
request_header: Dict
"""A header to set on HTTP/RPC requests."""

cached_chain_id: Optional[int] = None
cached_chain_id: Optional[int] = Field(None, exclude=True)
"""Implementation providers may use this to cache and re-use chain ID."""

block_page_size: int = 100
Expand Down Expand Up @@ -1752,7 +1752,10 @@ def disconnect(self):
Subclasses override this method to do provider-specific disconnection tasks.
"""

self.cached_chain_id = None # type: ignore
# NOTE: Setting it this way mostly because of a mypy issue.
default_value = self.model_fields["cached_chain_id"].default
self.cached_chain_id = default_value

if self.process:
self.stop()

Expand Down
4 changes: 2 additions & 2 deletions src/ape_test/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def connect(self):
self._web3 = Web3(tester)

def disconnect(self):
self.cached_chain_id = None # type: ignore
self.cached_chain_id = None
self._web3 = None
self._evm_backend = None

Expand Down Expand Up @@ -111,7 +111,7 @@ def estimate_gas_cost(self, txn: TransactionAPI, **kwargs) -> int:

@property
def chain_id(self) -> int:
if self.cached_chain_id:
if self.cached_chain_id is not None:
return self.cached_chain_id

try:
Expand Down

0 comments on commit 1064516

Please sign in to comment.