Skip to content

Commit

Permalink
chore: mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
renatav committed Nov 27, 2024
1 parent cb5b45a commit 2070426
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions taf/api/api_workflow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from contextlib import contextmanager
from pathlib import Path
from typing import Dict, List, Optional, Sequence, Union
from typing import Dict, List, Optional, Union

from taf.api.utils._conf import find_keystore
from taf.auth_repo import AuthenticationRepository
Expand All @@ -15,11 +15,11 @@
@contextmanager
def manage_repo_and_signers(
auth_repo: AuthenticationRepository,
roles: Optional[Sequence[str]] = None,
roles: Optional[List[str]] = None,
keystore: Optional[Union[str, Path]] = None,
scheme: Optional[str] = DEFAULT_RSA_SIGNATURE_SCHEME,
prompt_for_keys: Optional[bool] = False,
paths_to_reset_on_error: Optional[Sequence[Union[str, Path]]] = None,
paths_to_reset_on_error: Optional[List[Union[str, Path]]] = None,
load_roles: Optional[bool] = True,
load_parents: Optional[bool] = False,
load_snapshot_and_timestamp: Optional[bool] = True,
Expand Down Expand Up @@ -75,7 +75,7 @@ def manage_repo_and_signers(
if auth_repo.is_git_repository and paths_to_reset_on_error:
# restore metadata, leave targets as they might have been modified by the user
# TODO flag for also resetting targets?
# also update the CLI error handling
auth_repo.restore(paths_to_reset_on_error)
# also update the CLI error handling]
auth_repo.restore([str(path) for path in paths_to_reset_on_error])

raise TAFError from e
2 changes: 1 addition & 1 deletion taf/api/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def register_target_files(
all_updated_targets.extend(list(removed_targets_data.keys()))

roles_and_targets = defaultdict(list)
paths_to_reset = []
paths_to_reset: List = []
for path in all_updated_targets:
roles_and_targets[auth_repo.get_role_from_target_paths([path])].append(path)
if reset_updated_targets_on_error:
Expand Down
20 changes: 11 additions & 9 deletions taf/yubikey.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,17 @@ def setup(


def setup_new_yubikey(serial_num, scheme=DEFAULT_RSA_SIGNATURE_SCHEME, key_size=2048):
pin = get_key_pin(serial_num)
cert_cn = input("Enter key holder's name: ")
print("Generating key, please wait...")
pub_key_pem = setup(
pin, cert_cn, cert_exp_days=EXPIRATION_INTERVAL, key_size=key_size
).decode("utf-8")
scheme = DEFAULT_RSA_SIGNATURE_SCHEME
key = import_rsakey_from_pem(pub_key_pem, scheme)
return key
# TODO
# pin = get_key_pin(serial_num)
# cert_cn = input("Enter key holder's name: ")
# print("Generating key, please wait...")
# pub_key_pem = setup(
# pin, cert_cn, cert_exp_days=EXPIRATION_INTERVAL, key_size=key_size
# ).decode("utf-8")
# scheme = DEFAULT_RSA_SIGNATURE_SCHEME
# key = import_rsakey_from_pem(pub_key_pem, scheme)
# return key
return None


def get_and_validate_pin(key_name, pin_confirm=True, pin_repeat=True):
Expand Down

0 comments on commit 2070426

Please sign in to comment.