python-ort 0.4.3__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {python_ort-0.4.3 → python_ort-0.6.0}/PKG-INFO +2 -2
  2. {python_ort-0.4.3 → python_ort-0.6.0}/pyproject.toml +7 -9
  3. python_ort-0.6.0/src/ort/__init__.py +13 -0
  4. python_ort-0.6.0/src/ort/models/__init__.py +64 -0
  5. python_ort-0.6.0/src/ort/models/advisor_capability.py +21 -0
  6. python_ort-0.6.0/src/ort/models/advisor_details.py +41 -0
  7. python_ort-0.6.0/src/ort/models/advisor_result.py +42 -0
  8. python_ort-0.6.0/src/ort/models/advisor_run.py +39 -0
  9. python_ort-0.6.0/src/ort/models/advisor_summary.py +38 -0
  10. python_ort-0.6.0/src/ort/models/analyzer_result.py +43 -0
  11. python_ort-0.6.0/src/ort/models/analyzer_run.py +37 -0
  12. python_ort-0.6.0/src/ort/models/config/advisor_configuration.py +28 -0
  13. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/analyzer_configuration.py +3 -5
  14. python_ort-0.6.0/src/ort/models/defect.py +87 -0
  15. python_ort-0.6.0/src/ort/models/dependency_graph.py +98 -0
  16. python_ort-0.6.0/src/ort/models/dependency_graph_edge.py +30 -0
  17. python_ort-0.6.0/src/ort/models/dependency_graph_node.py +54 -0
  18. python_ort-0.6.0/src/ort/models/dependency_reference.py +51 -0
  19. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/hash.py +1 -1
  20. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/identifier.py +4 -0
  21. python_ort-0.6.0/src/ort/models/issue.py +36 -0
  22. python_ort-0.6.0/src/ort/models/ort_result.py +44 -0
  23. python_ort-0.6.0/src/ort/models/package.py +131 -0
  24. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/package_curation_data.py +4 -9
  25. python_ort-0.6.0/src/ort/models/package_linkage.py +33 -0
  26. python_ort-0.6.0/src/ort/models/package_reference.py +33 -0
  27. python_ort-0.6.0/src/ort/models/project.py +81 -0
  28. python_ort-0.6.0/src/ort/models/remote_artifact.py +22 -0
  29. python_ort-0.6.0/src/ort/models/repository.py +42 -0
  30. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/repository_configuration.py +1 -1
  31. python_ort-0.6.0/src/ort/models/root_dependency_index.py +27 -0
  32. python_ort-0.6.0/src/ort/models/scope.py +30 -0
  33. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/source_code_origin.py +4 -0
  34. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/vcsinfo.py +6 -2
  35. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/vcstype.py +6 -1
  36. python_ort-0.6.0/src/ort/models/vulnerabilities/__init__.py +8 -0
  37. python_ort-0.6.0/src/ort/models/vulnerabilities/cvss2_rating.py +39 -0
  38. python_ort-0.6.0/src/ort/models/vulnerabilities/cvss3_rating.py +45 -0
  39. python_ort-0.6.0/src/ort/models/vulnerabilities/cvss4_rating.py +45 -0
  40. python_ort-0.6.0/src/ort/models/vulnerabilities/vulnerability.py +39 -0
  41. python_ort-0.6.0/src/ort/models/vulnerabilities/vulnerability_reference.py +78 -0
  42. python_ort-0.6.0/src/ort/severity.py +19 -0
  43. python_ort-0.6.0/src/ort/utils/__init__.py +10 -0
  44. python_ort-0.6.0/src/ort/utils/environment.py +38 -0
  45. python_ort-0.6.0/src/ort/utils/processed_declared_license.py +30 -0
  46. python_ort-0.4.3/src/ort/__init__.py +0 -9
  47. python_ort-0.4.3/src/ort/models/__init__.py +0 -0
  48. python_ort-0.4.3/src/ort/models/ort_configuration.py +0 -322
  49. {python_ort-0.4.3 → python_ort-0.6.0}/LICENSE +0 -0
  50. {python_ort-0.4.3 → python_ort-0.6.0}/README.md +0 -0
  51. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/curations.py +0 -0
  52. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/license_finding_curation.py +0 -0
  53. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/license_finding_curation_reason.py +0 -0
  54. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/package_configuration.py +0 -0
  55. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/package_manager_configuration.py +0 -0
  56. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/path_exclude.py +0 -0
  57. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/path_exclude_reason.py +0 -0
  58. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/path_include_reason.py +0 -0
  59. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/repository_analyzer_configuration.py +0 -0
  60. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/config/vcsmatcher.py +0 -0
  61. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/hash_algorithm.py +0 -0
  62. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/package_curation.py +0 -0
  63. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/resolutions.py +0 -0
  64. {python_ort-0.4.3 → python_ort-0.6.0}/src/ort/models/vcsinfo_curation_data.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-ort
