Dataclass runtime machinery for declarative DSLs
Project description
dataclass-dsl
Build declarative Python DSLs where infrastructure and configuration look like this:
from . import *
class LogBucketEncryption(s3.Bucket.BucketEncryption):
server_side_encryption_configuration = [LogBucketEncryptionRule]
class LogBucket(s3.Bucket):
bucket_encryption = LogBucketEncryption
public_access_block_configuration = LogBucketPublicAccessBlock
versioning_configuration = LogBucketVersioning
No decorators. No function calls. No boilerplate.
The Pattern
Domain packages built on dataclass-dsl share three properties:
| Property | What it means |
|---|---|
| Single import | from . import * — everything available, loaded in dependency order |
| Zero decorators | Classes are plain declarations, machinery is invisible |
| Inheritance wrappers | Each class inherits from a resource type with simple attribute assignments |
The result reads like configuration, but with full Python power: IDE autocomplete, type checking, refactoring, and the ability to use variables, loops, and conditionals when needed.
What This Enables
Reference other resources by class name:
class AppSubnet(Subnet):
vpc = AppVPC # Reference to another resource
cidr_block = "10.0.1.0/24"
Reference specific attributes:
class LambdaFunction(Function):
role_arn = ExecutionRole.Arn # Gets the Arn of ExecutionRole
Compose nested configurations:
class BucketEncryption(s3.Bucket.BucketEncryption):
server_side_encryption_configuration = [EncryptionRule]
class MyBucket(s3.Bucket):
bucket_encryption = BucketEncryption
Use lists and maps of references:
class LoadBalancer(ALB):
subnets = [SubnetA, SubnetB, SubnetC]
security_groups = [WebSecurityGroup]
How It Works
dataclass-dsl provides the runtime machinery that makes this pattern possible:
- Automatic dependency detection — References between classes are detected at runtime
- Topological ordering — Resources are serialized in dependency order
- Multi-file support —
setup_resources()loads files in the right order, enablingfrom . import * - IDE stub generation — Full autocomplete and type checking despite dynamic imports
Domain packages use these primitives to create decorators and loaders that are invisible to end users.
Installation
uv add dataclass-dsl
Using a Domain Package
If you're using a domain package built on dataclass-dsl (like an AWS CDK alternative or Kubernetes manifest generator), follow that package's documentation. You'll write clean declarative classes without needing to understand the internals.
Building a Domain Package
If you're creating a domain package, see the Internals Guide for:
- Creating a domain-specific decorator with
create_decorator() - Setting up multi-file packages with
setup_resources() - Implementing a
Providerfor your target format - Generating IDE stubs for
from . import *
Also see the AWS S3 example to see what a domain package produces.
Documentation
- Core Concepts — The wrapper pattern, references, and templates
- Internals Guide — Building domain packages
- Specification — Formal specification
- CLI Framework — CLI utilities for domain packages
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dataclass_dsl-1.1.1.tar.gz.
File metadata
- Download URL: dataclass_dsl-1.1.1.tar.gz
- Upload date:
- Size: 61.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
460f7bd4fb86cf5ff7a561b5cf7a5771bd8ef0af1d0fd0733136d437953c8472
|
|
| MD5 |
f81e93ef9e891003471eda0c33b8dc26
|
|
| BLAKE2b-256 |
5d61d2b756a4d97c448a8eb187f753f079a04f3f2c516291ada69abdba103661
|
Provenance
The following attestation bundles were made for dataclass_dsl-1.1.1.tar.gz:
Publisher:
release.yml on lex00/dataclass-dsl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dataclass_dsl-1.1.1.tar.gz -
Subject digest:
460f7bd4fb86cf5ff7a561b5cf7a5771bd8ef0af1d0fd0733136d437953c8472 - Sigstore transparency entry: 803281975
- Sigstore integration time:
-
Permalink:
lex00/dataclass-dsl@fd49d89b584062b169051adc2f3903a5eefbce78 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/lex00
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fd49d89b584062b169051adc2f3903a5eefbce78 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dataclass_dsl-1.1.1-py3-none-any.whl.
File metadata
- Download URL: dataclass_dsl-1.1.1-py3-none-any.whl
- Upload date:
- Size: 54.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
908d6eb772826a993ec99d07fd01785b7a9be0a03b857a85fc3ede1b71dbea61
|
|
| MD5 |
4468b4c7eaa749b8d0f481ec43faab9e
|
|
| BLAKE2b-256 |
bbc493d9d836de86541596f34390ba1db69a77370052c2cfca82561c7ee61919
|
Provenance
The following attestation bundles were made for dataclass_dsl-1.1.1-py3-none-any.whl:
Publisher:
release.yml on lex00/dataclass-dsl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dataclass_dsl-1.1.1-py3-none-any.whl -
Subject digest:
908d6eb772826a993ec99d07fd01785b7a9be0a03b857a85fc3ede1b71dbea61 - Sigstore transparency entry: 803281980
- Sigstore integration time:
-
Permalink:
lex00/dataclass-dsl@fd49d89b584062b169051adc2f3903a5eefbce78 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/lex00
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fd49d89b584062b169051adc2f3903a5eefbce78 -
Trigger Event:
release
-
Statement type: