Skip to content

refactor(repoconfig): Get rid of legacy classes#18

Merged
heliocastro merged 1 commit intomainfrom
refactor/repository_config
Feb 20, 2026
Merged

refactor(repoconfig): Get rid of legacy classes#18
heliocastro merged 1 commit intomainfrom
refactor/repository_config

Conversation

@heliocastro
Copy link
Owner

No description provided.

Signed-off-by: Helio Chissini de Castro <dev@heliocastro.info>
Copilot AI review requested due to automatic review settings February 20, 2026 13:23
@heliocastro heliocastro self-assigned this Feb 20, 2026
@heliocastro heliocastro merged commit 39e4ffb into main Feb 20, 2026
20 checks passed
@heliocastro heliocastro deleted the refactor/repository_config branch February 20, 2026 13:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the repository configuration code by removing legacy classes from src/ort/models/repository_configuration.py and reorganizing them into a cleaner, more modular structure under src/ort/models/config/. The refactoring replaces verbose class names (e.g., OrtRepositoryConfigurationIncludesPath) with simpler, clearer names (e.g., PathInclude), changes enums from using auto() to explicit IntEnum values, and introduces a reusable convert_enum utility function for string-to-enum field validation.

Changes:

  • Removed the monolithic repository_configuration.py file containing 305 lines of legacy classes and replaced it with a modular config structure
  • Introduced new model classes with cleaner names and explicit IntEnum values for all configuration enums (path includes/excludes, scopes, resolutions, snippets, licenses)
  • Added a convert_enum utility function and applied it to Issue severity validation, with plans to use it across other enum fields

Reviewed changes

Copilot reviewed 31 out of 32 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
src/ort/models/repository_configuration.py Deleted legacy file with monolithic class definitions
src/ort/models/config/repository_configuration.py New modular RepositoryConfiguration with cleaner imports
src/ort/models/config/includes.py New Includes model for path inclusions
src/ort/models/config/excludes.py New Excludes model for path and scope exclusions
src/ort/models/config/path_include.py PathInclude model with enum validator
src/ort/models/config/path_include_reason.py PathIncludeReason enum changed to IntEnum with explicit values
src/ort/models/config/path_exclude.py PathExclude model with enum validator added
src/ort/models/config/path_exclude_reason.py PathExcludeReason enum refactored from Enum with auto() to IntEnum
src/ort/models/config/scope_exclude.py New ScopeExclude model with enum validator
src/ort/models/config/scope_exclude_reason.py New ScopeExcludeReason IntEnum
src/ort/models/config/resolutions.py New Resolutions model aggregating issue, rule violation, and vulnerability resolutions
src/ort/models/config/issue_resolution.py New IssueResolution model
src/ort/models/config/issue_resolution_reason.py New IssueResolutionReason IntEnum
src/ort/models/config/rule_violation_resolution.py New RuleViolationResolution model with enum validator
src/ort/models/config/rule_violation_reason.py New RuleViolationResolutionReason IntEnum
src/ort/models/config/vulnerability_resolution.py New VulnerabilityResolution model
src/ort/models/config/vulnerability_resolution_reason.py New VulnerabilityResolutionReason IntEnum
src/ort/models/config/license_choice.py New LicenseChoice and PackageLicenseChoice models
src/ort/models/config/snippet/snippet_choice.py New SnippetChoice, Given, and Choice models for snippet selection
src/ort/models/config/snippet/snippet_choice_reason.py New SnippetChoiceReason IntEnum
src/ort/models/config/snippet/Provenance.py New Provenance model for repository provenance URLs
src/ort/models/text_location.py New TextLocation model for file location references
src/ort/utils/spdx/spdx_license_choice.py New SpdxLicenseChoice model for license selections
src/ort/utils/spdx/spdx_expression.py New SpdxExpression IntEnum for validation strictness levels
src/ort/utils/convert_enum.py New utility function for string-to-enum conversion
src/ort/utils/__init__.py Exported convert_enum utility
src/ort/models/__init__.py Updated exports to include new config models
src/ort/__init__.py Updated import path for RepositoryConfiguration
src/ort/models/repository.py Updated import path for RepositoryConfiguration
src/ort/models/issue.py Refactored to use convert_enum utility
tests/test_repository_configuration.py Updated to use new class names and enum values
Comments suppressed due to low confidence (1)

tests/test_repository_configuration.py:65

  • The error message in the docstring refers to "RepositoryConfigurationIncludesPath" which is the old class name from the legacy code. It should be updated to "PathInclude" to match the new class name being used in the refactored code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring says "Defines paths which should be excluded" but this is the PathInclude class that defines paths to be included. The docstring should say "Defines paths which should be included." Additionally, the rest of the description talks about exclusions ("marked as excluded", "whole project is excluded") which is incorrect for an include operation.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +41
repository_license_choices: list[SpdxLicenseChoice] = Field(
default_factory=list,
description="SPDX",
)
Copy link

Copilot AI Feb 20, 2026

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 uses AI. Check for mistakes.
Comment on lines +32 to +34
purl: str = Field(
...,
description="The purl of the snippet chosen by this snippet choice."
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'purl' field is marked as required (using ...) but the description states "If [reason] is [SnippetChoiceReason.NO_RELEVANT_FINDING], it is null." This is inconsistent. If the field can be null, it should be defined as 'purl: str | None' with a default of None, not as required.

Suggested change
purl: str = Field(
...,
description="The purl of the snippet chosen by this snippet choice."
purl: str | None = Field(
None,
description="The purl of the snippet chosen by this snippet choice. "

Copilot uses AI. Check for mistakes.
)
purl: str = Field(
...,
description="The purl of the snippet chosen by this snippet choice."
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a space between sentences in the description. It should read "snippet choice. If [reason]" instead of "snippet choice.If [reason]"

Suggested change
description="The purl of the snippet chosen by this snippet choice."
description="The purl of the snippet chosen by this snippet choice. "

Copilot uses AI. Check for mistakes.

class PackageLicenseChoice(BaseModel):
"""
SpdxLicenseChoice]s defined for an artifact.
Copy link

Copilot AI Feb 20, 2026

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.

Suggested change
SpdxLicenseChoice]s defined for an artifact.
[SpdxLicenseChoice]s defined for an artifact.

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +28
reason: IssueResolutionReason = Field(
description="The reason why the issue is resolved.",
)
Copy link

Copilot AI Feb 20, 2026

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.

Copilot uses AI. Check for mistakes.

class Includes(BaseModel):
"""
Defines which parts of a repository should be excluded.
Copy link

Copilot AI Feb 20, 2026

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."

Suggested change
Defines which parts of a repository should be excluded.
Defines which parts of a repository should be included.

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +40
given: str | None = Field(
default=None,
description="SPDX",
)
Copy link

Copilot AI Feb 20, 2026

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 "The SPDX expression to match" or "The given SPDX license expression or sub-expression."

Copilot uses AI. Check for mistakes.

message: str = Field(
description="A regular expression string to match the messages of rule violations to resolve."
"Whitespace in the message will be [collapsed][collapseWhitespace] and it will be converted to"
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a space between sentences. The description should have a space after the period: "to resolve. Whitespace in the message"

Suggested change
"Whitespace in the message will be [collapsed][collapseWhitespace] and it will be converted to"
" Whitespace in the message will be [collapsed][collapseWhitespace] and it will be converted to"

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +40
reason: SnippetChoiceReason = Field(
...,
description="The reason why this snippet choice was made.",
)
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Choice class has an enum field 'reason' of type SnippetChoiceReason 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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants