-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(repoconfig): Get rid of legacy classes #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
|
|
||
| from pydantic import BaseModel, ConfigDict, Field | ||
|
|
||
| from .path_exclude import PathExclude | ||
| from .scope_exclude import ScopeExclude | ||
|
|
||
|
|
||
| class Excludes(BaseModel): | ||
| """ | ||
| Defines which parts of a repository should be excluded. | ||
| """ | ||
|
|
||
| model_config = ConfigDict( | ||
| extra="forbid", | ||
| ) | ||
|
|
||
| paths: list[PathExclude] = Field( | ||
| default_factory=list, | ||
| description="Path excludes.", | ||
| ) | ||
|
|
||
| scopes: list[ScopeExclude] = Field( | ||
| default_factory=list, | ||
| description="Scopes that will be excluded from all projects.", | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
|
|
||
| from pydantic import BaseModel, ConfigDict, Field | ||
|
|
||
| from .path_include import PathInclude | ||
|
|
||
|
|
||
| class Includes(BaseModel): | ||
| """ | ||
| Defines which parts of a repository should be excluded. | ||
| """ | ||
|
|
||
| model_config = ConfigDict( | ||
| extra="forbid", | ||
| ) | ||
|
|
||
| paths: list[PathInclude] = Field( | ||
| default_factory=list, | ||
| description="Path includes.", | ||
| ) | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||||||
| # SPDX-License-Identifier: MIT | ||||||
|
|
||||||
|
|
||||||
| from pydantic import BaseModel, ConfigDict, Field | ||||||
|
|
||||||
| from .issue_resolution_reason import IssueResolutionReason | ||||||
|
|
||||||
|
|
||||||
| class IssueResolution(BaseModel): | ||||||
| """ | ||||||
| Defines the resolution of an [Issue]. This can be used to silence false positives, or issues that have been | ||||||
| identified as not being relevant. | ||||||
| """ | ||||||
|
|
||||||
| model_config = ConfigDict( | ||||||
| extra="forbid", | ||||||
| ) | ||||||
|
|
||||||
| message: str = Field( | ||||||
| description="A regular expression string to match the messages of issues to resolve. Whitespace in the message" | ||||||
|
||||||
| description="A regular expression string to match the messages of issues to resolve. Whitespace in the message" | |
| description="A regular expression string to match the messages of issues to resolve. Whitespace in the message " |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IssueResolution class has an enum field 'reason' of type IssueResolutionReason but doesn't have a field_validator to convert string values to enum values. This is inconsistent with similar classes in the codebase like PathExclude, PathInclude, ScopeExclude, and RuleViolationResolution which all use the convert_enum utility with a field_validator. Consider adding a validator for consistency and to properly handle string-to-enum conversion.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| from enum import IntEnum | ||
|
|
||
|
|
||
| class IssueResolutionReason(IntEnum): | ||
| """ | ||
| Possible reasons for resolving an Issue using an IssueResolution. | ||
|
|
||
| properties: | ||
| BUILD_TOOL_ISSUE: | ||
| The issue originates from the build tool used by the project. | ||
| CANT_FIX_ISSUE: | ||
| The issue can not be fixed. | ||
| For example, it requires a change to be made by a third party that is not responsive. | ||
| SCANNER_ISSUE: | ||
| The issue is due to an irrelevant scanner issue. | ||
| For example, a time out on a large file that is not distributed. | ||
| """ | ||
|
|
||
| BUILD_TOOL_ISSUE = 1 | ||
| CANT_FIX_ISSUE = 2 | ||
| SCANNER_ISSUE = 3 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||||||
|
||||||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | |
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring has a missing opening bracket. It says "SpdxLicenseChoice]s defined" but should say "[SpdxLicenseChoice]s defined" to be consistent with the documentation style used elsewhere.
| SpdxLicenseChoice]s defined for an artifact. | |
| [SpdxLicenseChoice]s defined for an artifact. |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description is incomplete and unhelpful. It just says "SPDX" but should provide a meaningful description of what this field represents, such as "SPDX license choices applied to all packages in the repository."
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description is incomplete and unhelpful. It just says "Package" but should provide a meaningful description of what this field represents, such as "Package-specific license choices."
| description="Package", | |
| description="Package-specific SPDX license choices for individual packages.", |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,73 +1,47 @@ | ||
| # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| from enum import Enum, auto | ||
| from enum import IntEnum | ||
|
|
||
|
|
||
| class PathExcludeReason(Enum): | ||
| class PathExcludeReason(IntEnum): | ||
| """ | ||
| Possible reasons for excluding a path. | ||
| Attributes | ||
|
|
||
| Attributes: | ||
| BUILD_TOOL_OF | ||
| The path only contains tools used for building source code which are not included in | ||
| distributed build artifacts. | ||
|
|
||
| DATA_FILE_OF | ||
| The path only contains data files such as fonts or images which are not included in | ||
| distributed build artifacts. | ||
|
|
||
| DOCUMENTATION_OF | ||
| The path only contains documentation which is not included in distributed build artifacts. | ||
|
|
||
| EXAMPLE_OF | ||
| The path only contains source code examples which are not included in distributed build | ||
| artifacts. | ||
|
|
||
| OPTIONAL_COMPONENT_OF | ||
| The path only contains optional components for the code that is built which are not included | ||
| in distributed build artifacts. | ||
|
|
||
| OTHER | ||
| Any other reason which cannot be represented by any other element of PathExcludeReason. | ||
|
|
||
| PROVIDED_BY | ||
| The path only contains packages or sources for packages that have to be provided by the user | ||
| of distributed build artifacts. | ||
|
|
||
| TEST_OF | ||
| The path only contains files used for testing source code which are not included in | ||
| distributed build artifacts. | ||
|
|
||
| TEST_TOOL_OF | ||
| The path only contains tools used for testing source code which are not included in | ||
| distributed build artifacts. | ||
| """ | ||
|
|
||
| # The path only contains tools used for building source code which are not included in distributed build artifacts. | ||
| BUILD_TOOL_OF = auto() | ||
|
|
||
| # The path only contains data files such as fonts or images which are not included in distributed build artifacts. | ||
| DATA_FILE_OF = auto() | ||
|
|
||
| # The path only contains documentation which is not included in distributed build artifacts. | ||
| DOCUMENTATION_OF = auto() | ||
|
|
||
| # The path only contains source code examples which are not included in distributed build artifacts. | ||
| EXAMPLE_OF = auto() | ||
|
|
||
| # The path only contains optional components for the code that is built which are not included | ||
| # in distributed build artifacts. | ||
| OPTIONAL_COMPONENT_OF = auto() | ||
|
|
||
| # Any other reason which cannot be represented by any other element of PathExcludeReason. | ||
| OTHER = auto() | ||
|
|
||
| # The path only contains packages or sources for packages that have to be provided by the user | ||
| # of distributed build artifacts. | ||
| PROVIDED_BY = auto() | ||
|
|
||
| # The path only contains files used for testing source code which are not included in distributed build artifacts. | ||
| TEST_OF = auto() | ||
|
|
||
| # The path only contains tools used for testing source code which are not included in distributed build artifacts. | ||
| TEST_TOOL_OF = auto() | ||
| BUILD_TOOL_OF = 1 | ||
| DATA_FILE_OF = 2 | ||
| DOCUMENTATION_OF = 3 | ||
| EXAMPLE_OF = 4 | ||
| OPTIONAL_COMPONENT_OF = 5 | ||
| OTHER = 6 | ||
| PROVIDED_BY = 7 | ||
| TEST_OF = 8 | ||
| TEST_TOOL_OF = 9 |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||||||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||||||||||
| # SPDX-License-Identifier: MIT | ||||||||||
|
|
||||||||||
|
|
||||||||||
| from pydantic import BaseModel, ConfigDict, Field, field_validator | ||||||||||
|
|
||||||||||
| from ort.utils import convert_enum | ||||||||||
|
|
||||||||||
| from .path_include_reason import PathIncludeReason | ||||||||||
|
|
||||||||||
|
|
||||||||||
| class PathInclude(BaseModel): | ||||||||||
| """ | ||||||||||
| Defines paths which should be excluded. Each file or directory that is matched by the [glob][pattern] is marked as | ||||||||||
| excluded. If a project definition file is matched by the [pattern], the whole project is excluded. For details about | ||||||||||
|
Comment on lines
+14
to
+15
|
||||||||||
| Defines paths which should be excluded. Each file or directory that is matched by the [glob][pattern] is marked as | |
| excluded. If a project definition file is matched by the [pattern], the whole project is excluded. For details about | |
| Defines paths which should be included. Each file or directory that is matched by the [glob][pattern] is marked as | |
| included. If a project definition file is matched by the [pattern], the whole project is included. For details about |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,19 @@ | ||
| # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| from enum import IntEnum | ||
|
|
||
|
|
||
| class PathIncludeReason(IntEnum): | ||
| """ | ||
| Possible reasons for including a path. | ||
|
|
||
| Attributes: | ||
| SOURCE_OF | ||
| The path contains source code used to build distributed build artifacts. | ||
| OTHER | ||
| A fallback reason for the [PathIncludeReason] when none of the other reasons apply. | ||
| """ | ||
|
|
||
| SOURCE_OF = 1 | ||
| OTHER = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring says "Defines which parts of a repository should be excluded" but this is the Includes class that defines which parts should be included. The docstring should say "Defines which parts of a repository should be included."