3
- Version: 0.4.3
3
+ Version: 0.6.0
4
4
  Summary: A Python Ort model serialization library
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
14
  Classifier: Programming Language :: Python :: 3.14
15
15
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
- Requires-Dist: pydantic>=2.12.4
16
+ Requires-Dist: pydantic>=2.12.5
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
19
 
@@ -4,14 +4,14 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "python-ort"
7
- version = "0.4.3"
7
+ version = "0.6.0"
8
8
  description = "A Python Ort model serialization library"
9
9
  readme = "README.md"
10
10
  license = "MIT"
11
11
  license-files = ["LICENSE"]
12
12
  requires-python = ">=3.10"
13
13
  dependencies = [
14
- "pydantic>=2.12.4",
14
+ "pydantic>=2.12.5",
15
15
  ]
16
16
  classifiers = [
17
17
  "Development Status :: 3 - Alpha",
@@ -31,13 +31,11 @@ module-root = "src"
31
31
 
32
32
  [dependency-groups]
33
33
  dev = [
34
- "datamodel-code-generator[http]>=0.35.0",
35
- "pre-commit>=4.3.0",
36
- "pycodestyle>=2.14.0",
37
- "pyrefly>=0.40.0",
38
- "pytest>=8.4.2",
39
- "rich>=14.2.0",
40
- "ruff>=0.14.4",
34
+ "datamodel-code-generator[http]>=0.54.0",
35
+ "pytest>=9.0.2",
36
+ "rich>=14.3.2",
37
+ "ruff>=0.15.1",
38
+ "ty>=0.0.17",
41
39
  "types-pyyaml>=6.0.12.20250915",
42
40
  ]
43
41
 
@@ -0,0 +1,13 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ from ort.models.analyzer_result import AnalyzerResult
6
+ from ort.models.ort_result import OrtResult
7
+ from ort.models.repository_configuration import RepositoryConfiguration
8
+
9
+ __all__ = [
10
+ "AnalyzerResult",
11
+ "RepositoryConfiguration",
12
+ "OrtResult",
13
+ ]
@@ -0,0 +1,64 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from .advisor_capability import AdvisorCapability
5
+ from .advisor_result import AdvisorResult
6
+ from .advisor_run import AdvisorRun
7
+ from .analyzer_result import AnalyzerResult
8
+ from .analyzer_run import AnalyzerRun
9
+ from .dependency_graph import DependencyGraph
10
+ from .dependency_graph_edge import DependencyGraphEdge
11
+ from .dependency_graph_node import DependencyGraphNode
12
+ from .dependency_reference import DependencyReference
13
+ from .hash import Hash
14
+ from .hash_algorithm import HashAlgorithm
15
+ from .identifier import Identifier
16
+ from .issue import Issue
17
+ from .ort_result import OrtResult
18
+ from .package import Package
19
+ from .package_curation import PackageCuration
20
+ from .package_curation_data import PackageCurationData
21
+ from .package_linkage import PackageLinkage
22
+ from .package_reference import PackageReference
23
+ from .project import Project
24
+ from .remote_artifact import RemoteArtifact
25
+ from .repository import Repository
26
+ from .repository_configuration import RepositoryConfiguration
27
+ from .root_dependency_index import RootDependencyIndex
28
+ from .scope import Scope
29
+ from .source_code_origin import SourceCodeOrigin
30
+ from .vcsinfo import VcsInfo
31
+ from .vcsinfo_curation_data import VcsInfoCurationData
32
+ from .vcstype import VcsType
33
+
34
+ __all__ = [
35
+ "AdvisorCapability",
36
+ "AdvisorResult",
37
+ "AdvisorRun",
38
+ "AnalyzerResult",
39
+ "AnalyzerRun",
40
+ "DependencyGraph",
41
+ "DependencyGraphEdge",
42
+ "DependencyGraphNode",
43
+ "DependencyReference",
44
+ "Hash",
45
+ "HashAlgorithm",
46
+ "Identifier",
47
+ "Issue",
48
+ "OrtResult",
49
+ "Package",
50
+ "PackageCuration",
51
+ "PackageCurationData",
52
+ "PackageLinkage",
53
+ "PackageReference",
54
+ "Project",
55
+ "RemoteArtifact",
56
+ "Repository",
57
+ "RepositoryConfiguration",
58
+ "RootDependencyIndex",
59
+ "Scope",
60
+ "SourceCodeOrigin",
61
+ "VcsInfo",
62
+ "VcsInfoCurationData",
63
+ "VcsType",
64
+ ]
@@ -0,0 +1,21 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+
5
+ from enum import IntEnum
6
+
7
+
8
+ class AdvisorCapability(IntEnum):
9
+ """
10
+ An enum class that defines the capabilities of a specific advisor implementation.
11
+
12
+ There are multiple types of findings that can be retrieved by an advisor, such as security vulnerabilities or
13
+ defects. An [AdvisorResult] has different fields for the different findings types. This enum corresponds to these
14
+ fields. It allows an advisor implementation to declare, which of these fields it can populate. This information is
15
+ of interest, for instance, when generating reports for specific findings to determine, which advisor may have
16
+ contributed.
17
+
18
+ """
19
+
20
+ DEFECTS = 1
21
+ VULNERABILITIES = 2
@@ -0,0 +1,41 @@
1
+ # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
6
+
7
+ from ort.models import AdvisorCapability
8
+
9
+
10
+ class AdvisorDetails(BaseModel):
11
+ """
12
+ Details about the used provider of vulnerability information.
13
+
14
+ """
15
+
16
+ model_config = ConfigDict(
17
+ extra="forbid",
18
+ )
19
+
20
+ name: str = Field(description="The name of the used advisor.")
21
+ capabilities: set[AdvisorCapability] = Field(
22
+ description="The capabilities of the used advisor. This property indicates, which kind of findings"
23
+ "are retrieved by the advisor."
24
+ )
25
+
26
+ @field_validator("capabilities", mode="before")
27
+ @classmethod
28
+ def convert_capability(cls, v):
29
+ def _convert(item):
30
+ if isinstance(item, str):
31
+ try:
32
+ return AdvisorCapability[item]
33
+ except KeyError:
34
+ raise ValueError(f"Invalid capability: {item}")
35
+ return item
36
+
37
+ if isinstance(v, (list, set)):
38
+ return {_convert(item) for item in v}
39
+ if isinstance(v, str):
40
+ return _convert(v)
41
+ return v
@@ -0,0 +1,42 @@
1
+ # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from pydantic import BaseModel, ConfigDict, Field
5
+
6
+ from ort.models.vulnerabilities import Vulnerability
7
+
8
+ from .advisor_details import AdvisorDetails
9
+ from .advisor_summary import AdvisorSummary
10
+ from .defect import Defect
11
+
12
+
13
+ class AdvisorResult(BaseModel):
14
+ """
15
+ The result of a specific advisor execution for a single package.
16
+
17
+ Different advisor implementations may produce findings of different types. To reflect this, this class has multiple
18
+ fields for findings of these types. It is up to a concrete advisor, which of these fields it populates.
19
+
20
+ """
21
+
22
+ model_config = ConfigDict(
23
+ extra="forbid",
24
+ )
25
+
26
+ advisor: AdvisorDetails = Field(
27
+ description="Details about the used advisor.",
28
+ )
29
+
30
+ summary: AdvisorSummary = Field(
31
+ description="A summary of the advisor results.",
32
+ )
33
+
34
+ defects: list[Defect] = Field(
35
+ default_factory=list,
36
+ description="The defects.",
37
+ )
38
+
39
+ vulnerabilities: list[Vulnerability] = Field(
40
+ default_factory=list,
41
+ description="The vulnerabilities.",
42
+ )
@@ -0,0 +1,39 @@
1
+ # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from datetime import datetime
5
+
6
+ from pydantic import BaseModel, ConfigDict, Field
7
+
8
+ from ort.models import AdvisorResult
9
+ from ort.models.config.advisor_configuration import AdvisorConfiguration
10
+ from ort.utils.environment import Environment
11
+
12
+ from .identifier import Identifier
13
+
14
+
15
+ class AdvisorRun(BaseModel):
16
+ """
17
+ Type alias for a function that allows filtering of [AdvisorResult]s.
18
+
19
+ """
20
+
21
+ model_config = ConfigDict(
22
+ extra="forbid",
23
+ )
24
+ start_time: datetime = Field(
25
+ description="The time the advisor was started.",
26
+ )
27
+ end_time: datetime = Field(
28
+ description="The time the advisor has finished.",
29
+ )
30
+ environment: Environment = Field(
31
+ description="The [Environment] in which the advisor was executed.",
32
+ )
33
+ config: AdvisorConfiguration = Field(
34
+ description="The [AdvisorConfiguration] used for this run.",
35
+ )
36
+ results: dict[Identifier, list[AdvisorResult]] = Field(
37
+ default_factory=dict,
38
+ description="The result of this run.",
39
+ )
@@ -0,0 +1,38 @@
1
+ # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from datetime import datetime
5
+
6
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
7
+
8
+ from .issue import Issue
9
+
10
+
11
+ class AdvisorSummary(BaseModel):
12
+ """
13
+ A short summary of the advisor result.
14
+
15
+ """
16
+
17
+ model_config = ConfigDict(
18
+ extra="forbid",
19
+ )
20
+
21
+ start_time: datetime = Field(
22
+ description="The time the advisor started.",
23
+ )
24
+ end_time: datetime = Field(
25
+ description="The time the advisor finished.",
26
+ )
27
+ issues: list[Issue] = Field(
28
+ default_factory=list,
29
+ description="The list of issues that occurred during the advisor run."
30
+ "This property is not serialized if the list is empty to reduce the size of the result file.",
31
+ )
32
+
33
+ @field_validator("start_time", "end_time", mode="before")
34
+ @classmethod
35
+ def transform_date(cls, v):
36
+ if isinstance(v, str):
37
+ return datetime.fromisoformat(v.replace("Z", "+00:00"))
38
+ return v
@@ -0,0 +1,43 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field
6
+
7
+ from .dependency_graph import DependencyGraph
8
+ from .identifier import Identifier
9
+ from .issue import Issue
10
+ from .package import Package
11
+ from .project import Project
12
+
13
+
14
+ class AnalyzerResult(BaseModel):
15
+ """
16
+ A class that merges all information from individual [ProjectAnalyzerResult]s created for each found definition file.
17
+ """
18
+
19
+ model_config = ConfigDict(
20
+ extra="forbid",
21
+ )
22
+
23
+ projects: set[Project] = Field(
24
+ description="Sorted set of the projects, as they appear in the individual analyzer results.",
25
+ )
26
+
27
+ packages: set[Package] = Field(
28
+ description="The set of identified packages for all projects.",
29
+ )
30
+
31
+ issues: dict[Identifier, list[Issue]] = Field(
32
+ default_factory=dict,
33
+ description="The lists of Issue objects that occurred within the analyzed projects themselves. Issues related"
34
+ "to project dependencies are contained in the dependencies of the project's scopes. This property is not"
35
+ "serialized if the map is empty to reduce the size of the result file.",
36
+ )
37
+
38
+ dependency_graphs: dict[str, DependencyGraph] = Field(
39
+ default_factory=dict,
40
+ description="A map with DependencyGraph objects keyed by the name of the package manager that created this"
41
+ "graph. Package managers supporting this feature can construct a shared DependencyGraph over all projects and"
42
+ "store it in this map.",
43
+ )
@@ -0,0 +1,37 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from datetime import datetime
5
+
6
+ from pydantic import BaseModel, ConfigDict, Field
7
+
8
+ from ort.models import AnalyzerResult
9
+ from ort.models.config.analyzer_configuration import AnalyzerConfiguration
10
+ from ort.utils.environment import Environment
11
+
12
+
13
+ class AnalyzerRun(BaseModel):
14
+ """
15
+ The summary of a single run of the analyzer.
16
+
17
+ """
18
+
19
+ model_config = ConfigDict(
20
+ extra="forbid",
21
+ )
22
+ start_time: datetime = Field(
23
+ description="The time the analyzer was started.",
24
+ )
25
+ end_time: datetime = Field(
26
+ description="The time the analyzer has finished.",
27
+ )
28
+ environment: Environment = Field(
29
+ description="The [Environment] in which the analyzer was executed.",
30
+ )
31
+ config: AnalyzerConfiguration = Field(
32
+ description="The [AnalyzerConfiguration] used for this run.",
33
+ )
34
+ result: AnalyzerResult | None = Field(
35
+ default=None,
36
+ description="The result of this run.",
37
+ )
@@ -0,0 +1,28 @@
1
+ # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+
5
+ from typing import Any
6
+
7
+ from pydantic import BaseModel, ConfigDict, Field
8
+
9
+
10
+ class AdvisorConfiguration(BaseModel):
11
+ """
12
+ The configuration model of the advisor. This class is (de-)serialized in the following places:
13
+ - Deserialized from "config.yml" as part of [OrtConfiguration].
14
+ - (De-)Serialized as part of [org.ossreviewtoolkit.model.OrtResult].
15
+ """
16
+
17
+ model_config = ConfigDict(
18
+ extra="forbid",
19
+ )
20
+ skip_excluded: bool = Field(
21
+ default=False,
22
+ description="A flag to control whether excluded scopes and paths should be skipped when giving the advice.",
23
+ )
24
+ advisors: dict[str, Any] | None = Field(
25
+ default=None,
26
+ description="A map with [configuration][PluginConfig] for advice providers using the"
27
+ "[plugin id][PluginDescriptor.id] as key.",
28
+ )
@@ -38,11 +38,9 @@ _package_managers: list[str] = [
38
38
 
39
39
  class AnalyzerConfiguration(BaseModel):
40
40
  """
41
- Enable the analysis of projects that use version ranges to declare their dependencies. If set to true,
42
- dependencies of exactly the same project might change with another scan done at a later time if any of the
43
- (transitive) dependencies are declared using version ranges and a new version of such a dependency was
44
- published in the meantime. If set to false, analysis of projects that use version ranges will fail. Defaults to
45
- false.
41
+ The configuration model of the analyzer. This class is (de-)serialized in the following places:
42
+ - Deserialized from "config.yml" as part of [OrtConfiguration] (via Hoplite).
43
+ - (De-)Serialized as part of [org.ossreviewtoolkit.model.OrtResult] (via Jackson).
46
44
  """
47
45
 
48
46
  model_config = ConfigDict(
@@ -0,0 +1,87 @@
1
+ # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ from datetime import datetime
5
+
6
+ from pydantic import AnyUrl, BaseModel, ConfigDict, Field
7
+
8
+
9
+ class Defect(BaseModel):
10
+ """
11
+ A data model for software defects.
12
+
13
+ Instances of this class are created by advisor implementations that retrieve information about
14
+ known defects in packages.
15
+
16
+ """
17
+
18
+ model_config = ConfigDict(
19
+ extra="forbid",
20
+ )
21
+
22
+ id: str = Field(
23
+ description="The (external) ID of this defect. This is a string used by a concrete issue tracker"
24
+ "system to reference this defect, such as a bug ID or ticket number.",
25
+ )
26
+
27
+ url: AnyUrl = Field(
28
+ description="The URL pointing to the source of this defect. This is typically a reference into "
29
+ "the issue tracker system that contains this defect.",
30
+ )
31
+ title: str | None = Field(
32
+ default=None,
33
+ description="A title for this defect if available. This is a short summary describing the problem at hand.",
34
+ )
35
+ state: str | None = Field(
36
+ default=None,
37
+ description="A state of the associated defect if available. The concrete meaning of this string depends"
38
+ "on the source from where it was obtained, as different issue tracker systems use their specific "
39
+ "terminology. Possible values could be OPEN, IN PROGRESS, BLOCKED, etc.",
40
+ )
41
+ severity: str | None = Field(
42
+ default=None,
43
+ description="The severity assigned to the defect if available. The meaning of this string depends"
44
+ "on the source system.",
45
+ )
46
+ description: str | None = Field(
47
+ default=None,
48
+ description="An optional description of this defect. It can contain more detailed information about"
49
+ "the defect and its impact. The field may be undefined if the url of this defect already points to"
50
+ "a website with all this information.",
51
+ )
52
+ creation_time: datetime | None = Field(
53
+ default=None,
54
+ description="The creation time of this defect if available.",
55
+ )
56
+ modification_time: datetime | None = Field(
57
+ default=None,
58
+ description="Contains a time when this defect has been modified the last time in the tracker system"
59
+ "it has been obtained from. This information can be useful for instance to find out how up-to-date"
60
+ "this defect report might be.",
61
+ )
62
+ closing_time: datetime | None = Field(
63
+ default=None,
64
+ description="Contains a time when this defect has been closed if it has been resolved already"
65
+ "(and this information is available in the source system). For users of the component affected"
66
+ "by this defect, this information can be of interest to find out whether a fix is available,"
67
+ "maybe in a newer version.",
68
+ )
69
+ fix_release_version: str | None = Field(
70
+ default=None,
71
+ description="Contains the version of the release, in which this defect was fixed if available."
72
+ "This is important information for consumers of the component affected by the defect, so they"
73
+ "can upgrade to this version.",
74
+ )
75
+ fix_release_url: AnyUrl | None = Field(
76
+ default=None,
77
+ description="A URL pointing to the release, in which this defect was fixed if available."
78
+ "Depending on the information provided by a source, this URL could point to a website with detail"
79
+ "information about the release, to release notes, or something like that. This information is"
80
+ "important for consumers of the component affected by this defect, so they can upgrade to this release.",
81
+ )
82
+ labels: dict[str, str] = Field(
83
+ default_factory=dict,
84
+ description="A map with labels assigned to this defect. Labels provide a means frequently used by issue"
85
+ "tracker systems to classify defects based on defined criteria. The exact meaning of these labels is"
86
+ "depending on the source system.",
87
+ )
@@ -0,0 +1,98 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
6
+
7
+ from .dependency_graph_edge import DependencyGraphEdge
8
+ from .dependency_graph_node import DependencyGraphNode
9
+ from .dependency_reference import DependencyReference
10
+ from .identifier import Identifier
11
+ from .root_dependency_index import RootDependencyIndex
12
+
13
+
14
+ class DependencyGraph(BaseModel):
15
+ """
16
+ Represents the graph of dependencies of a project.
17
+
18
+ This class holds information about a project's scopes and their dependencies in a format that minimizes the
19
+ consumption of memory. In projects with many scopes there is often a high degree of duplication in the dependencies
20
+ of the scopes. To avoid this, this class aims to share as many parts of the dependency graph as possible between
21
+ the different scopes. Ideally, there is only a single dependency graph containing the dependencies used by all
22
+ scopes. This is not always possible due to inconsistencies in dependency relations, like a package using different
23
+ dependencies in different scopes. Then the dependency graph is split into multiple fragments, and each fragment has
24
+ a consistent view on the dependencies it contains.
25
+
26
+ When constructing a dependency graph the dependencies are organized as a connected structure of DependencyReference
27
+ objects in memory. Originally, the serialization format of a graph was based on this structure, but that turned out
28
+ to be not ideal: During serialization, sub graphs referenced from multiple nodes (e.g. libraries with transitive
29
+ dependencies referenced from multiple projects) get duplicated, which can cause a significant amount of redundancy.
30
+ Therefore, the data representation has been changed again to a form, which can be serialized without introducing
31
+ redundancy. It consists of the following elements:
32
+
33
+ - packages: A list with the coordinates of all the packages (free of duplication) that are referenced by the graph.
34
+ This allows extracting the packages directly, but also has the advantage that the package coordinates do not have
35
+ to be repeated over and over: All the references to packages are expressed by indices into this list.
36
+ - nodes: An ordered list with the nodes of the dependency graph. A single node represents a package, and therefore
37
+ has a reference into the list with package coordinates. It can, however, happen that packages occur multiple
38
+ times in the graph if they are in different subtrees with different sets of transitive dependencies. Then there
39
+ are multiple nodes for the packages affected, and a fragment_index is used to identify them uniquely. Nodes also
40
+ store information about issues of a package and their linkage.
41
+ - edges: Here the structure of the graph comes in. Each edge connects two nodes and represents a directed
42
+ depends-on relationship. The nodes are referenced by numeric indices into the list of nodes.
43
+ - scopes: This is a map that associates the scopes used by projects with their direct dependencies. A single
44
+ dependency graph contains the dependencies of all the projects processed by a specific package manager.
45
+ Therefore, the keys of this map are scope names qualified by the coordinates of a project; which makes them
46
+ unique. The values are references to the nodes in the graph that correspond to the packages the scopes depend on
47
+ directly.
48
+
49
+ To navigate this structure, start with a scope and gather the references to its direct dependency nodes. Then, by
50
+ following the edges starting from these nodes, the set of transitive dependencies can be determined. The numeric
51
+ indices can be resolved via the packages list.
52
+ """
53
+
54
+ model_config = ConfigDict(
55
+ extra="forbid",
56
+ )
57
+
58
+ packages: list[Identifier] = Field(
59
+ default_factory=list,
60
+ description="A list with the identifiers of the packages that appear in the dependency graph. This list is "
61
+ "used to resolve the numeric indices contained in the dependency_graph_node objects.",
62
+ )
63
+
64
+ scope_roots: set[DependencyReference] = Field(
65
+ default_factory=set,
66
+ description="Stores the dependency graph as a list of root nodes for the direct dependencies referenced by "
67
+ "scopes. Starting with these nodes, the whole graph can be traversed. The nodes are constructed "
68
+ "from the direct dependencies declared by scopes that cannot be reached via other paths in the "
69
+ "dependency graph. Note that this property exists for backwards compatibility only; it is replaced "
70
+ "by the lists of nodes and edges.",
71
+ )
72
+
73
+ scopes: dict[str, list[RootDependencyIndex]] = Field(
74
+ default_factory=dict,
75
+ description="A mapping from scope names to the direct dependencies of the scopes. Based on this information, "
76
+ "the set of scopes of a project can be constructed from the serialized form.",
77
+ )
78
+
79
+ nodes: list[DependencyGraphNode] = Field(
80
+ default_factory=list,
81
+ description="A list with the nodes of this dependency graph. Nodes correspond to packages, but in contrast to "
82
+ "the packages list, there can be multiple nodes for a single package. The order of nodes in this "
83
+ "list is relevant; the edges of the graph reference their nodes by numeric indices.",
84
+ )
85
+
86
+ edges: set[DependencyGraphEdge] = Field(
87
+ default_factory=set,
88
+ description="A set with the edges of this dependency graph. By traversing the edges, the dependencies of "
89
+ "packages can be determined.",
90
+ )
91
+
92
+ @field_validator("edges", mode="before")
93
+ @classmethod
94
+ def sort_and_set_edges(cls, v):
95
+ if v is None:
96
+ return set()
97
+
98
+ return {DependencyGraphEdge.model_validate(e) for e in v}
@@ -0,0 +1,30 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field
6
+
7
+
8
+ class DependencyGraphEdge(BaseModel):
9
+ """
10
+ A data class representing an edge in the dependency graph.
11
+
12
+ An edge corresponds to a directed depends-on relationship between two packages. The packages are identified by the
13
+ numeric indices into the list of nodes.
14
+ """
15
+
16
+ model_config = ConfigDict(
17
+ extra="forbid",
18
+ frozen=True,
19
+ )
20
+
21
+ from_: int = Field(
22
+ ...,
23
+ alias="from",
24
+ description="The index of the source node of this edge.",
25
+ )
26
+ to_: int = Field(
27
+ ...,
28
+ alias="to",
29
+ description="The index of the destination node of this edge.",
30
+ )