Skip to main content

TyConf - Type-safe Configuration Management for Python with Value Validation

Project description

TyConf

TyConfTyped Config - a type-safe configuration management library for Python with runtime validation.

What is TyConf?

TyConf is a modern Python library that makes managing application configuration simple, safe, and intuitive. It provides runtime type validation, value validation, read-only properties, and freeze/unfreeze capabilities to help you build robust applications.

Quick Start

from tyconf import TyConf
from tyconf.validators import range

# Create configuration with type-safe properties and validators
config = TyConf(
    host=(str, "localhost"),               # Mutable string
    debug=(bool, True),                    # Mutable boolean
    port=(int, 8080, range(1024, 65535)),  # Validated mutable range
    users=(list, ["admin", "root"], True)  # Immutable list
)

# Access values easily
print(config.host)       # 'localhost'
config.port = 3000       # Type-checked and range-validated automatically
config.port = "3000"     # Rises TypeError: Property 'port': expected int, got str
config.users = ["guest"] # Rises AttributeError: Property 'users' is read-only

Key Features

Type Safety - Runtime type validation with support for Optional and Union types
Value Validation - Built-in validators (range, length, regex, etc.) and custom validation functions
Read-Only Properties - Protect critical configuration from accidental changes
Freeze/Unfreeze - Lock entire configuration to prevent modifications
Intuitive API - Both attribute (config.host) and dict-style (config['host']) access
Copy & Reset - Easily duplicate or restore default configurations
Zero Dependencies - Pure Python with no external requirements

Installation

pip install tyconf

Documentation

Examples

See the examples/ directory for complete examples:

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Links

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

tyconf-1.1.2.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

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

tyconf-1.1.2-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file tyconf-1.1.2.tar.gz.

File metadata

  • Download URL: tyconf-1.1.2.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for tyconf-1.1.2.tar.gz
Algorithm Hash digest
SHA256 9906cd2ed194b740e9992ee89d46ab0c905a9f86da0a6c94d40a875471b3f495
MD5 9e318fa23444a66dd4ad44e260635ed7
BLAKE2b-256 36dc8cc3d3dccd0d99d4d2c44e9636723f940d55166ba0c3e65a227413bfe1bf

See more details on using hashes here.

File details

Details for the file tyconf-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: tyconf-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for tyconf-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e05c90ded2ba0120ec298fcae4eca5d26dd4b884fe08954a86eccd96ec560b4b
MD5 f10abe90204c45f9ae404a2a67ea0da9
BLAKE2b-256 ca178dc55ac12c21d08d14e46a19f0c218a6bc8685272ce2312879b66b7c4928

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