Skip to content

Commit

Permalink
refactor: types
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jul 4, 2024
1 parent 8a55bd3 commit 85b3336
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 1 addition & 3 deletions ape_keyring/_cli/secrets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

import click
from ape.cli import ape_cli_context

Expand All @@ -22,7 +20,7 @@ def _list(cli_ctx):
cli_ctx.logger.warning("No secrets found.")
return

def output_secret_list(header: str, secret_keys: List[str]) -> bool:
def output_secret_list(header: str, secret_keys: list[str]) -> bool:
if not secret_keys:
return False

Expand Down
6 changes: 3 additions & 3 deletions ape_keyring/_secrets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from enum import Enum
from pathlib import Path
from typing import List, Optional, Union
from typing import Optional, Union

from ape.utils import ManagerAccessMixin, load_config

Expand Down Expand Up @@ -36,12 +36,12 @@ def secrets_exist(self) -> bool:
return self.project_keys or self.global_keys # type: ignore

@property
def project_keys(self) -> List[str]:
def project_keys(self) -> list[str]:
keys = self._storage.keys
return [k.replace(self._project_key, "") for k in keys if self._project_key in k]

@property
def global_keys(self) -> List[str]:
def global_keys(self) -> list[str]:
keys = self._storage.keys
return [k for k in keys if k not in self.project_keys and self._project_key_prefix not in k]

Expand Down
3 changes: 2 additions & 1 deletion ape_keyring/accounts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Iterator, Optional
from collections.abc import Iterator
from typing import Any, Optional

from ape.api import AccountAPI, AccountContainerAPI, TransactionAPI
from ape.exceptions import AccountsError
Expand Down
8 changes: 4 additions & 4 deletions ape_keyring/storage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from pathlib import Path
from typing import Any, Dict, List, Optional
from typing import Any, Optional

import keyring
from ape.logging import logger
Expand Down Expand Up @@ -48,14 +48,14 @@ def data_file_path(self) -> Path:
return self.data_folder / "data.json"

@property
def plugin_data(self) -> Dict:
def plugin_data(self) -> dict:
if self.data_file_path.is_file():
return json.loads(self.data_file_path.read_text())

return {}

@property
def keys(self) -> List[str]:
def keys(self) -> list[str]:
"""
A list of stored item keys. Each key can unlock a secret.
Expand Down Expand Up @@ -105,7 +105,7 @@ def delete_all(self):
for key in self.keys:
_delete_secret(key)

def _track(self, new_keys: List[str]):
def _track(self, new_keys: list[str]):
self._store_public_data(self._tracker_key, new_keys)

def _store_public_data(self, key: str, value: Any):
Expand Down

0 comments on commit 85b3336

Please sign in to comment.