Skip to content
/ Spec Public

A statically typed data structure validator with support for advance features

License

Notifications You must be signed in to change notification settings

Zomatree/Spec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spec

PyPI - Version

A statically typed data structure validator with support for advance features.


Table of Contents

Installation

$ pip install git+https://github.com/zomatree/spec

Usage

A simple class

class MyModel(spec.Model):
    a: int
    b: str

foo = MyModel({"a": 1, "b": "bar"})

print(foo.a)
print(foo.b)

Nested classes

class Inner(spec.Model):
    v: int

class Outer(spec.Model):
    inner: Inner
    other: str

data = Outer({"inner": {"v": 1}, "other": "foo"})

Renaming

from typing import Annotated

class MyModel(spec.Model):
    my_foo = Annotated[int, spec.rename("myFoo")]

data = MyModel({"myFoo": 1})

License

spec is distributed under the terms of the MIT license.

About

A statically typed data structure validator with support for advance features

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages