Skip to main content

Slotomania

Project description

codecov pyup

Slotomania

A code generator that transforms schemas to Python slot classes and typescript interfaces

Examples

from slotomania.contrib.marshmallow_converter import (
    schemas_to_slots,
)
class Eye(Schema):
    color = fields.String(required=True)


class Head(Schema):
    hair = fields.String(requried=True)


class Body(Schema):
    eyes = fields.List(fields.Nested(Eye()), required=True)
    mouth = fields.Decimal(required=True)
    poo = fields.Float(required=True)
    foot = fields.DateTime(required=True)
    head = fields.Nested(Head(), required=True)

assert format_python_code(schemas_to_slots([
    Eye(),
    Head(),
    Body(),
])) == format_python_code("""
from slotomania.core import Sloto
import datetime
import decimal
import typing

class Eye(Sloto):
    __slots__ = ['color']
    def __init__(
        self,
        color: str,
    ) -> None:

        self.color = color


class Head(Sloto):
    __slots__ = ['hair']
    def __init__(
        self,
        hair: str = None,
    ) -> None:

        self.hair = hair


class Body(Sloto):
    __slots__ = ['eyes', 'foot', 'head', 'mouth', 'poo']
    def __init__(
        self,
        eyes: typing.List[Eye],
        foot: datetime.datetime,
        head: Head,
        mouth: decimal.Decimal,
        poo: float,
    ) -> None:

        self.eyes = eyes
        self.foot = foot
        self.head = head
        self.mouth = mouth
        self.poo = poo
        """
        )

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

slotomania-0.0.5-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file slotomania-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for slotomania-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 107214f62a6185b770a77b790bf6c9e7233932af0b1f2dd3a1f32127a0bcddbb
MD5 aa15653484f7a64dec2eab9c052f9e2e
BLAKE2b-256 69f86f6633fc1cccf309ed177513f48a07bc208e7fd5b17e3eb5a8de821b2499

See more details on using hashes here.

Supported by

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