Skip to content

Commit 6c5157f

Browse files
committed
fix(model): Add defaults and hash calculation for PackageReference
Signed-off-by: Helio Chissini de Castro <helio.chissini.de.castro@cariad.technology>
1 parent 74b6e22 commit 6c5157f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/ort/models/package_reference.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,19 @@ class PackageReference(BaseModel):
2525
"also use that as the default value here to not blow up ORT result files.",
2626
)
2727
dependencies: set["PackageReference"] = Field(
28+
default_factory=set,
2829
description="The set of references to packages this package depends on. Note that this list depends on the "
2930
"scope in which this package is referenced.",
3031
)
3132
issues: list[Issue] = Field(
33+
default_factory=list,
3234
description="A list of issues that occurred handling this PackageReference.",
3335
)
36+
37+
def __hash__(self) -> int:
38+
return hash(self.id)
39+
40+
def __eq__(self, other) -> bool:
41+
if not isinstance(other, PackageReference):
42+
return NotImplemented
43+
return self.id == other.id

0 commit comments

Comments
 (0)