tessl install tessl/pypi-pydantic@2.11.0Data 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%
Build a storage quota configuration system that validates and manages file size limits for different user tiers.
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.
Validate storage quota configurations with support for both decimal (KB, MB, GB) and binary (KiB, MiB, GiB) units.
Check if a given file size in bytes is within the quota limit.
Format storage sizes in bytes as human-readable strings.
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@generates
Provides data validation with support for human-readable byte size types.
@satisfied-by