Skip to main content

Convert unstructured data into type-safe dataclasses.

Project description

from dataclasses import dataclass, field
from flutter import checked, check_type
from typing import List


@checked
@dataclass
class Node:
    line: int


@checked
@dataclass
class Parent(Node):
    children: List[Node] = field(default_factory=list)


assert check_type(Parent, {
    'line': 0,
    'children': [{'line': 1}]
}) == Parent(line=0, children=[Node(1)])

assert check_type(Parent, {
    'line': 10
}) == Parent(line=10, children=[])

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flutter-0.1.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

flutter-0.1-py3-none-any.whl (12.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page