Skip to content

Commit a6460c6

Browse files
authored
Merge pull request #2278 from fridex/pydocstyle-first-line-period-rebase
Fix pydocstyle D400: first line should end with a period
2 parents 7f04a6e + 5d347b8 commit a6460c6

File tree

7 files changed

+31
-33
lines changed

7 files changed

+31
-33
lines changed

tuf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright New York University and the TUF contributors
22
# SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
"""TUF
4+
"""TUF.
55
"""
66

77
# This value is used in the requests user agent.

tuf/api/metadata.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright New York University and the TUF contributors
22
# SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
"""
4+
"""The low-level Metadata API.
5+
56
The low-level Metadata API in ``tuf.api.metadata`` module contains:
67
78
* Safe de/serialization of metadata to and from files.
@@ -550,13 +551,13 @@ def __eq__(self, other: Any) -> bool:
550551

551552
@abc.abstractmethod
552553
def to_dict(self) -> Dict[str, Any]:
553-
"""Serialize and return a dict representation of self"""
554+
"""Serialize and return a dict representation of self."""
554555
raise NotImplementedError
555556

556557
@classmethod
557558
@abc.abstractmethod
558559
def from_dict(cls, signed_dict: Dict[str, Any]) -> "Signed":
559-
"""Deserialization helper, creates object from json/dict representation"""
560+
"""Deserialization helper, creates object from json/dict representation."""
560561
raise NotImplementedError
561562

562563
@classmethod
@@ -1003,7 +1004,7 @@ class BaseFile:
10031004
def _verify_hashes(
10041005
data: Union[bytes, IO[bytes]], expected_hashes: Dict[str, str]
10051006
) -> None:
1006-
"""Verify that the hash of ``data`` matches ``expected_hashes``"""
1007+
"""Verify that the hash of ``data`` matches ``expected_hashes``."""
10071008
is_bytes = isinstance(data, bytes)
10081009
for algo, exp_hash in expected_hashes.items():
10091010
try:
@@ -1032,7 +1033,7 @@ def _verify_hashes(
10321033
def _verify_length(
10331034
data: Union[bytes, IO[bytes]], expected_length: int
10341035
) -> None:
1035-
"""Verify that the length of ``data`` matches ``expected_length``"""
1036+
"""Verify that the length of ``data`` matches ``expected_length``."""
10361037
if isinstance(data, bytes):
10371038
observed_length = len(data)
10381039
else:
@@ -1541,8 +1542,7 @@ def to_dict(self) -> Dict[str, Any]:
15411542
}
15421543

15431544
def get_role_for_target(self, target_filepath: str) -> str:
1544-
"""Calculate the name of the delegated role responsible for
1545-
``target_filepath``.
1545+
"""Calculate the name of the delegated role responsible for ``target_filepath``.
15461546
15471547
The target at path ``target_filepath`` is assigned to a bin by casting
15481548
the left-most ``bit_length`` of bits of the file path hash digest to

tuf/ngclient/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright New York University and the TUF contributors
22
# SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
"""TUF client public API
4+
"""TUF client public API.
55
"""
66

77

tuf/ngclient/_internal/requests_fetcher.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Copyright 2021, New York University and the TUF contributors
22
# SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
"""Provides an implementation of ``FetcherInterface`` using the Requests
5-
HTTP library.
4+
"""Provides an implementation of ``FetcherInterface`` using the Requests HTTP library.
65
"""
76

87
# requests_fetcher is public but comes from _internal for now (because
@@ -56,7 +55,7 @@ def __init__(self) -> None:
5655
self.chunk_size: int = 400000 # bytes
5756

5857
def _fetch(self, url: str) -> Iterator[bytes]:
59-
"""Fetch the contents of HTTP/HTTPS url from a remote server
58+
"""Fetch the contents of HTTP/HTTPS url from a remote server.
6059
6160
Args:
6261
url: URL string that represents a file location.
@@ -114,8 +113,7 @@ def _chunks(self, response: "requests.Response") -> Iterator[bytes]:
114113
response.close()
115114

116115
def _get_session(self, url: str) -> requests.Session:
117-
"""Return a different customized requests.Session per schema+hostname
118-
combination.
116+
"""Return a different customized requests.Session per schema+hostname combination.
119117
120118
Raises:
121119
exceptions.DownloadError: When there is a problem parsing the url.

tuf/ngclient/_internal/trusted_metadata_set.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright the TUF contributors
22
# SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
"""Trusted collection of client-side TUF Metadata
4+
"""Trusted collection of client-side TUF Metadata.
55
66
``TrustedMetadataSet`` keeps track of the current valid set of metadata for the
77
client, and handles almost every step of the "Detailed client workflow" (
@@ -71,15 +71,15 @@
7171

7272

7373
class TrustedMetadataSet(abc.Mapping):
74-
"""Internal class to keep track of trusted metadata in ``Updater``
74+
"""Internal class to keep track of trusted metadata in ``Updater``.
7575
7676
``TrustedMetadataSet`` ensures that the collection of metadata in it is valid
7777
and trusted through the whole client update workflow. It provides easy ways
7878
to update the metadata with the caller making decisions on what is updated.
7979
"""
8080

8181
def __init__(self, root_data: bytes):
82-
"""Initialize ``TrustedMetadataSet`` by loading trusted root metadata
82+
"""Initialize ``TrustedMetadataSet`` by loading trusted root metadata.
8383
8484
Args:
8585
root_data: Trusted root metadata as bytes. Note that this metadata
@@ -99,36 +99,36 @@ def __init__(self, root_data: bytes):
9999
self._load_trusted_root(root_data)
100100

