or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pydantic@2.11.x
tile.json

tessl/pypi-pydantic

tessl install tessl/pypi-pydantic@2.11.0

Data validation using Python type hints

Agent Success

Agent success rate when using this tile

90%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.3x

Baseline

Agent success rate without this tile

69%

task.mdevals/scenario-4/

User Status Manager

A system for managing user account statuses with automatic validation and JSON serialization.

Capabilities

Status validation

  • Creating a user with status "active" succeeds @test
  • Creating a user with status "suspended" succeeds @test
  • Creating a user with an invalid status like "invalid" raises a validation error @test

JSON serialization

  • Serializing a user with status "active" to JSON produces a dictionary with status value as "active" string @test
  • Serializing a user with status "suspended" to JSON produces a dictionary with status value as "suspended" string @test

User creation from dictionary

  • Creating a user from a dictionary with status "active" succeeds @test
  • Creating a user from a dictionary with status "banned" succeeds @test

Implementation

@generates

API

from enum import Enum
from typing import Dict, Any

class AccountStatus(Enum):
    """Enumeration of possible account statuses."""
    ACTIVE = "active"
    SUSPENDED = "suspended"
    BANNED = "banned"

class User:
    """
    User model with validated account status.

    When serialized to JSON/dict, the status should be represented
    as its string value (e.g., "active") rather than the enum instance.
    """
    username: str
    status: AccountStatus

    def to_dict(self) -> Dict[str, Any]:
        """
        Convert user to dictionary representation.
        Status should be serialized as its string value.
        """
        pass

Dependencies { .dependencies }

pydantic { .dependency }

Provides data validation support.