:fire:toastedmarshmallow-enum:fire:: Dumps and Loads Enums
Inspired by Marshmallow Enum and by ORM libraries.
The Toasted Marshmallow Enum package makes it possible to dump and load Enum values based on the ultra fast serialization that Toasted Marshmallow provides.
Installing toastedmarshmallow-enum
pip install toastedmarshmallow-enum
Using Toasted Marshmallow Enum
Using Toasted Marshmallow Enum in an existing Marshmallow Schema is as easy as defining the enum class attribute as an EnumField. For example:
from enum import Enum
import toastedmarshmallow
from marshmallow import fields, Schema
from toastedmarshmallow_enum import EnumField
class Level(Enum):
LOW = '0'
MEDIUM = '1'
HIGH = '2'
class UserSchema(Schema):
class Meta:
jit = toastedmarshmallow.Jit
name = fields.String()
level = EnumField(Level)
How it works
Dump methods:
class User:
def __init(name, level):
self.name = name
self.level = level
schema = DummyUserSchema()
user = User(name='John Doe', level=Level.HIGH)
print(schema.dump(user).data)
# {'name': 'John Doe', 'level': 2}
print(schema.load({'name': 'John Doe', 'level: 2}).data)
# {'name': 'John Doe', 'level': 'HIGH'}
Metadata
Release files for toastedmarshmallow-enum 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| toastedmarshmallow-enum-1.0.1.tar.gz | 2.8 kB | Without provenance | Details for toastedmarshmallow-enum-1.0.1.tar.gz |
Release files / toastedmarshmallow-enum-1.0.1.tar.gz
| Download URL | toastedmarshmallow-enum-1.0.1.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4058a7f29e0a1210e5f52650b75858f77a01ec255d659793c0e52f57ddc9eb7
|
|
BLAKE2b-256 checksum How to use checksums |
b22359f407d89275e392b9ab3cb5c9c7ebf16312cd4f3eaa28f9f92bced10091
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for toastedmarshmallow-enum 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.