Data validation using Python type hints
90
{
"context": "This criteria evaluates how well the engineer uses pydantic's alias system to automatically convert field names between internal (snake_case) and external (camelCase) API formats. It specifically assesses the use of alias generators for automatic conversion, custom serialization aliases for special cases, and proper serialization with the by_alias parameter.",
"type": "weighted_checklist",
"checklist": [
{
"name": "ConfigDict with alias_generator",
"description": "Uses ConfigDict with alias_generator (e.g., to_camel from pydantic.alias_generators or a custom function) to automatically convert snake_case field names to camelCase during serialization",
"max_score": 25
},
{
"name": "Custom serialization_alias usage",
"description": "Uses Field() with serialization_alias parameter to specify that registration_date should serialize as 'regDate' instead of following the camelCase pattern",
"max_score": 20
},
{
"name": "serialize_by_alias configuration",
"description": "Configures models to serialize by alias by either setting serialize_by_alias=True in ConfigDict or using by_alias=True parameter in model_dump() calls",
"max_score": 20
},
{
"name": "to_api_format method implementation",
"description": "Implements a to_api_format() method in each model that calls model_dump() with appropriate parameters (by_alias=True if not configured globally) to return aliased field names",
"max_score": 15
},
{
"name": "Nested model aliasing",
"description": "Correctly applies alias generation to nested models (User and Address within UserProfile) so that nested fields also serialize with camelCase names",
"max_score": 10
},
{
"name": "BaseModel inheritance",
"description": "Defines all three models (User, Address, UserProfile) as classes that inherit from pydantic.BaseModel",
"max_score": 5
},
{
"name": "Field type annotations",
"description": "Uses proper type annotations (int, str) for all fields in all models to enable pydantic validation",
"max_score": 5
}
]
}Install with Tessl CLI
npx tessl i tessl/pypi-pydanticdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10