Skip to content

Commit 712918e

Browse files
committed
wip
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 83aa0c2 commit 712918e

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Diff for: cyclonedx/model/component.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@ def get_pypi_url(self) -> str:
17441744
@staticmethod
17451745
def __comparable_tuple(o: 'Component') -> _ComparableTuple:
17461746
return _ComparableTuple((
1747-
o._bom_ref, # see https://github.com/CycloneDX/cyclonedx-python-lib/issues/753
1747+
o.bom_ref, # see https://github.com/CycloneDX/cyclonedx-python-lib/issues/753
17481748
o.type, o.group, o.name, o.version,
17491749
o.mime_type, o.supplier, o.author, o.publisher,
17501750
o.description, o.scope, _ComparableTuple(o.hashes),

Diff for: cyclonedx/model/contact.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)