Some extra sweets for marshmallow.
Examples
Use annotations for schema description.
from jam import Schema
class Bar(Schema):
baz: str
class Foo(Schema):
bar: Bar
foo: Foo = Foo().load({"bar": {"baz": "quux"}})
assert foo.bar.baz == "quux"
When annotations not enough
class Foo(Schema):
bar: str = fields.Email()
Mapping rules
Basic Types
annotation |
marshmallow field |
|---|---|
str |
fields.String |
float |
fields.Float |
bool |
fields.Boolean |
int |
fields.Integer |
uuid.UUID |
fields.UUID |
decimal.Decimal |
fields.Decimal |
dt.datetime |
fields.DateTime |
dt.time |
fields.Time |
dt.date |
fields.Date |
dt.timedelta |
fields.TimeDelta |
All fields will be required for make it optional use typing.Optional[X]
Many
annotation |
marshmallow field |
|---|---|
list |
fields.Raw(many=True) |
typing.List[float] |
fields.List(fields.Float()) |
Nested
annotation |
marshmallow field |
|---|---|
NestedSchema |
fields.Nested(NestedSchema, required=True) |
typing.Optional[NestedSchema] |
fields.Nested(NestedSchema, required=True) |
typing.List[NestedSchema] |
fields.Nested(NestedSchema, required=True, many=True) |
Release files for marshmallow-jam 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| marshmallow-jam-1.2.0.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| marshmallow_jam-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / marshmallow-jam-1.2.0.tar.gz
| Download URL | marshmallow-jam-1.2.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff3fa72b9f7023e487cfcbeb56f56257add45cd5f7c012b41ad4fb35f06707c0
|
|
BLAKE2b-256 checksum How to use checksums |
6bb4760911a9496b6474e08fba5178a5516dc07222f48b3bf26b1b2335532f9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
|
Release files / marshmallow_jam-1.2.0-py3-none-any.whl
| Download URL | marshmallow_jam-1.2.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf05569cebbb4321ca46a4c8ee9057163248a5ae0fa4bd3bb0641d39dc0d9812
|
|
BLAKE2b-256 checksum How to use checksums |
6c5e3e13a138c69b46297d58feddb9fae3da61ac6ca3ed67f4030c2a15d59698
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
|