maxi-schema for Python
Python library for parsing and dumping MAXI schema + records.
Install
pip install maxi-format
API overview
| Function | Description |
|---|---|
parse_maxi(input, **options) |
Parse MAXI text → MaxiParseResult (schema + raw records) |
stream_maxi(input, **options) |
Parse schema eagerly, yield records lazily via async iterator |
parse_maxi_as(input, class_map, **options) |
Parse + hydrate records into class instances |
parse_maxi_auto_as(input, classes, **options) |
Same, with alias inferred from __maxi_schema__ |
dump_maxi(data, **options) |
Serialize objects / parse results → MAXI text |
dump_maxi_auto(objects, **options) |
Same, with schema inferred from __maxi_schema__ |
define_maxi_schema(Cls, schema) |
Register a schema descriptor for a class |
get_maxi_schema(ClsOrInstance) |
Look up a registered schema descriptor |
MaxiModel |
Declarative base class for schema-annotated models |
Quick start
Parse
import asyncio
from maxi import parse_maxi
input_text = """
U:User(id:int|name|email)
###
U(1|Julie|julie@maxi.org)
""".strip()
res = asyncio.run(parse_maxi(input_text))
print(res.records[0].values) # [1, 'Julie', 'julie@maxi.org']
Parse into class instances
import asyncio
from maxi import parse_maxi_auto_as
class User:
__maxi_schema__ = {
"alias": "U",
"fields": [{"name": "id", "typeExpr": "int"}, {"name": "name"}, {"name": "email"}],
}
def __init__(self, id=None, name=None, email=None):
self.id = id
self.name = name
self.email = email
result = asyncio.run(parse_maxi_auto_as(input_text, [User]))
user_instance = result.data["U"][0]
print(isinstance(user_instance, User)) # True
print(user_instance.name) # 'Julie'
Dump
Using MaxiModel for zero-config dumping:
from maxi import dump_maxi_auto
from maxi.models import MaxiModel, IntField, StrField
class User(MaxiModel, alias="U"):
id = IntField(id=True)
name = StrField()
maxi = dump_maxi_auto([User(id=1, name="Julie")])
Or with explicit types via dump_maxi:
from maxi import dump_maxi
maxi = dump_maxi([{"id": 1, "name": "Julie"}],
default_alias="U",
types=[{"alias": "U", "name": "User", "fields": [{"name": "id", "typeExpr": "int"}, {"name": "name"}]}],
)
Documentation
- docs/parser.md — full parser guide:
parse_maxi,stream_maxi,parse_maxi_as,parse_maxi_auto_as, hydration,MaxiModel, options - docs/dumper.md — full dumper guide:
dump_maxi,dump_maxi_auto, schema-annotated classes, references, inheritance, options
MAXI format (quick reference)
U:User(id:int|name|email=unknown) ← type definition
### ← section separator
U(1|Julie|~) ← record (~ = explicit null)
- Omitted trailing fields use their declared default value.
- See the MAXI spec for the full format definition.
Test
Requires pytest and pytest-asyncio.
pip install pytest pytest-asyncio
pytest
License
Released under the MIT License.
Metadata
Release files for maxi-format 0.3.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 | Provenance | Actions |
|---|---|---|---|---|
| maxi_format-0.3.0.tar.gz | 53.9 kB | Without provenance | Details for maxi_format-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| maxi_format-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for maxi_format-0.3.0-py3-none-any.whl |
Total release size: 94.5 kB
Release files / maxi_format-0.3.0.tar.gz
| Download URL | maxi_format-0.3.0.tar.gz |
|---|---|
| Size | 53.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7cae5efe1ad08f414ca0e5f243ce2f3fa91f4ea9e5e961ebcf0620593948501
|
|
BLAKE2b-256 checksum How to use checksums |
1089ee0f81198771621e6dc76dd568d3c4466b129ccf8c3b7a148408bd4554bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / maxi_format-0.3.0-py3-none-any.whl
| Download URL | maxi_format-0.3.0-py3-none-any.whl |
|---|---|
| Size | 40.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fae869b23a8c1d5e2723b3fdfb56827da9e111d6d1d613722f4a1891645c5a3f
|
|
BLAKE2b-256 checksum How to use checksums |
cf8e7d09c0e18aeb39613103eb6608ee92cb7d42481d09f8a1b6975df54e0724
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for maxi-format 0.3.0
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.