Skip to content

Commit

Permalink
chore: formatting and mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
renatav committed Oct 6, 2023
1 parent 2777230 commit 4918555
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion taf/api/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _determine_out_of_band_data(
dependency: GitRepository,
branch_name: str,
out_of_band_commit: str,
no_prompt: bool,
no_prompt: Optional[bool] = False,
):
"""
Determines values of out-of-band branch and commit as a part of adding a new
Expand Down
6 changes: 3 additions & 3 deletions taf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
)
def check_expiration_dates(
path: str,
interval: Optional[int] = None,
interval: Optional[int] = 30,
start_date: Optional[datetime] = None,
excluded_roles: Optional[List[str]] = None,
print: bool = True,
print_output: bool = True,
) -> Tuple[Dict, Dict]:
"""
Check if any metadata files (roles) are expired or will expire in the next <interval> days.
Expand All @@ -51,7 +51,7 @@ def check_expiration_dates(
interval, start_date, excluded_roles
)

if print:
if print_output:
print_expiration_dates(
expired_dict, will_expire_dict, start_date=start_date, interval=interval
)
Expand Down
4 changes: 2 additions & 2 deletions taf/api/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def _get_roles_key_size(role: str, keystore: str, keys_num: int) -> int:
def list_keys_of_role(
path: str,
role: str,
) -> None:
) -> List[str]:
"""
Print information about signing keys of role. If a certificate whose name matches
a key's id exists, include information contained by that certificate (like name and valid to/from dates)
Expand Down Expand Up @@ -718,7 +718,7 @@ def remove_role(
if target_file_path.is_file():
if remove_targets:
os.unlink(str(target_file_path))
removed_targets.append(target_file_path)
removed_targets.append(str(target_file_path))
else:
added_targets_data[target_file_path] = {}
else:
Expand Down
1 change: 0 additions & 1 deletion taf/api/utils/roles_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from tuf.repository_tool import Repository as TUFRepository, Targets
from taf.exceptions import TAFError
from taf.models.types import RolesIterator
from taf.models.types import Role, TargetsRole
from taf.yubikey import get_key_serial_by_id
from tuf.repository_tool import Metadata
from taf.keys import get_key_name
Expand Down
4 changes: 3 additions & 1 deletion taf/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ def _load_and_append_yubikeys(key_name, role, retry_on_failure):

return public_key is not None

keystore_files = get_keystore_keys_of_role(keystore, role)
keystore_files = []
if keystore is not None:
keystore_files = get_keystore_keys_of_role(keystore, role)
while not all_loaded and num_of_signatures < signing_keys_num:
all_loaded = num_of_signatures >= threshold

Expand Down
2 changes: 1 addition & 1 deletion taf/keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def default_keystore_path() -> str:
return keystore_path


def get_keystore_keys_of_role(keystore: str, role: str) -> str:
def get_keystore_keys_of_role(keystore: str, role: str) -> List[str]:
keystores_glob = f"{keystore}/{role}*"
# Use glob to find matching files
keystores = glob.glob(keystores_glob)
Expand Down
2 changes: 1 addition & 1 deletion taf/messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

MESSAGES = {
"git-commit": {
"create-repo": "Initialized repository",
Expand All @@ -18,6 +17,7 @@
}
}


def git_commit_message(key, **kwargs):
if not len(kwargs):
return MESSAGES["git-commit"][key]
Expand Down
2 changes: 0 additions & 2 deletions taf/tests/test_api/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import json
import os


from pathlib import Path
from taf.tests.conftest import KEYSTORES_PATH, TEST_DATA_PATH
Expand Down
1 change: 1 addition & 0 deletions taf/tests/test_api/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def _init_auth_repo_dir():
def child_repo_path():
repo_path = _init_auth_repo_dir()
yield repo_path
shutil.rmtree(str(repo_path.parent), onerror=on_rm_error)


@fixture(scope="module")
Expand Down

0 comments on commit 4918555

Please sign in to comment.