Skip to content

Investigate removing pydantic.BaseModel from CompressionTaskResult class #1347

@coderabbitai

Description

@coderabbitai

Background

During the Pydantic v2 upgrade in PR #1338, a discussion arose about whether the CompressionTaskResult class needs to inherit from pydantic.BaseModel.

Currently, the class has a validator for the status field:

@field_validator("status")
@classmethod
def valid_status(cls, field):
    supported_status = [CompressionTaskStatus.SUCCEEDED, CompressionTaskStatus.FAILED]
    if field not in supported_status:
        raise ValueError(f'must be one of the following {"|" .join(supported_status)}')
    return field

However, since CompressionTaskResult is not user-facing, it might be possible to:

  1. Remove the pydantic.BaseModel inheritance
  2. Type the status field directly as CompressionTaskStatus instead of int
  3. Remove the validator entirely

Requirements

  • Thorough validation is required to ensure no regression is caused by lifting the checks/typing
  • Investigate all usage patterns of CompressionTaskResult throughout the codebase
  • Ensure that direct typing provides the same safety guarantees as the current validator
  • Consider impact on serialization/deserialization if the class is used in that context

Context

Acceptance Criteria

  • Analyze all usages of CompressionTaskResult in the codebase
  • Determine if pydantic.BaseModel can be safely removed
  • If feasible, implement the change with proper typing
  • Ensure comprehensive testing to prevent regressions
  • Document any breaking changes or migration requirements

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions