Skip to content

Commit 878c8c6

Browse files
author
Jussi Kukkonen
authored
Merge pull request #1363 from MVrachev/black-identation
Fix black docstring indentation errors
2 parents ec7173f + 1712b71 commit 878c8c6

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

tuf/api/metadata.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def from_bytes(
164164
return deserializer.deserialize(data)
165165

166166
def to_dict(self) -> Dict[str, Any]:
167-
"""Returns the dict representation of self. """
167+
"""Returns the dict representation of self."""
168168

169169
signatures = []
170170
for sig in self.signatures:
@@ -397,7 +397,7 @@ def is_expired(self, reference_time: datetime = None) -> bool:
397397

398398
# Modification.
399399
def bump_expiration(self, delta: timedelta = timedelta(days=1)) -> None:
400-
"""Increments the expires attribute by the passed timedelta. """
400+
"""Increments the expires attribute by the passed timedelta."""
401401
self.expires += delta
402402

403403
def bump_version(self) -> None:
@@ -465,7 +465,7 @@ def __init__(
465465

466466
@classmethod
467467
def from_dict(cls, root_dict: Mapping[str, Any]) -> "Root":
468-
"""Creates Root object from its dict representation. """
468+
"""Creates Root object from its dict representation."""
469469
common_args = cls._common_fields_from_dict(root_dict)
470470
consistent_snapshot = root_dict.pop("consistent_snapshot")
471471
keys = root_dict.pop("keys")
@@ -474,7 +474,7 @@ def from_dict(cls, root_dict: Mapping[str, Any]) -> "Root":
474474
return cls(*common_args, consistent_snapshot, keys, roles, root_dict)
475475

476476
def to_dict(self) -> Dict[str, Any]:
477-
"""Returns the dict representation of self. """
477+
"""Returns the dict representation of self."""
478478
root_dict = self._common_fields_to_dict()
479479
root_dict.update(
480480
{
@@ -489,14 +489,14 @@ def to_dict(self) -> Dict[str, Any]:
489489
def add_key(
490490
self, role: str, keyid: str, key_metadata: Mapping[str, Any]
491491
) -> None:
492-
"""Adds new key for 'role' and updates the key store. """
492+
"""Adds new key for 'role' and updates the key store."""
493493
if keyid not in self.roles[role]["keyids"]:
494494
self.roles[role]["keyids"].append(keyid)
495495
self.keys[keyid] = key_metadata
496496

497497
# Remove key for a role.
498498
def remove_key(self, role: str, keyid: str) -> None:
499-
"""Removes key for 'role' and updates the key store. """
499+
"""Removes key for 'role' and updates the key store."""
500500
if keyid in self.roles[role]["keyids"]:
501501
self.roles[role]["keyids"].remove(keyid)
502502
for keyinfo in self.roles.values():
@@ -543,14 +543,14 @@ def __init__(
543543

544544
@classmethod
545545
def from_dict(cls, timestamp_dict: Mapping[str, Any]) -> "Timestamp":
546-
"""Creates Timestamp object from its dict representation. """
546+
"""Creates Timestamp object from its dict representation."""
547547
common_args = cls._common_fields_from_dict(timestamp_dict)
548548
meta = timestamp_dict.pop("meta")
549549
# All fields left in the timestamp_dict are unrecognized.
550550
return cls(*common_args, meta, timestamp_dict)
551551

552552
def to_dict(self) -> Dict[str, Any]:
553-
"""Returns the dict representation of self. """
553+
"""Returns the dict representation of self."""
554554
timestamp_dict = self._common_fields_to_dict()
555555
timestamp_dict.update({"meta": self.meta})
556556
return timestamp_dict
@@ -559,7 +559,7 @@ def to_dict(self) -> Dict[str, Any]:
559559
def update(
560560
self, version: int, length: int, hashes: Mapping[str, Any]
561561
) -> None:
562-
"""Assigns passed info about snapshot metadata to meta dict. """
562+
"""Assigns passed info about snapshot metadata to meta dict."""
563563
self.meta["snapshot.json"] = {
564564
"version": version,
565565
"length": length,
@@ -611,14 +611,14 @@ def __init__(
611611

612612
@classmethod
613613
def from_dict(cls, snapshot_dict: Mapping[str, Any]) -> "Snapshot":
614-
"""Creates Snapshot object from its dict representation. """
614+
"""Creates Snapshot object from its dict representation."""
615615
common_args = cls._common_fields_from_dict(snapshot_dict)
616616
meta = snapshot_dict.pop("meta")
617617
# All fields left in the snapshot_dict are unrecognized.
618618
return cls(*common_args, meta, snapshot_dict)
619619

620620
def to_dict(self) -> Dict[str, Any]:
621-
"""Returns the dict representation of self. """
621+
"""Returns the dict representation of self."""
622622
snapshot_dict = self._common_fields_to_dict()
623623
snapshot_dict.update({"meta": self.meta})
624624
return snapshot_dict
@@ -631,7 +631,7 @@ def update(
631631
length: Optional[int] = None,
632632
hashes: Optional[Mapping[str, Any]] = None,
633633
) -> None:
634-
"""Assigns passed (delegated) targets role info to meta dict. """
634+
"""Assigns passed (delegated) targets role info to meta dict."""
635635
metadata_fn = f"{rolename}.json"
636636

637637
self.meta[metadata_fn] = {"version": version}
@@ -719,15 +719,15 @@ def __init__(
719719

720720
@classmethod
721721
def from_dict(cls, targets_dict: Mapping[str, Any]) -> "Targets":
722-
"""Creates Targets object from its dict representation. """
722+
"""Creates Targets object from its dict representation."""
723723
common_args = cls._common_fields_from_dict(targets_dict)
724724
targets = targets_dict.pop("targets")
725725
delegations = targets_dict.pop("delegations")
726726
# All fields left in the targets_dict are unrecognized.
727727
return cls(*common_args, targets, delegations, targets_dict)
728728

729729
def to_dict(self) -> Dict[str, Any]:
730-
"""Returns the dict representation of self. """
730+
"""Returns the dict representation of self."""
731731
targets_dict = self._common_fields_to_dict()
732732
targets_dict.update(
733733
{
@@ -739,5 +739,5 @@ def to_dict(self) -> Dict[str, Any]:
739739

740740
# Modification.
741741
def update(self, filename: str, fileinfo: Mapping[str, Any]) -> None:
742-
"""Assigns passed target file info to meta dict. """
742+
"""Assigns passed target file info to meta dict."""
743743
self.targets[filename] = fileinfo

tuf/api/serialization/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@
1919

2020
# TODO: Should these be in tuf.exceptions or inherit from tuf.exceptions.Error?
2121
class SerializationError(Exception):
22-
"""Error during serialization. """
22+
"""Error during serialization."""
2323

2424

2525
class DeserializationError(Exception):
26-
"""Error during deserialization. """
26+
"""Error during deserialization."""
2727

2828

2929
class MetadataDeserializer(metaclass=abc.ABCMeta):
30-
"""Abstract base class for deserialization of Metadata objects. """
30+
"""Abstract base class for deserialization of Metadata objects."""
3131

3232
@abc.abstractmethod
3333
def deserialize(self, raw_data: bytes) -> "Metadata":
34-
"""Deserialize passed bytes to Metadata object. """
34+
"""Deserialize passed bytes to Metadata object."""
3535
raise NotImplementedError
3636

3737

3838
class MetadataSerializer(metaclass=abc.ABCMeta):
39-
"""Abstract base class for serialization of Metadata objects. """
39+
"""Abstract base class for serialization of Metadata objects."""
4040

4141
@abc.abstractmethod
4242
def serialize(self, metadata_obj: "Metadata") -> bytes:
43-
"""Serialize passed Metadata object to bytes. """
43+
"""Serialize passed Metadata object to bytes."""
4444
raise NotImplementedError
4545

4646

4747
class SignedSerializer(metaclass=abc.ABCMeta):
48-
"""Abstract base class for serialization of Signed objects. """
48+
"""Abstract base class for serialization of Signed objects."""
4949

5050
@abc.abstractmethod
5151
def serialize(self, signed_obj: "Signed") -> bytes:
52-
"""Serialize passed Signed object to bytes. """
52+
"""Serialize passed Signed object to bytes."""
5353
raise NotImplementedError

tuf/api/serialization/json.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929

3030
class JSONDeserializer(MetadataDeserializer):
31-
"""Provides JSON to Metadata deserialize method. """
31+
"""Provides JSON to Metadata deserialize method."""
3232

3333
def deserialize(self, raw_data: bytes) -> Metadata:
34-
"""Deserialize utf-8 encoded JSON bytes into Metadata object. """
34+
"""Deserialize utf-8 encoded JSON bytes into Metadata object."""
3535
try:
3636
json_dict = json.loads(raw_data.decode("utf-8"))
3737
metadata_obj = Metadata.from_dict(json_dict)
@@ -55,7 +55,7 @@ def __init__(self, compact: bool = False) -> None:
5555
self.compact = compact
5656

5757
def serialize(self, metadata_obj: Metadata) -> bytes:
58-
"""Serialize Metadata object into utf-8 encoded JSON bytes. """
58+
"""Serialize Metadata object into utf-8 encoded JSON bytes."""
5959
try:
6060
indent = None if self.compact else 1
6161
separators = (",", ":") if self.compact else (",", ": ")
@@ -73,7 +73,7 @@ def serialize(self, metadata_obj: Metadata) -> bytes:
7373

7474

7575
class CanonicalJSONSerializer(SignedSerializer):
76-
"""Provides Signed to OLPC Canonical JSON serialize method. """
76+
"""Provides Signed to OLPC Canonical JSON serialize method."""
7777

7878
def serialize(self, signed_obj: Signed) -> bytes:
7979
"""Serialize Signed object into utf-8 encoded OLPC Canonical JSON

0 commit comments

Comments
 (0)