Skip to main content

Pure-Python implementation of the go-cty type system with strong validation, serialization, and Terraform interoperability

Project description

🌊🪢 Pyvider CTY

License Python 3.11+ uv Ruff CI

Pure-Python implementation of the go-cty type system for Terraform tooling

pyvider.cty provides strong type validation and serialization capabilities for configuration data, designed to work seamlessly with Terraform providers and HashiCorp ecosystem tools.

✨ Key Features

  • 🎯 Complete Type System - Full implementation of go-cty primitives, collections, and structural types
  • 🔄 Cross-Language Compatibility - JSON/MessagePack serialization for Go interoperability
  • Type-Safe Validation - Strong validation with detailed error messages
  • 🏷️ Marks System - Attach metadata to values without modification
  • 🧭 Path Navigation - Type-safe access to nested data structures
  • 📚 Standard Library - Comprehensive collection of type functions

Quick Start

Note: pyvider-cty is in pre-release (v0.x.x). APIs and features may change before 1.0 release.

  1. Install: uv add pyvider-cty
  2. Follow the Getting Started guide.
  3. See the Quick Example below.

Documentation

Comprehensive documentation is available in the docs/ directory:

Or start with the documentation index.

Development

Quick Start

# Set up environment
uv sync

# Run common tasks
we run test       # Run tests
we run lint       # Check code
we run format     # Format code
we tasks          # See all available commands

See CLAUDE.md for detailed development instructions and architecture information.

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

License

Apache License 2.0. See LICENSE for details.

Overview

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.

Key Features: Complete type system, cross-language compatibility via MessagePack, type-safe validation, marks system, path navigation, and comprehensive standard library.

Installation

uv add pyvider-cty

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)

# Access validated data
print(f"Name: {user_val['name'].raw_value}")  # Output: Alice

Known Limitations

  • Python 3.11+ Required: Due to modern type features and syntax used.
  • Performance: The library is not optimized for performance-critical applications involving very large or deeply nested data structures. Performance is reasonable for typical use cases.

Copyright (c) provide.io LLC.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvider_cty-0.4.0.tar.gz (66.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvider_cty-0.4.0-py3-none-any.whl (88.9 kB view details)

Uploaded Python 3

File details

Details for the file pyvider_cty-0.4.0.tar.gz.

File metadata

  • Download URL: pyvider_cty-0.4.0.tar.gz
  • Upload date:
  • Size: 66.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyvider_cty-0.4.0.tar.gz
Algorithm Hash digest
SHA256 381bee0c1a770b7dcd6f35bd1128311adeb56ae7d887a7ccfaf3b3d510c90da4
MD5 aa40fdb0ea6bcd7b32379b39be2f850f
BLAKE2b-256 a0005df6a760a92fad30d1026764d4810bba6b91565dbc0126f498ca24723a1b

See more details on using hashes here.

File details

Details for the file pyvider_cty-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pyvider_cty-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 88.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyvider_cty-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba1d4a5d0dff449e7990e30e52e470c951a47b5526e73ad41c695c2cff10dc60
MD5 772bed5ff20a482ee9ec8df839d3b2e6
BLAKE2b-256 3430f6ae378393c19fe03e4e9d2fc453b6cb0d77f6cbe20957295f91edd98bfe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page