101101
def __getitem__(self, role: str) -> Metadata:
102-
"""Return current ``Metadata`` for ``role``"""
102+
"""Return current ``Metadata`` for ``role``."""
103103
return self._trusted_set[role]
104104

105105
def __len__(self) -> int:
106-
"""Return number of ``Metadata`` objects in ``TrustedMetadataSet``"""
106+
"""Return number of ``Metadata`` objects in ``TrustedMetadataSet``."""
107107
return len(self._trusted_set)
108108

109109
def __iter__(self) -> Iterator[Metadata]:
110-
"""Return iterator over ``Metadata`` objects in ``TrustedMetadataSet``"""
110+
"""Return iterator over ``Metadata`` objects in ``TrustedMetadataSet``."""
111111
return iter(self._trusted_set.values())
112112

113113
# Helper properties for top level metadata
114114
@property
115115
def root(self) -> Metadata[Root]:
116-
"""Get current root ``Metadata``"""
116+
"""Get current root ``Metadata``."""
117117
return self._trusted_set[Root.type]
118118

119119
@property
120120
def timestamp(self) -> Metadata[Timestamp]:
121-
"""Get current timestamp ``Metadata``"""
121+
"""Get current timestamp ``Metadata``."""
122122
return self._trusted_set[Timestamp.type]
123123

124124
@property
125125
def snapshot(self) -> Metadata[Snapshot]:
126-
"""Get current snapshot ``Metadata``"""
126+
"""Get current snapshot ``Metadata``."""
127127
return self._trusted_set[Snapshot.type]
128128

129129
@property
130130
def targets(self) -> Metadata[Targets]:
131-
"""Get current top-level targets ``Metadata``"""
131+
"""Get current top-level targets ``Metadata``."""
132132
return self._trusted_set[Targets.type]
133133

134134
# Methods for updating metadata
@@ -251,7 +251,7 @@ def update_timestamp(self, data: bytes) -> Metadata[Timestamp]:
251251
return new_timestamp
252252

253253
def _check_final_timestamp(self) -> None:
254-
"""Raise if timestamp is expired"""
254+
"""Raise if timestamp is expired."""
255255

256256
if self.timestamp.signed.is_expired(self.reference_time):
257257
raise exceptions.ExpiredMetadataError("timestamp.json is expired")
@@ -345,7 +345,7 @@ def update_snapshot(
345345
return new_snapshot
346346

347347
def _check_final_snapshot(self) -> None:
348-
"""Raise if snapshot is expired or meta version does not match"""
348+
"""Raise if snapshot is expired or meta version does not match."""
349349

350350
if self.snapshot.signed.is_expired(self.reference_time):
351351
raise exceptions.ExpiredMetadataError("snapshot.json is expired")

tuf/ngclient/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2021, New York University and the TUF contributors
22
# SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
"""Configuration options for ``Updater`` class
4+
"""Configuration options for ``Updater`` class.
55
"""
66

77
from dataclasses import dataclass

tuf/ngclient/updater.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2020, New York University and the TUF contributors
22
# SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
"""Client update workflow implementation
4+
"""Client update workflow implementation.
55
66
The ``Updater`` class provides an implementation of the
77
`TUF client workflow
@@ -177,7 +177,7 @@ def find_cached_target(
177177
targetinfo: TargetFile,
178178
filepath: Optional[str] = None,
179179
) -> Optional[str]:
180-
"""Check whether a local file is an up to date target
180+
"""Check whether a local file is an up to date target.
181181
182182
Args:
183183
targetinfo: ``TargetFile`` from ``get_targetinfo()``.
@@ -266,7 +266,7 @@ def download_target(
266266
def _download_metadata(
267267
self, rolename: str, length: int, version: Optional[int] = None
268268
) -> bytes:
269-
"""Download a metadata file and return it as bytes"""
269+
"""Download a metadata file and return it as bytes."""
270270
encoded_name = parse.quote(rolename, "")
271271
if version is None:
272272
url = f"{self._metadata_base_url}{encoded_name}.json"
@@ -330,7 +330,7 @@ def _load_root(self) -> None:
330330
break
331331

332332
def _load_timestamp(self) -> None:
333-
"""Load local and remote timestamp metadata"""
333+
"""Load local and remote timestamp metadata."""
334334
try:
335335
data = self._load_local_metadata(Timestamp.type)
336336
self._trusted_set.update_timestamp(data)
@@ -352,7 +352,7 @@ def _load_timestamp(self) -> None:
352352
self._persist_metadata(Timestamp.type, data)
353353

354354
def _load_snapshot(self) -> None:
355-
"""Load local (and if needed remote) snapshot metadata"""
355+
"""Load local (and if needed remote) snapshot metadata."""
356356
try:
357357
data = self._load_local_metadata(Snapshot.type)
358358
self._trusted_set.update_snapshot(data, trusted=True)
@@ -483,5 +483,5 @@ def _preorder_depth_first_walk(
483483

484484

485485
def _ensure_trailing_slash(url: str) -> str:
486-
"""Return url guaranteed to end in a slash"""
486+
"""Return url guaranteed to end in a slash."""
487487
return url if url.endswith("/") else f"{url}/"

0 commit comments

Comments
 (0)