Skip to content

Commit 961e6f5

Browse files
authored
Merge pull request #2845 from theupdateframework/dependabot/pip/test-and-lint-dependencies-04bd18a988
build(deps): bump ruff from 0.11.13 to 0.12.0 in the test-and-lint-dependencies group
2 parents 71de7dd + 88cc984 commit 961e6f5

File tree

5 files changed

+76
-8
lines changed

5 files changed

+76
-8
lines changed

requirements/lint.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Lint tools
77
# (We are not so interested in the specific versions of the tools: the versions
88
# are pinned to prevent unexpected linting failures when tools update)
9-
ruff==0.11.13
9+
ruff==0.12.0
1010
mypy==1.16.1
1111
zizmor==1.9.0
1212

tuf/api/_payload.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ def __eq__(self, other: object) -> bool:
181181
and self.unrecognized_fields == other.unrecognized_fields
182182
)
183183

184+
def __hash__(self) -> int:
185+
return hash(
186+
(
187+
self.type,
188+
self.version,
189+
self.spec_version,
190+
self.expires,
191+
self.unrecognized_fields,
192+
)
193+
)
194+
184195
@abc.abstractmethod
185196
def to_dict(self) -> dict[str, Any]:
186197
"""Serialize and return a dict representation of self."""
@@ -299,6 +310,9 @@ def __eq__(self, other: object) -> bool:
299310
and self.unrecognized_fields == other.unrecognized_fields
300311
)
301312

313+
def __hash__(self) -> int:
314+
return hash((self.keyids, self.threshold, self.unrecognized_fields))
315+
302316
@classmethod
303317
def from_dict(cls, role_dict: dict[str, Any]) -> Role:
304318
"""Create ``Role`` object from its json/dict representation.
@@ -551,6 +565,17 @@ def __eq__(self, other: object) -> bool:
551565
and self.consistent_snapshot == other.consistent_snapshot
552566
)
553567

568+
def __hash__(self) -> int:
569+
return hash(
570+
(
571+
super().__hash__(),
572+
self.keys,
573+
self.roles,
574+
self.consistent_snapshot,
575+
self.unrecognized_fields,
576+
)
577+
)
578+
554579
@classmethod
555580
def from_dict(cls, signed_dict: dict[str, Any]) -> Root:
556581
"""Create ``Root`` object from its json/dict representation.
@@ -826,6 +851,11 @@ def __eq__(self, other: object) -> bool:
826851
and self.unrecognized_fields == other.unrecognized_fields
827852
)
828853

854+
def __hash__(self) -> int:
855+
return hash(
856+
(self.version, self.length, self.hashes, self.unrecognized_fields)
857+
)
858+
829859
@classmethod
830860
def from_dict(cls, meta_dict: dict[str, Any]) -> MetaFile:
831861
"""Create ``MetaFile`` object from its json/dict representation.
@@ -940,6 +970,9 @@ def __eq__(self, other: object) -> bool:
940970
super().__eq__(other) and self.snapshot_meta == other.snapshot_meta
941971
)
942972

973+
def __hash__(self) -> int:
974+
return hash((super().__hash__(), self.snapshot_meta))
975+
943976
@classmethod
944977
def from_dict(cls, signed_dict: dict[str, Any]) -> Timestamp:
945978
"""Create ``Timestamp`` object from its json/dict representation.
@@ -1001,6 +1034,9 @@ def __eq__(self, other: object) -> bool:
10011034

10021035
return super().__eq__(other) and self.meta == other.meta
10031036

1037+
def __hash__(self) -> int:
1038+
return hash((super().__hash__(), self.meta))
1039+
10041040
@classmethod
10051041
def from_dict(cls, signed_dict: dict[str, Any]) -> Snapshot:
10061042
"""Create ``Snapshot`` object from its json/dict representation.
@@ -1098,6 +1134,17 @@ def __eq__(self, other: object) -> bool:
10981134
and self.path_hash_prefixes == other.path_hash_prefixes
10991135
)
11001136

1137+
def __hash__(self) -> int:
1138+
return hash(
1139+
(
1140+
super().__hash__(),
1141+
self.name,
1142+
self.terminating,
1143+
self.path,
1144+
self.path_hash_prefixes,
1145+
)
1146+
)
1147+
11011148
@classmethod
11021149
def from_dict(cls, role_dict: dict[str, Any]) -> DelegatedRole:
11031150
"""Create ``DelegatedRole`` object from its json/dict representation.
@@ -1256,6 +1303,9 @@ def __eq__(self, other: object) -> bool:
12561303
and self.name_prefix == other.name_prefix
12571304
)
12581305

