Repository: apify/crawlee-python
File: src/crawlee/base_storage_client/_models.py (Python)

Code before:
    was_already_handled: Annotated[bool, Field(alias='wasAlreadyHandled')]


@docs_group('Data structures')
class UnprocessedRequest(BaseModel):
    """Represents an unprocessed request."""

    model_config = ConfigDict(populate_by_name=True)

    unique_key: Annotated[str, Field(alias='requestUniqueKey')]
    url: Annotated[str, BeforeValidator(validate_http_url), Field()]
    method: Annotated[HttpMethod | None, Field()] = None


@docs_group('Data structures')
class BatchRequestsOperationResponse(BaseModel):
    """Response to batch request deletion calls."""

    model_config = ConfigDict(populate_by_name=True)

    processed_requests: Annotated[list[ProcessedRequest], Field(alias='processedRequests')]
    unprocessed_requests: Annotated[list[UnprocessedRequest], Field(alias='unprocessedRequests')]


class InternalRequest(BaseModel):
    """Represents an internal representation of queue request with additional metadata for ordering and storage."""

    model_config = ConfigDict(populate_by_name=True)

    id: str

    unique_key: str

    order_no: Decimal | None = None
    """Order number for maintaining request sequence in queue.
    Used for restoring correct request order when recovering queue from storage."""

    handled_at: datetime | None

    request: Annotated[
        Request, Field(alias='json_'), BeforeValidator(lambda v: json.loads(v) if isinstance(v, str) else v)
    ]
    """Original Request object. The alias 'json_' is required for backward compatibility with legacy code."""

    @classmethod
    def from_request(cls, request: Request, id: str, order_no: Decimal | None) -> InternalRequest:
        return cls(
            unique_key=request.unique_key, id=id, handled_at=request.handled_at, order_no=order_no, request=request
        )

    def to_request(self) -> Request:

Review comment (suggestion):
```suggestion
    """Internal representation of a queue request with additional metadata for ordering and storage."""
```

Code after:
    was_already_handled: Annotated[bool, Field(alias='wasAlreadyHandled')]


@docs_group('Data structures')
class UnprocessedRequest(BaseModel):
    """Represents an unprocessed request."""

    model_config = ConfigDict(populate_by_name=True)

    unique_key: Annotated[str, Field(alias='requestUniqueKey')]
    url: Annotated[str, BeforeValidator(validate_http_url), Field()]
    method: Annotated[HttpMethod | None, Field()] = None


@docs_group('Data structures')
class BatchRequestsOperationResponse(BaseModel):
    """Response to batch request deletion calls."""

    model_config = ConfigDict(populate_by_name=True)

    processed_requests: Annotated[list[ProcessedRequest], Field(alias='processedRequests')]
    unprocessed_requests: Annotated[list[UnprocessedRequest], Field(alias='unprocessedRequests')]


class InternalRequest(BaseModel):
    """Internal representation of a queue request with additional metadata for ordering and storage."""

    model_config = ConfigDict(populate_by_name=True)

    id: str

    unique_key: str

    order_no: Decimal | None = None
    """Order number for maintaining request sequence in queue.
    Used for restoring correct request order when recovering queue from storage."""

    handled_at: datetime | None

    request: Annotated[
        Request, Field(alias='json_'), BeforeValidator(lambda v: json.loads(v) if isinstance(v, str) else v)
    ]
    """Original Request object. The alias 'json_' is required for backward compatibility with legacy code."""

    @classmethod
    def from_request(cls, request: Request, id: str, order_no: Decimal | None) -> InternalRequest:
        return cls(
            unique_key=request.unique_key, id=id, handled_at=request.handled_at, order_no=order_no, request=request
        )

    def to_request(self) -> Request: