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-1/

Storage Quota Configuration System

Build a storage quota configuration system that validates and manages file size limits for different user tiers.

Overview

Implement a configuration validator that accepts storage quotas in human-readable formats (like "500 MB", "2.5 GiB") and provides utilities to check if file sizes are within allowed limits and format sizes for display.

Capabilities

Quota validation

Validate storage quota configurations with support for both decimal (KB, MB, GB) and binary (KiB, MiB, GiB) units.

  • A quota of "500 MB" is successfully validated @test
  • A quota of "2.5 GiB" is successfully validated @test
  • A quota of "100 KB" is successfully validated @test

File size checking

Check if a given file size in bytes is within the quota limit.

  • A file of 100000000 bytes (100 MB) is within a "500 MB" quota @test
  • A file of 600000000 bytes (600 MB) exceeds a "500 MB" quota @test
  • A file of 1073741824 bytes (1 GiB) is within a "2.5 GiB" quota @test

Human-readable formatting

Format storage sizes in bytes as human-readable strings.

  • 1048576 bytes is formatted as "1.0 MiB" @test
  • 500000000 bytes is formatted as "476.84 MiB" @test
  • 1073741824 bytes is formatted as "1.0 GiB" @test

API

from pydantic import BaseModel

class StorageQuota(BaseModel):
    """Storage quota configuration for a user tier."""
    quota_limit: <appropriate_type>

    def is_within_quota(self, file_size_bytes: int) -> bool:
        """Check if a file size in bytes is within the quota limit."""
        pass

    def format_size(self, size_bytes: int) -> str:
        """Format a size in bytes as a human-readable string."""
        pass

Implementation

@generates

Dependencies { .dependencies }

pydantic { .dependency }

Provides data validation with support for human-readable byte size types.

@satisfied-by