Skip to content

Commit 043bfa0

Browse files
committed
fix(snippets): Fix license parsing code as non hasheable
Signed-off-by: Helio Chissini de Castro <helio.chissini.de.castro@cariad.technology>
1 parent 13537a2 commit 043bfa0

6 files changed

Lines changed: 19 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "uv_build"
44

55
[project]
66
name = "python-ort"
7-
version = "0.8.12"
7+
version = "0.8.13"
88
description = "A Python Ort model serialization library"
99
readme = "README.md"
1010
license = "MIT"

src/ort/models/copyright_finding.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ class CopyrightFinding(BaseModel):
2121
location: TextLocation = Field(
2222
description="The text location where the copyright statement was found.",
2323
)
24+
25+
def __hash__(self) -> int:
26+
return hash(self.statement)
27+
28+
def __eq__(self, other) -> bool:
29+
if not isinstance(other, CopyrightFinding):
30+
return NotImplemented
31+
return self.statement == other.statement

src/ort/models/license_finding.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ def validate_spdx(cls, value):
4343
return value
4444
except ExpressionError as e:
4545
raise ValueError(str(e)) from e
46+
47+
def __hash__(self) -> int:
48+
return hash(self.license)
49+
50+
def __eq__(self, other) -> bool:
51+
if not isinstance(other, LicenseFinding):
52+
return NotImplemented
53+
return self.license == other.license

src/ort/models/text_location.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class TextLocation(BaseModel):
3131
def validate_line_numbers(cls, value):
3232
if isinstance(value, str):
3333
value = int(value)
34-
if value < 0:
35-
raise ValueError("Line numbers must be greater than or equal to 0.")
3634
return value
3735

3836
def __hash__(self) -> int:

tests/data/advisor/advisor_result_defects.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ summary:
99
message: "Timeout while querying OSV API."
1010
severity: 2
1111
vulnerabilities: []
12+
volumes:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)