@@ -133,22 +133,23 @@ def classification(self) -> str:
133
133
def classification (self , classification : str ) -> None :
134
134
self ._classification = classification
135
135
136
+ def __comparable_tuple (self ) -> _ComparableTuple :
137
+ return _ComparableTuple ((
138
+ self .flow , self .classification
139
+ ))
140
+
136
141
def __eq__ (self , other : object ) -> bool :
137
142
if isinstance (other , DataClassification ):
138
- return hash ( other ) == hash ( self )
143
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
139
144
return False
140
145
141
146
def __lt__ (self , other : object ) -> bool :
142
147
if isinstance (other , DataClassification ):
143
- return _ComparableTuple ((
144
- self .flow , self .classification
145
- )) < _ComparableTuple ((
146
- other .flow , other .classification
147
- ))
148
+ return self .__comparable_tuple () < other .__comparable_tuple ()
148
149
return NotImplemented
149
150
150
151
def __hash__ (self ) -> int :
151
- return hash (( self .flow , self . classification ))
152
+ return hash (self .__comparable_tuple ( ))
152
153
153
154
def __repr__ (self ) -> str :
154
155
return f'<DataClassification flow={ self .flow } >'
@@ -236,22 +237,23 @@ def content(self) -> str:
236
237
def content (self , content : str ) -> None :
237
238
self ._content = content
238
239
240
+ def __comparable_tuple (self ) -> _ComparableTuple :
241
+ return _ComparableTuple ((
242
+ self .content_type , self .encoding , self .content ,
243
+ ))
244
+
239
245
def __eq__ (self , other : object ) -> bool :
240
246
if isinstance (other , AttachedText ):
241
- return hash ( other ) == hash ( self )
247
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
242
248
return False
243
249
244
250
def __lt__ (self , other : Any ) -> bool :
245
251
if isinstance (other , AttachedText ):
246
- return _ComparableTuple ((
247
- self .content_type , self .content , self .encoding
248
- )) < _ComparableTuple ((
249
- other .content_type , other .content , other .encoding
250
- ))
252
+ return self .__comparable_tuple () < other .__comparable_tuple ()
251
253
return NotImplemented
252
254
253
255
def __hash__ (self ) -> int :
254
- return hash (( self .content , self . content_type , self . encoding ))
256
+ return hash (self .__comparable_tuple ( ))
255
257
256
258
def __repr__ (self ) -> str :
257
259
return f'<AttachedText content-type={ self .content_type } , encoding={ self .encoding } >'
@@ -515,22 +517,23 @@ def content(self) -> str:
515
517
def content (self , content : str ) -> None :
516
518
self ._content = content
517
519
520
+ def __comparable_tuple (self ) -> _ComparableTuple :
521
+ return _ComparableTuple ((
522
+ self .alg , self .content
523
+ ))
524
+
518
525
def __eq__ (self , other : object ) -> bool :
519
526
if isinstance (other , HashType ):
520
- return hash ( other ) == hash ( self )
527
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
521
528
return False
522
529
523
530
def __lt__ (self , other : Any ) -> bool :
524
531
if isinstance (other , HashType ):
525
- return _ComparableTuple ((
526
- self .alg , self .content
527
- )) < _ComparableTuple ((
528
- other .alg , other .content
529
- ))
532
+ return self .__comparable_tuple () < other .__comparable_tuple ()
530
533
return NotImplemented
531
534
532
535
def __hash__ (self ) -> int :
533
- return hash (( self .alg , self . content ))
536
+ return hash (self .__comparable_tuple ( ))
534
537
535
538
def __repr__ (self ) -> str :
536
539
return f'<HashType { self .alg .name } :{ self .content } >'
@@ -733,7 +736,7 @@ def __init__(self, uri: str) -> None:
733
736
734
737
def __eq__ (self , other : Any ) -> bool :
735
738
if isinstance (other , XsUri ):
736
- return hash ( other ) == hash ( self )
739
+ return self . _uri == other . _uri
737
740
return False
738
741
739
742
def __lt__ (self , other : Any ) -> bool :
@@ -892,25 +895,24 @@ def hashes(self) -> 'SortedSet[HashType]':
892
895
def hashes (self , hashes : Iterable [HashType ]) -> None :
893
896
self ._hashes = SortedSet (hashes )
894
897
898
+ def __comparable_tuple (self ) -> _ComparableTuple :
899
+ return _ComparableTuple ((
900
+ self ._type , self ._url , self ._comment ,
901
+ _ComparableTuple (self ._hashes )
902
+ ))
903
+
895
904
def __eq__ (self , other : object ) -> bool :
896
905
if isinstance (other , ExternalReference ):
897
- return hash ( other ) == hash ( self )
906
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
898
907
return False
899
908
900
909
def __lt__ (self , other : Any ) -> bool :
901
910
if isinstance (other , ExternalReference ):
902
- return _ComparableTuple ((
903
- self ._type , self ._url , self ._comment
904
- )) < _ComparableTuple ((
905
- other ._type , other ._url , other ._comment
906
- ))
911
+ return self .__comparable_tuple () < other .__comparable_tuple ()
907
912
return NotImplemented
908
913
909
914
def __hash__ (self ) -> int :
910
- return hash ((
911
- self ._type , self ._url , self ._comment ,
912
- tuple (sorted (self ._hashes , key = hash ))
913
- ))
915
+ return hash (self .__comparable_tuple ())
914
916
915
917
def __repr__ (self ) -> str :
916
918
return f'<ExternalReference { self .type .name } , { self .url } >'
@@ -969,22 +971,23 @@ def value(self) -> Optional[str]:
969
971
def value (self , value : Optional [str ]) -> None :
970
972
self ._value = value
971
973
974
+ def __comparable_tuple (self ) -> _ComparableTuple :
975
+ return _ComparableTuple ((
976
+ self .name , self .value
977
+ ))
978
+
972
979
def __eq__ (self , other : object ) -> bool :
973
980
if isinstance (other , Property ):
974
- return hash ( other ) == hash ( self )
981
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
975
982
return False
976
983
977
984
def __lt__ (self , other : Any ) -> bool :
978
985
if isinstance (other , Property ):
979
- return _ComparableTuple ((
980
- self .name , self .value
981
- )) < _ComparableTuple ((
982
- other .name , other .value
983
- ))
986
+ return self .__comparable_tuple () < other .__comparable_tuple ()
984
987
return NotImplemented
985
988
986
989
def __hash__ (self ) -> int :
987
- return hash (( self .name , self . value ))
990
+ return hash (self .__comparable_tuple ( ))
988
991
989
992
def __repr__ (self ) -> str :
990
993
return f'<Property name={ self .name } >'
@@ -1060,22 +1063,23 @@ def encoding(self) -> Optional[Encoding]:
1060
1063
def encoding (self , encoding : Optional [Encoding ]) -> None :
1061
1064
self ._encoding = encoding
1062
1065
1066
+ def __comparable_tuple (self ) -> _ComparableTuple :
1067
+ return _ComparableTuple ((
1068
+ self .content , self .content_type , self .encoding
1069
+ ))
1070
+
1063
1071
def __eq__ (self , other : object ) -> bool :
1064
1072
if isinstance (other , NoteText ):
1065
- return hash ( other ) == hash ( self )
1073
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
1066
1074
return False
1067
1075
1068
1076
def __lt__ (self , other : Any ) -> bool :
1069
1077
if isinstance (other , NoteText ):
1070
- return _ComparableTuple ((
1071
- self .content , self .content_type , self .encoding
1072
- )) < _ComparableTuple ((
1073
- other .content , other .content_type , other .encoding
1074
- ))
1078
+ return self .__comparable_tuple () < other .__comparable_tuple ()
1075
1079
return NotImplemented
1076
1080
1077
1081
def __hash__ (self ) -> int :
1078
- return hash (( self .content , self . content_type , self . encoding ))
1082
+ return hash (self .__comparable_tuple ( ))
1079
1083
1080
1084
def __repr__ (self ) -> str :
1081
1085
return f'<NoteText content_type={ self .content_type } , encoding={ self .encoding } >'
@@ -1144,22 +1148,23 @@ def locale(self, locale: Optional[str]) -> None:
1144
1148
" ISO-3166 (or higher) country code. according to ISO-639 format. Examples include: 'en', 'en-US'."
1145
1149
)
1146
1150
1151
+ def __comparable_tuple (self ) -> _ComparableTuple :
1152
+ return _ComparableTuple ((
1153
+ self .locale , self .text
1154
+ ))
1155
+
1147
1156
def __eq__ (self , other : object ) -> bool :
1148
1157
if isinstance (other , Note ):
1149
- return hash ( other ) == hash ( self )
1158
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
1150
1159
return False
1151
1160
1152
1161
def __lt__ (self , other : Any ) -> bool :
1153
1162
if isinstance (other , Note ):
1154
- return _ComparableTuple ((
1155
- self .locale , self .text
1156
- )) < _ComparableTuple ((
1157
- other .locale , other .text
1158
- ))
1163
+ return self .__comparable_tuple () < other .__comparable_tuple ()
1159
1164
return NotImplemented
1160
1165
1161
1166
def __hash__ (self ) -> int :
1162
- return hash (( self .text , self . locale ))
1167
+ return hash (self .__comparable_tuple ( ))
1163
1168
1164
1169
def __repr__ (self ) -> str :
1165
1170
return f'<Note id={ id (self )} , locale={ self .locale } >'
@@ -1234,22 +1239,23 @@ def email(self) -> Optional[str]:
1234
1239
def email (self , email : Optional [str ]) -> None :
1235
1240
self ._email = email
1236
1241
1242
+ def __comparable_tuple (self ) -> _ComparableTuple :
1243
+ return _ComparableTuple ((
1244
+ self .timestamp , self .name , self .email
1245
+ ))
1246
+
1237
1247
def __eq__ (self , other : object ) -> bool :
1238
1248
if isinstance (other , IdentifiableAction ):
1239
- return hash ( other ) == hash ( self )
1249
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
1240
1250
return False
1241
1251
1242
1252
def __lt__ (self , other : Any ) -> bool :
1243
1253
if isinstance (other , IdentifiableAction ):
1244
- return _ComparableTuple ((
1245
- self .timestamp , self .name , self .email
1246
- )) < _ComparableTuple ((
1247
- other .timestamp , other .name , other .email
1248
- ))
1254
+ return self .__comparable_tuple () < other .__comparable_tuple ()
1249
1255
return NotImplemented
1250
1256
1251
1257
def __hash__ (self ) -> int :
1252
- return hash (( self .timestamp , self . name , self . email ))
1258
+ return hash (self .__comparable_tuple ( ))
1253
1259
1254
1260
def __repr__ (self ) -> str :
1255
1261
return f'<IdentifiableAction name={ self .name } , email={ self .email } >'
@@ -1287,16 +1293,16 @@ def text(self, text: str) -> None:
1287
1293
1288
1294
def __eq__ (self , other : object ) -> bool :
1289
1295
if isinstance (other , Copyright ):
1290
- return hash ( other ) == hash ( self )
1296
+ return self . _text == other . _text
1291
1297
return False
1292
1298
1293
1299
def __lt__ (self , other : Any ) -> bool :
1294
1300
if isinstance (other , Copyright ):
1295
- return self .text < other .text
1301
+ return self ._text < other ._text
1296
1302
return NotImplemented
1297
1303
1298
1304
def __hash__ (self ) -> int :
1299
- return hash (self .text )
1305
+ return hash (self ._text )
1300
1306
1301
1307
def __repr__ (self ) -> str :
1302
1308
return f'<Copyright text={ self .text } >'
0 commit comments