Skip to content

Commit 2208015

Browse files
author
Lukas Pühringer
authored
Merge pull request #2582 from jku/more-flake-linters
Enable more linters (flake8-bugbear and flake8-datetimez)
2 parents d86f8ad + d95cff9 commit 2208015

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

pyproject.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ line-length=80
8282

8383
[tool.ruff.lint]
8484
select = [
85-
"D", # pydocstyle
86-
"E", # pycodestyle
87-
"F", # pyflakes
88-
"I", # isort
89-
"N", # pep8-naming
90-
"PL", # pylint
91-
"S", # flake8-bandit
85+
"B", # flake8-bugbear
86+
"D", # pydocstyle
87+
"DTZ", # flake8-datetimez
88+
"E", # pycodestyle
89+
"F", # pyflakes
90+
"I", # isort
91+
"N", # pep8-naming
92+
"PL", # pylint
93+
"S", # flake8-bandit
9294
]
9395
ignore = ["D400","D415","D213","D205","D202","D107","D407","D413","D212","D104","D406","D105","D411","D401","D200","D203", "PLR0913", "PLR2004"]
9496

tuf/api/_payload.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ def _common_fields_from_dict(
181181
# Convert 'expires' TUF metadata string to a datetime object, which is
182182
# what the constructor expects and what we store. The inverse operation
183183
# is implemented in '_common_fields_to_dict'.
184-
expires = datetime.strptime(expires_str, "%Y-%m-%dT%H:%M:%SZ")
185-
expires = expires.replace(tzinfo=timezone.utc)
184+
expires = datetime.strptime(expires_str, "%Y-%m-%dT%H:%M:%SZ").replace(
185+
tzinfo=timezone.utc
186+
)
186187

187188
return version, spec_version, expires
188189

tuf/ngclient/_internal/requests_fetcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _fetch(self, url: str) -> Iterator[bytes]:
9494
except requests.HTTPError as e:
9595
response.close()
9696
status = e.response.status_code
97-
raise exceptions.DownloadHTTPError(str(e), status)
97+
raise exceptions.DownloadHTTPError(str(e), status) from e
9898

9999
return self._chunks(response)
100100

tuf/ngclient/updater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def _load_targets(self, role: str, parent_role: str) -> Targets:
397397
if metainfo is None:
398398
raise exceptions.RepositoryError(
399399
f"Role {role} was delegated but is not part of snapshot"
400-
)
400+
) from None
401401

402402
length = metainfo.length or self.config.targets_max_length
403403
version = None

0 commit comments

Comments
 (0)