1306+
def __hash__(self) -> int:
1307+
return hash((super().__hash__(), self.bit_length, self.name_prefix))
1308+
12591309
@classmethod
12601310
def from_dict(cls, role_dict: dict[str, Any]) -> SuccinctRoles:
12611311
"""Create ``SuccinctRoles`` object from its json/dict representation.
@@ -1408,6 +1458,16 @@ def __eq__(self, other: object) -> bool:
14081458

14091459
return all_attributes_check
14101460

1461+
def __hash__(self) -> int:
1462+
return hash(
1463+
(
1464+
self.keys,
1465+
self.roles,
1466+
self.succinct_roles,
1467+
self.unrecognized_fields,
1468+
)
1469+
)
1470+
14111471
@classmethod
14121472
def from_dict(cls, delegations_dict: dict[str, Any]) -> Delegations:
14131473
"""Create ``Delegations`` object from its json/dict representation.
@@ -1529,6 +1589,11 @@ def __eq__(self, other: object) -> bool:
15291589
and self.unrecognized_fields == other.unrecognized_fields
15301590
)
15311591

1592+
def __hash__(self) -> int:
1593+
return hash(
1594+
(self.length, self.hashes, self.path, self.unrecognized_fields)
1595+
)
1596+
15321597
@classmethod
15331598
def from_dict(cls, target_dict: dict[str, Any], path: str) -> TargetFile:
15341599
"""Create ``TargetFile`` object from its json/dict representation.
@@ -1672,6 +1737,9 @@ def __eq__(self, other: object) -> bool:
16721737
and self.delegations == other.delegations
16731738
)
16741739

1740+
def __hash__(self) -> int:
1741+
return hash((super().__hash__(), self.targets, self.delegations))
1742+
16751743
@classmethod
16761744
def from_dict(cls, signed_dict: dict[str, Any]) -> Targets:
16771745
"""Create ``Targets`` object from its json/dict representation.

tuf/api/metadata.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,15 @@ def __eq__(self, other: object) -> bool:
147147
and self.unrecognized_fields == other.unrecognized_fields
148148
)
149149

150+
def __hash__(self) -> int:
151+
return hash((self.signatures, self.signed, self.unrecognized_fields))
152+
150153
@property
151154
def signed_bytes(self) -> bytes:
152155
"""Default canonical json byte representation of ``self.signed``."""
153156

154157
# Use local scope import to avoid circular import errors
155-
from tuf.api.serialization.json import CanonicalJSONSerializer
158+
from tuf.api.serialization.json import CanonicalJSONSerializer # noqa: I001, PLC0415
156159

157160
return CanonicalJSONSerializer().serialize(self.signed)
158161

@@ -261,7 +264,7 @@ def from_bytes(
261264

262265
if deserializer is None:
263266
# Use local scope import to avoid circular import errors
264-
from tuf.api.serialization.json import JSONDeserializer
267+
from tuf.api.serialization.json import JSONDeserializer # noqa: I001, PLC0415
265268

266269
deserializer = JSONDeserializer()
267270

@@ -288,7 +291,7 @@ def to_bytes(self, serializer: MetadataSerializer | None = None) -> bytes:
288291

289292
if serializer is None:
290293
# Use local scope import to avoid circular import errors
291-
from tuf.api.serialization.json import JSONSerializer
294+
from tuf.api.serialization.json import JSONSerializer # noqa: I001, PLC0415
292295

293296
serializer = JSONSerializer(compact=True)
294297

tuf/api/serialization/json.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
verification.
99
"""
1010

11-
# We should not have shadowed stdlib json but that milk spilled already
12-
# ruff: noqa: A005
13-
1411
from __future__ import annotations
1512

1613
import json

verify_release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def verify_github_release(version: str, compare_dir: str) -> bool:
108108
"GET", url, preload_content=False, timeout=HTTP_TIMEOUT
109109
)
110110
with open(os.path.join(github_dir, filename), "wb") as f:
111-
for data in response.stream():
111+
for data in response.stream(): # noqa: FURB122
112112
f.write(data)
113113

114114
return cmp(

0 commit comments

Comments
 (0)