python-adapters-success

Builds Pydantic foreign models, contract models, and ordered unions for Python boundary crossing.

Updated Jul 15, 2026
One-click install
npx skills add https://github.com/kyzobuild/kyzo-python --skill python-adapters-success-kyzobuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-adapters-success
Source: https://github.com/kyzobuild/kyzo-python/tree/main/cursor/skills/python-adapters-success
Command: npx skills add https://github.com/kyzobuild/kyzo-python --skill python-adapters-success-kyzobuild

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pydantic.

What problem does it solve? Python programs often handle external data with ad-hoc mappers, raw json.loads dicts, and try/except blocks that manufacture unproven values. This Skill enforces a disciplined architecture where every boundary crossing uses one of three declarative Pydantic constructs, eliminating hand-written translation and error-handling code. ## Core Features & Use Cases - Foreign Model: Defines frozen BaseModels with Field aliases, validation_alias, and AliasPath to lift another system's data shape into domain types in one constructor call. - Contract Model: Defines frozen BaseModels for the program's own API requests and replies, composed only of declared domain types with no foreign aliases. - Ordered Union: Uses Annotated unions with union_mode="left_to_right" and a TypeAdapter constructor to model foreign data that may fail, replacing try/except defaults and reply parsers. - Use Case: When integrating a trading venue's WebSocket feed, define a VenueFill foreign model with aliases for the venue's keys and an ordered union Frame type that admits unparseable frames as declared values instead of catching exceptions. ## Quick Start Ask the AI to model an incoming API payload or outgoing response shape using the foreign model, contract model, or ordered union constructs from this Skill.

Frequently Asked Questions about python-adapters-success

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I parse external API responses with Pydantic?▼

Define a frozen foreign model named for the external system's thing, using Field(alias=...) for key renames and validation_alias or AliasPath for wrapped data. Call model_validate on objects or model_validate_json on serialized bytes to lift the whole payload in one constructor call.

How to handle API failures in Python without try/except?▼

Model the failure as a value using an ordered union: Annotated[A | B, Field(union_mode="left_to_right")] with the success variant first and a failure variant that composes from the input itself. Construct through a TypeAdapter constant instead of catching exceptions.

What is the difference between a foreign model and a contract model in Pydantic?▼

A foreign model represents another system's data shape, named for their thing with aliases holding their keys, lifting data inward. A contract model is your program's own API shape, built from your declared types with no foreign aliases, projecting outward.

When should I use union_mode left_to_right in Pydantic?▼

Use left_to_right union mode for foreign data that carries no identity and is expected sometimes to fail, such as unparseable frames or raising client replies. Identity-carrying data should use a discriminated union instead, never attempt-order selection.

Why should I avoid json.loads dicts and mapper functions?▼

A json.loads dict carries unproven data through the program, and mapper or translator functions restate work the Pydantic constructor already owns. The foreign model lifts the whole payload declaratively in one validated construction call.