Skip to content

Commit 9e47333

Browse files
committed
api: Lint metadata.py
While working using pylint 2.5.3 (from debian package 2.5.3-2) I noticed those warnings that were not triggered by pylint 2.7.2 used in current tox configuration. After some investigation pylint-2.6, dropped "bad-continuation" feature. This will not harm to support older pylint versions, until an other formater (like blank) is introduced. Relate-to: #1294 Signed-off-by: Philippe Coval <[email protected]>
1 parent 313511a commit 9e47333

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tuf/api/metadata.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ class also that has a 'from_dict' factory method. (Currently this is
9696
# metadata['signatures'], call Signature.from_dict for each item, and
9797
# pass a list of Signature objects to the Metadata constructor intead.
9898
return cls(
99-
signed=inner_cls.from_dict(metadata['signed']),
100-
signatures=metadata['signatures'])
99+
signed=inner_cls.from_dict(metadata['signed']),
100+
signatures=metadata['signatures'])
101101

102102

103103
@classmethod
@@ -122,7 +122,7 @@ def from_json(cls, metadata_json: str) -> 'Metadata':
122122
def from_json_file(
123123
cls, filename: str,
124124
storage_backend: Optional[StorageBackendInterface] = None
125-
) -> 'Metadata':
125+
) -> 'Metadata':
126126
"""Loads JSON-formatted TUF metadata from file storage.
127127
128128
Arguments:
@@ -155,10 +155,10 @@ def to_dict(self) -> JsonDict:
155155
def to_json(self, compact: bool = False) -> None:
156156
"""Returns the optionally compacted JSON representation of self. """
157157
return json.dumps(
158-
self.to_dict(),
159-
indent=(None if compact else 1),
160-
separators=((',', ':') if compact else (',', ': ')),
161-
sort_keys=True)
158+
self.to_dict(),
159+
indent=(None if compact else 1),
160+
separators=((',', ':') if compact else (',', ': ')),
161+
sort_keys=True)
162162

163163

164164
def to_json_file(
@@ -232,16 +232,16 @@ def verify(self, key: JsonDict) -> bool:
232232
233233
"""
234234
signatures_for_keyid = list(filter(
235-
lambda sig: sig['keyid'] == key['keyid'], self.signatures))
235+
lambda sig: sig['keyid'] == key['keyid'], self.signatures))
236236

237237
if not signatures_for_keyid:
238238
raise tuf.exceptions.Error(
239-
f'no signature for key {key["keyid"]}.')
239+
f'no signature for key {key["keyid"]}.')
240240

241241
if len(signatures_for_keyid) > 1:
242242
raise tuf.exceptions.Error(
243-
f'{len(signatures_for_keyid)} signatures for key '
244-
f'{key["keyid"]}, not sure which one to verify.')
243+
f'{len(signatures_for_keyid)} signatures for key '
244+
f'{key["keyid"]}, not sure which one to verify.')
245245

246246
return verify_signature(
247247
key, signatures_for_keyid[0],
@@ -293,7 +293,7 @@ def from_dict(cls, signed_dict: JsonDict) -> 'Signed':
293293
# what the constructor expects and what we store. The inverse operation
294294
# is implemented in 'to_dict'.
295295
signed_dict['expires'] = tuf.formats.expiry_string_to_datetime(
296-
signed_dict['expires'])
296+
signed_dict['expires'])
297297
# NOTE: We write the converted 'expires' back into 'signed_dict' above
298298
# so that we can pass it to the constructor as '**signed_dict' below,
299299
# along with other fields that belong to Signed subclasses.
@@ -582,7 +582,7 @@ class Targets(Signed):
582582
def __init__(
583583
self, _type: str, version: int, spec_version: str,
584584
expires: datetime, targets: JsonDict, delegations: JsonDict
585-
) -> None:
585+
) -> None:
586586
super().__init__(_type, version, spec_version, expires)
587587
# TODO: Add class for meta
588588
self.targets = targets

0 commit comments

Comments
 (0)