Skip to main content

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


Download files

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

Source Distribution

pycodify-0.1.2.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

pycodify-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

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

Hashes for pycodify-0.1.2.tar.gz
Algorithm Hash digest
SHA256 88d1b49bb2e94caa4170d7a0fbc09064555798f994a6252a9187b6d739ac18f7
MD5 9ae0f37b4ee184310555b3a024c2e39a
BLAKE2b-256 7367da8e64ee8c813d018718672dac9331648c2bd3e6a1b74ad253c33ebbe9db

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycodify-0.1.2.tar.gz:

Publisher: publish.yml on OpenHCSDev/pycodify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pycodify-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05f84f0ec9d79251cbba8b890570472b8c1822ab7b48b4ed0fe4004fc6c18ef9
MD5 ecc8eda358ab13cb131b188466981e4f
BLAKE2b-256 b8a17984ecf9c603df3c97b9314275a0ee41d646790317444b47145c6730b541

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycodify-0.1.2-py3-none-any.whl:

Publisher: publish.yml on OpenHCSDev/pycodify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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