Welcome to Pyvider CTY¶
A powerful and flexible type system for Python, compatible with HashiCorp's go-cty.
π€ 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.
pyvider.cty is a pure-Python implementation of the go-cty type system, providing strong type validation and serialization capabilities for configuration data. It's designed to work seamlessly with Terraform providers and other HashiCorp ecosystem tools.
Why Pyvider CTY?¶
β‘ Expressive and Flexible¶
- Rich Type System: A comprehensive set of primitive, collection, and structural types to model your data accurately.
- Dynamic Types: Handle data with unknown or varying structures using the dynamic type.
- Capsule Types: Encapsulate and protect foreign data types within the
ctysystem.
π οΈ Developer Experience¶
- Modern Python: Leverages Python 3.11+ features with complete type annotations.
- Clear and Concise API: A simple and intuitive API for defining types, validating data, and working with values.
- Detailed Diagnostics: Get detailed error messages and validation diagnostics to quickly identify and fix issues.
ποΈ Robust and Reliable¶
- Immutable Values:
ctyvalues are immutable, ensuring data integrity and preventing unintended side effects. - Thoroughly Tested: A comprehensive test suite ensures the library is reliable and production-ready.
- Battle-Tested Concepts: Based on the well-established
ctytype system from HashiCorp's Terraform.
π Cross-Language Compatibility¶
- Go-Cty Interoperability: Serialize and deserialize data in MessagePack format compatible with go-cty.
- Terraform Integration: Parse Terraform type strings and work with Terraform data structures.
Quick Example¶
from pyvider.cty import CtyObject, CtyString, CtyNumber, CtyList
# Define a type schema
user_type = CtyObject(
attribute_types={
"name": CtyString(),
"age": CtyNumber(),
"hobbies": CtyList(element_type=CtyString())
},
optional_attributes={"age"}
)
# Validate data
user_data = {
"name": "Alice",
"hobbies": ["reading", "hiking"]
}
user_val = user_type.validate(user_data)
print(f"Name: {user_val['name'].raw_value}")
Where to Start¶
-
Install pyvider.cty and learn the basics in 5 minutes
-
Comprehensive guide to types, values, and advanced features
-
Practical guides for common tasks and use cases
-
Complete API documentation for all types and functions
Installation¶
Features at a Glance¶
- π― Complete Type System: Primitives, collections, and structural types
- π Cross-Language Compatibility: Interoperates with go-cty via MessagePack
- π‘οΈ Type Safety: Strong validation at value creation
- π·οΈ Marks System: Attach metadata without modifying values
- πΊοΈ Path Navigation: Type-safe access to nested data
- β‘ Full Standard Library: Comprehensive suite of functions for data manipulation
Community and Support¶
- GitHub: provide-io/pyvider-cty
- Issues: Report bugs or request features
- Contributing: See our Contributing Guidelines
License¶
Apache License 2.0. See LICENSE for details.