@@ -181,6 +181,17 @@ def __eq__(self, other: object) -> bool:
181
181
and self .unrecognized_fields == other .unrecognized_fields
182
182
)
183
183
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
+
184
195
@abc .abstractmethod
185
196
def to_dict (self ) -> dict [str , Any ]:
186
197
"""Serialize and return a dict representation of self."""
@@ -299,6 +310,9 @@ def __eq__(self, other: object) -> bool:
299
310
and self .unrecognized_fields == other .unrecognized_fields
300
311
)
301
312
313
+ def __hash__ (self ) -> int :
314
+ return hash ((self .keyids , self .threshold , self .unrecognized_fields ))
315
+
302
316
@classmethod
303
317
def from_dict (cls , role_dict : dict [str , Any ]) -> Role :
304
318
"""Create ``Role`` object from its json/dict representation.
@@ -551,6 +565,17 @@ def __eq__(self, other: object) -> bool:
551
565
and self .consistent_snapshot == other .consistent_snapshot
552
566
)
553
567
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
+
554
579
@classmethod
555
580
def from_dict (cls , signed_dict : dict [str , Any ]) -> Root :
556
581
"""Create ``Root`` object from its json/dict representation.
@@ -826,6 +851,11 @@ def __eq__(self, other: object) -> bool:
826
851
and self .unrecognized_fields == other .unrecognized_fields
827
852
)
828
853
854
+ def __hash__ (self ) -> int :
855
+ return hash (
856
+ (self .version , self .length , self .hashes , self .unrecognized_fields )
857
+ )
858
+
829
859
@classmethod
830
860
def from_dict (cls , meta_dict : dict [str , Any ]) -> MetaFile :
831
861
"""Create ``MetaFile`` object from its json/dict representation.
@@ -940,6 +970,9 @@ def __eq__(self, other: object) -> bool:
940
970
super ().__eq__ (other ) and self .snapshot_meta == other .snapshot_meta
941
971
)
942
972
973
+ def __hash__ (self ) -> int :
974
+ return hash ((super ().__hash__ (), self .snapshot_meta ))
975
+
943
976
@classmethod
944
977
def from_dict (cls , signed_dict : dict [str , Any ]) -> Timestamp :
945
978
"""Create ``Timestamp`` object from its json/dict representation.
@@ -1001,6 +1034,9 @@ def __eq__(self, other: object) -> bool:
1001
1034
1002
1035
return super ().__eq__ (other ) and self .meta == other .meta
1003
1036
1037
+ def __hash__ (self ) -> int :
1038
+ return hash ((super ().__hash__ (), self .meta ))
1039
+
1004
1040
@classmethod
1005
1041
def from_dict (cls , signed_dict : dict [str , Any ]) -> Snapshot :
1006
1042
"""Create ``Snapshot`` object from its json/dict representation.
@@ -1098,6 +1134,17 @@ def __eq__(self, other: object) -> bool:
1098
1134
and self .path_hash_prefixes == other .path_hash_prefixes
1099
1135
)
1100
1136
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
+
1101
1148
@classmethod
1102
1149
def from_dict (cls , role_dict : dict [str , Any ]) -> DelegatedRole :
1103
1150
"""Create ``DelegatedRole`` object from its json/dict representation.
@@ -1256,6 +1303,9 @@ def __eq__(self, other: object) -> bool:
1256
1303
and self .name_prefix == other .name_prefix
1257
1304
)
1258
1305
1306
+ def __hash__ (self ) -> int :
1307
+ return hash ((super ().__hash__ (), self .bit_length , self .name_prefix ))
1308
+
1259
1309
@classmethod
1260
1310
def from_dict (cls , role_dict : dict [str , Any ]) -> SuccinctRoles :
1261
1311
"""Create ``SuccinctRoles`` object from its json/dict representation.
@@ -1408,6 +1458,16 @@ def __eq__(self, other: object) -> bool:
1408
1458
1409
1459
return all_attributes_check
1410
1460
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
+
1411
1471
@classmethod
1412
1472
def from_dict (cls , delegations_dict : dict [str , Any ]) -> Delegations :
1413
1473
"""Create ``Delegations`` object from its json/dict representation.
@@ -1529,6 +1589,11 @@ def __eq__(self, other: object) -> bool:
1529
1589
and self .unrecognized_fields == other .unrecognized_fields
1530
1590
)
1531
1591
1592
+ def __hash__ (self ) -> int :
1593
+ return hash (
1594
+ (self .length , self .hashes , self .path , self .unrecognized_fields )
1595
+ )
1596
+
1532
1597
@classmethod
1533
1598
def from_dict (cls , target_dict : dict [str , Any ], path : str ) -> TargetFile :
1534
1599
"""Create ``TargetFile`` object from its json/dict representation.
@@ -1672,6 +1737,9 @@ def __eq__(self, other: object) -> bool:
1672
1737
and self .delegations == other .delegations
1673
1738
)
1674
1739
1740
+ def __hash__ (self ) -> int :
1741
+ return hash ((super ().__hash__ (), self .targets , self .delegations ))
1742
+
1675
1743
@classmethod
1676
1744
def from_dict (cls , signed_dict : dict [str , Any ]) -> Targets :
1677
1745
"""Create ``Targets`` object from its json/dict representation.
0 commit comments