@@ -163,25 +163,26 @@ def street_address(self) -> Optional[str]:
163
163
def street_address (self , street_address : Optional [str ]) -> None :
164
164
self ._street_address = street_address
165
165
166
+ @staticmethod
167
+ def __comparable_tuple (o : 'PostalAddress' ) -> _ComparableTuple :
168
+ return _ComparableTuple ((
169
+ o .bom_ref ,
170
+ o .country , o .region , o .locality , o .post_office_box_number , o .postal_code ,
171
+ o .street_address
172
+ ))
173
+
166
174
def __eq__ (self , other : object ) -> bool :
167
175
if isinstance (other , PostalAddress ):
168
- return hash ( other ) == hash ( self )
176
+ return self . __comparable_tuple ( self ) == self . __comparable_tuple ( other )
169
177
return False
170
178
171
179
def __lt__ (self , other : Any ) -> bool :
172
180
if isinstance (other , PostalAddress ):
173
- return _ComparableTuple ((
174
- self .bom_ref , self .country , self .region , self .locality , self .post_office_box_number , self .postal_code ,
175
- self .street_address
176
- )) < _ComparableTuple ((
177
- other .bom_ref , other .country , other .region , other .locality , other .post_office_box_number ,
178
- other .postal_code , other .street_address
179
- ))
181
+ return self .__comparable_tuple (self ) < self .__comparable_tuple (other )
180
182
return NotImplemented
181
183
182
184
def __hash__ (self ) -> int :
183
- return hash ((self .bom_ref , self .country , self .region , self .locality , self .post_office_box_number ,
184
- self .postal_code , self .street_address ))
185
+ return hash (self .__comparable_tuple (self ))
185
186
186
187
def __repr__ (self ) -> str :
187
188
return f'<PostalAddress bom-ref={ self .bom_ref } , street_address={ self .street_address } , country={ self .country } >'
0 commit comments