Skip to content

Commit 26e6a95

Browse files
authored
Merge pull request #2592 from jku/even-more-rulesets
lint: Enable more ruff rulesets
2 parents e1f8f73 + 009e1dd commit 26e6a95

6 files changed

Lines changed: 14 additions & 8 deletions

File tree

examples/uploader/_localrepo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def close(self, role: str, md: Metadata) -> None:
8080
md.signed.version += 1
8181
md.signed.expires = datetime.now(timezone.utc) + self.expiry_period
8282

83-
with open(f"{self.key_dir}/{role}", "rt", encoding="utf-8") as f:
83+
with open(f"{self.key_dir}/{role}", encoding="utf-8") as f:
8484
signer = SSlibSigner(json.loads(f.read()))
8585

8686
md.sign(signer, append=False)
@@ -126,7 +126,7 @@ def add_delegation(self, role: str) -> bool:
126126
return False
127127

128128
# Store the private key using rolename as filename
129-
with open(f"{self.key_dir}/{role}", "wt", encoding="utf-8") as f:
129+
with open(f"{self.key_dir}/{role}", "w", encoding="utf-8") as f:
130130
f.write(json.dumps(keydict))
131131

132132
print(f"Uploaded new delegation, stored key in {self.key_dir}/{role}")

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,26 @@ line-length=80
8484
select = [
8585
"A", # flake8-builtins
8686
"B", # flake8-bugbear
87+
"C4", # flake8-comprehensions
8788
"D", # pydocstyle
8889
"DTZ", # flake8-datetimez
8990
"E", # pycodestyle
9091
"F", # pyflakes
9192
"I", # isort
93+
"ISC", # flake8-implicit-str-concat
9294
"N", # pep8-naming
9395
"PL", # pylint
9496
"RET", # flake8-return
9597
"S", # flake8-bandit
9698
"SIM", # flake8-simplify
99+
"UP", # pyupgrade
97100
"W", # pycodestyle-warning
98101
]
99-
ignore = ["D400","D415","D213","D205","D202","D107","D407","D413","D212","D104","D406","D105","D411","D401","D200","D203", "PLR0913", "PLR2004"]
102+
ignore = [
103+
"D400", "D415", "D213", "D205", "D202", "D107", "D407", "D413", "D212", "D104", "D406", "D105", "D411", "D401", "D200", "D203",
104+
"PLR0913", "PLR2004",
105+
"ISC001", # incompatible with ruff formatter
106+
]
100107

101108
[tool.ruff.lint.per-file-ignores]
102109
"tests/*" = [

tests/generated_data/generate_md.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def verify_generation(md: Metadata, path: str) -> None:
6969
if static_md_bytes != md_bytes:
7070
raise ValueError(
7171
f"Generated data != local data at {path}. Generate a new "
72-
+ "metadata with 'python generated_data/generate_md.py'"
72+
"metadata with 'python generated_data/generate_md.py'"
7373
)
7474

7575

tests/test_trusted_metadata_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def test_update_timestamp_with_same_timestamp(self) -> None:
306306

307307
# Update timestamp with the same version.
308308
with self.assertRaises(exceptions.EqualVersionNumberError):
309-
self.trusted_set.update_timestamp((self.metadata[Timestamp.type]))
309+
self.trusted_set.update_timestamp(self.metadata[Timestamp.type])
310310

311311
# Every object has a unique id() if they are equal, this means timestamp
312312
# was not updated.

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def wait_for_server(
113113
succeeded = True
114114
except socket.timeout:
115115
pass
116-
except IOError as e:
116+
except OSError as e:
117117
# ECONNREFUSED is expected while the server is not started
118118
if e.errno not in [errno.ECONNREFUSED]:
119119
logger.warning(

tuf/ngclient/_internal/requests_fetcher.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ def _chunks(self, response: "requests.Response") -> Iterator[bytes]:
106106
"""
107107

108108
try:
109-
for data in response.iter_content(self.chunk_size):
110-
yield data
109+
yield from response.iter_content(self.chunk_size)
111110
except (
112111
requests.exceptions.ConnectionError,
113112
requests.exceptions.Timeout,

0 commit comments

Comments
 (0)