Skip to content

Commit

Permalink
Merge pull request #2592 from jku/even-more-rulesets
Browse files Browse the repository at this point in the history
lint: Enable more ruff rulesets
  • Loading branch information
jku committed Apr 2, 2024
2 parents e1f8f73 + 009e1dd commit 26e6a95
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/uploader/_localrepo.py
Expand Up @@ -80,7 +80,7 @@ def close(self, role: str, md: Metadata) -> None:
md.signed.version += 1
md.signed.expires = datetime.now(timezone.utc) + self.expiry_period

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

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

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

print(f"Uploaded new delegation, stored key in {self.key_dir}/{role}")
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Expand Up @@ -84,19 +84,26 @@ line-length=80
select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"D", # pydocstyle
"DTZ", # flake8-datetimez
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PL", # pylint
"RET", # flake8-return
"S", # flake8-bandit
"SIM", # flake8-simplify
"UP", # pyupgrade
"W", # pycodestyle-warning
]
ignore = ["D400","D415","D213","D205","D202","D107","D407","D413","D212","D104","D406","D105","D411","D401","D200","D203", "PLR0913", "PLR2004"]
ignore = [
"D400", "D415", "D213", "D205", "D202", "D107", "D407", "D413", "D212", "D104", "D406", "D105", "D411", "D401", "D200", "D203",
"PLR0913", "PLR2004",
"ISC001", # incompatible with ruff formatter
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = [
Expand Down
2 changes: 1 addition & 1 deletion tests/generated_data/generate_md.py
Expand Up @@ -69,7 +69,7 @@ def verify_generation(md: Metadata, path: str) -> None:
if static_md_bytes != md_bytes:
raise ValueError(
f"Generated data != local data at {path}. Generate a new "
+ "metadata with 'python generated_data/generate_md.py'"
"metadata with 'python generated_data/generate_md.py'"
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_trusted_metadata_set.py
Expand Up @@ -306,7 +306,7 @@ def test_update_timestamp_with_same_timestamp(self) -> None:

# Update timestamp with the same version.
with self.assertRaises(exceptions.EqualVersionNumberError):
self.trusted_set.update_timestamp((self.metadata[Timestamp.type]))
self.trusted_set.update_timestamp(self.metadata[Timestamp.type])

# Every object has a unique id() if they are equal, this means timestamp
# was not updated.
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Expand Up @@ -113,7 +113,7 @@ def wait_for_server(
succeeded = True
except socket.timeout:
pass
except IOError as e:
except OSError as e:
# ECONNREFUSED is expected while the server is not started
if e.errno not in [errno.ECONNREFUSED]:
logger.warning(
Expand Down
3 changes: 1 addition & 2 deletions tuf/ngclient/_internal/requests_fetcher.py
Expand Up @@ -106,8 +106,7 @@ def _chunks(self, response: "requests.Response") -> Iterator[bytes]:
"""

try:
for data in response.iter_content(self.chunk_size):
yield data
yield from response.iter_content(self.chunk_size)
except (
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
Expand Down

0 comments on commit 26e6a95

Please sign in to comment.