@@ -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.
0 commit comments