Skip to content

fix(models): Update ValidatedIntEnum class to properly serialize with…#25

Merged
heliocastro merged 1 commit intomainfrom
fix/validate_enum
Mar 18, 2026
Merged

fix(models): Update ValidatedIntEnum class to properly serialize with…#25
heliocastro merged 1 commit intomainfrom
fix/validate_enum

Conversation

@heliocastro
Copy link
Owner

… strings

… strings

Signed-off-by: Helio Chissini de Castro <helio.chissini.de.castro@cariad.technology>
@heliocastro heliocastro self-assigned this Mar 18, 2026
@heliocastro heliocastro added the bug Something isn't working label Mar 18, 2026
Copilot AI review requested due to automatic review settings March 18, 2026 17:30
@heliocastro heliocastro merged commit c35b237 into main Mar 18, 2026
18 checks passed
@heliocastro heliocastro deleted the fix/validate_enum branch March 18, 2026 17:31
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 updates the ValidatedIntEnum Pydantic integration so enums serialize as their string names (and expose a string-enum JSON schema), adds focused tests for the new behavior, and bumps project / tooling versions accordingly.

Changes:

  • Update ValidatedIntEnum core schema to serialize enums as name and emit a string enum JSON schema.
  • Add new tests and repo-config fixtures to validate enum behavior and YAML config validation (including known-invalid fixtures).
  • Bump python-ort version to 0.8.5 and update ty dependency to >=0.0.23; adjust SPDX header contact details in tests.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ort/utils/validated_enum.py Implements string-based serialization + JSON schema customization for ValidatedIntEnum.
tests/test_validated_int_enum.py New test coverage for parsing, serialization, round-trips, and schema generation.
tests/test_repo_config_license_choices.py New tests ensuring license_choices.yml validates and bad_license_choices.yml fails.
tests/test_repo_config_files.py Treats additional YAML fixtures as known-invalid and asserts they fail validation.
tests/data/repo_config/license_choices.yml New valid repo-config fixture for license choices.
tests/data/repo_config/bad_license_choices.yml New invalid repo-config fixture (wrong field name) to assert validation fails.
pyproject.toml Version bump + dev dependency update (ty>=0.0.23).
uv.lock Lockfile updates reflecting version bump and updated ty package.
tests/test_vulnerability_reference.py SPDX header contact update.
tests/test_scan_result.py SPDX header contact update.
tests/test_repository_configuration.py SPDX header contact update.
tests/test_repository_analyzer_config.py SPDX header contact update.
tests/test_repo_config_curations.py SPDX header contact update.
tests/test_package_curation.py SPDX header contact update.
tests/test_package_configuration.py SPDX header contact update.
tests/test_evaluator_run.py SPDX header contact update.
tests/test_cvss_ratings.py SPDX header contact update.
tests/test_advisor_result.py SPDX header contact update.
tests/test_advisor_details.py SPDX header contact update.
tests/test_advisor_capability.py SPDX header contact update.

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

Comment on lines +36 to +38
return core_schema.no_info_wrap_validator_function(
lambda value, handler: validate(value),
core_schema.str_schema(),
Comment on lines +45 to +48
lambda _schema, handler: {
"type": "string",
"enum": enum_names,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants