Extensions for working with Python Dataclasses
Project description
Compysitions
Project Overview
Python dataclasses are used to represent data in a python object. They support decoding some data to dict out of the box, but do not handle all types neatly nor support loading to an instance from dict. This project provides an extensible class that will allow you to define objects the way you would in a dataclass, but provides additional encoding and decoding support to represent these objects as data for i/o and storage purposes.
Usage Examples
The below will show how Compysitions handles support for increasingly complex data describing transactions in a store.
Built-in types
class Transaction(Compysition):
buyer_name: str = None
item_name: str = None
price: float = 0.00
transaction_data = {
"buyer_name": "John Smith",
"item_name": "Floral Shirt",
"price": 20.99
}
transaction_obj = Transaction().from_dict(transaction_data)
Setting up the development environment
The following steps will set up linting on commit and the ability to run tests.
- Clone repository
- Create a virtual environment for development
pip install -r dev_requirements.txt
pre-commit install
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
File details
Details for the file compysitions-0.0.3.tar.gz
.
File metadata
- Download URL: compysitions-0.0.3.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25ebe4ac5c660d064283a7b51807f977d2f22a405465c3b41cac9093e9e80b24 |
|
MD5 | e0c1c6140eeb376c9c815afbd505e80e |
|
BLAKE2b-256 | cb9eb82420535c202a18cca2957c0eb7c1c1559830a0132aabc8bc1766b008e6 |
File details
Details for the file compysitions-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: compysitions-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09dadd24ef1ea04bb0cc27b830ed03f97ac84253d35abb4f9c3f76073880e16f |
|
MD5 | 0a55a75c3dc6527878fab05cf80a7256 |
|
BLAKE2b-256 | 6e627ba377e865d3f658da89af3eb8bd3d5d46d51fa414c7d3296e7041f51aa9 |