@@ -163,25 +163,26 @@ def street_address(self) -> Optional[str]:
163163 def street_address (self , street_address : Optional [str ]) -> None :
164164 self ._street_address = street_address
165165
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+
166174 def __eq__ (self , other : object ) -> bool :
167175 if isinstance (other , PostalAddress ):
168- return hash ( other ) == hash ( self )
176+ return self . __comparable_tuple ( self ) == self . __comparable_tuple ( other )
169177 return False
170178
171179 def __lt__ (self , other : Any ) -> bool :
172180 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 )
180182 return NotImplemented
181183
182184 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 ))
185186
186187 def __repr__ (self ) -> str :
187188 return f'<PostalAddress bom-ref={ self .bom_ref } , street_address={ self .street_address } , country={ self .country } >'
0 commit comments