Python source code as a serialization format with automatic import resolution
Project description
pycodify
Python source code as a serialization format with automatic import resolution.
Quick Start
from pycodify import Assignment, generate_python_source
from dataclasses import dataclass
@dataclass
class Config:
name: str = "default"
value: int = 42
config = Config(name="production", value=100)
code = generate_python_source(Assignment("config", config), clean_mode=True)
print(code)
# Output:
# from __main__ import Config
# config = Config(name='production', value=100)
Why Python Source?
| Format | Diffable | Inspectable | Editable | Type-preserving | Cross-version |
|---|---|---|---|---|---|
| pickle | ✗ | ✗ | ✗ | ✓ | ✗ |
| JSON/YAML | ✓ | ✓ | ✓ | ✗ | ✓ |
| Python source | ✓ | ✓ | ✓ | ✓ | ✓ |
Binary formats like pickle cannot be diffed, inspected, or edited. Text formats like JSON lose type information. Python source code has all desired properties: it is diffable, inspectable, editable, type-preserving, and cross-version stable.
Features
- Complete Executable Source: Generates imports + code, not just expressions
- Type-Preserving: Enums, Paths, callables serialize as themselves
- Collision Handling: Automatic aliasing for name collisions across modules
- Clean Mode: Omit fields matching defaults for concise output
- Extensible: Register custom formatters for domain-specific types
Documentation
Full documentation available at pycodify.readthedocs.io
Installation
pip install pycodify
License
MIT
Project details
Release history Release notifications | RSS feed
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 pycodify-0.1.2.tar.gz.
File metadata
- Download URL: pycodify-0.1.2.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88d1b49bb2e94caa4170d7a0fbc09064555798f994a6252a9187b6d739ac18f7
|
|
| MD5 |
9ae0f37b4ee184310555b3a024c2e39a
|
|
| BLAKE2b-256 |
7367da8e64ee8c813d018718672dac9331648c2bd3e6a1b74ad253c33ebbe9db
|
Provenance
The following attestation bundles were made for pycodify-0.1.2.tar.gz:
Publisher:
publish.yml on OpenHCSDev/pycodify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycodify-0.1.2.tar.gz -
Subject digest:
88d1b49bb2e94caa4170d7a0fbc09064555798f994a6252a9187b6d739ac18f7 - Sigstore transparency entry: 884290095
- Sigstore integration time:
-
Permalink:
OpenHCSDev/pycodify@7dcec1b1f0b512d4f8a079fdbf8b2fd19f82952e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/OpenHCSDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7dcec1b1f0b512d4f8a079fdbf8b2fd19f82952e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycodify-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pycodify-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.6 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 |
05f84f0ec9d79251cbba8b890570472b8c1822ab7b48b4ed0fe4004fc6c18ef9
|
|
| MD5 |
ecc8eda358ab13cb131b188466981e4f
|
|
| BLAKE2b-256 |
b8a17984ecf9c603df3c97b9314275a0ee41d646790317444b47145c6730b541
|
Provenance
The following attestation bundles were made for pycodify-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on OpenHCSDev/pycodify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycodify-0.1.2-py3-none-any.whl -
Subject digest:
05f84f0ec9d79251cbba8b890570472b8c1822ab7b48b4ed0fe4004fc6c18ef9 - Sigstore transparency entry: 884290244
- Sigstore integration time:
-
Permalink:
OpenHCSDev/pycodify@7dcec1b1f0b512d4f8a079fdbf8b2fd19f82952e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/OpenHCSDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7dcec1b1f0b512d4f8a079fdbf8b2fd19f82952e -
Trigger Event:
push
-
Statement type: