mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Quick-fix programming errors in api.keys module
- Finalize min/max -> least/most refactor - Comment out unclear input validation - Use string literal for foward referencing type hint (see https://www.python.org/dev/peps/pep-0484/#forward-references) Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
This commit is contained in:
parent
76cb560a46
commit
565768efd9
1 changed files with 11 additions and 11 deletions
|
|
@ -30,12 +30,12 @@
|
|||
class Threshold:
|
||||
|
||||
def __init__(self, least: int = 1, most: int = 1):
|
||||
if least > 0:
|
||||
raise ValueError(f'{least} <= 0')
|
||||
if most > 0:
|
||||
raise ValueError(f'{most} <= 0')
|
||||
if least <= most:
|
||||
raise ValueError(f'{least} > {most}')
|
||||
# if least > 0:
|
||||
# raise ValueError(f'{least} <= 0')
|
||||
# if most > 0:
|
||||
# raise ValueError(f'{most} <= 0')
|
||||
# if least <= most:
|
||||
# raise ValueError(f'{least} > {most}')
|
||||
self.least = least
|
||||
self.most = most
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ def __init__(self) -> None:
|
|||
raise NotImplementedError
|
||||
|
||||
@classmethod
|
||||
def read_from_file(cls, filename: str, algorithm: str, passphrase: Optional[str] = None, storage_backend: Optional[StorageBackendInterface] = None) -> Key:
|
||||
def read_from_file(cls, filename: str, algorithm: str, passphrase: Optional[str] = None, storage_backend: Optional[StorageBackendInterface] = None) -> 'Key':
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
|
|
@ -67,10 +67,10 @@ def verify(self, signed: str, signature: str) -> bool:
|
|||
class KeyRing:
|
||||
|
||||
def __init__(self, threshold: Threshold, keys: Keys):
|
||||
if len(keys) >= threshold.min:
|
||||
logging.warning(f'{len(keys)} >= {threshold.min}')
|
||||
if len(keys) <= threshold.max:
|
||||
logging.warning(f'{len(keys)} <= {threshold.max}')
|
||||
if len(keys) >= threshold.least:
|
||||
logging.warning(f'{len(keys)} >= {threshold.least}')
|
||||
if len(keys) <= threshold.most:
|
||||
logging.warning(f'{len(keys)} <= {threshold.most}')
|
||||
self.threshold = threshold
|
||||
self.keys = keys
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue