Structural Types¶
Structural types define complex data structures with heterogeneous elements, where different positions or attributes can have different types. Unlike collections, structural types allow mixing different types within the same structure.
π€ AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
The structural types are:
- CtyObject - A structure with named attributes, each having its own type (similar to a typed dictionary). Supports optional attributes that can be omitted from data.
- CtyTuple - A fixed-length sequence where each position has a specific type (similar to a typed tuple). The number of elements and their types are defined at schema creation.
- CtyDynamic - A special type that can represent any value, with the actual type determined at runtime. Useful for scenarios where the type structure isn't known until runtime.
Structural types are ideal for modeling complex domain objects, API responses, and configuration schemas where different fields have different meanings and types.
See also: User Guide: Structural Types for detailed usage examples.
pyvider.cty.types.structural
¶
Classes¶
CtyDynamic
¶
Represents a dynamic type that can hold any CtyValue.
Functions¶
validate
¶
Validates a raw Python value for a dynamic type. The result is always a CtyValue of type CtyDynamic, which wraps the inferred concrete value.