Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Latest commit

 

History

History
35 lines (21 loc) · 690 Bytes

README.md

File metadata and controls

35 lines (21 loc) · 690 Bytes

strictus

A much tested rewrite of strictus-dictus (github repo) which does not extend dict.

Installation

pip install strictus

Usage

from typing import List

from strictus.core import strictus, strictus_field


class Item(strictus):
    id: str
    name: str


class ItemList(strictus):
    items: List[Item] = strictus_field(default_factory=list)


item_list = ItemList({"items": [{"id": 1, "name": "first"}]})
print(item_list.items[0].name)  # prints "first"
print(item_list.to_dict())  # prints "{'items': [{'id': '1', 'name': 'first'}]}"