Skip to main content

Usage

You can use inheritance to create your model:

class User(modeller.Model):
    id = ''
    _schema = {
        'type': 'object',
        'properties': {
            'name': { 'type': 'string' },
            'id': { 'type': 'integer' },
            'age': { 'type': 'integer' },
        },
        'required': [
            'name',
            'surname',
        ],
        # 'additionalProperties': False,
    }

# model will be validated after every instance
me = User(id=01, name='Tommy', surname='Der')

# you can also add additional properties
me.state = 'Italy'
me._validate()

print(me._json())

print(me._yaml())

print(me.surname)

With the schema in types/schema.yaml

$schema: http://json-schema.org/schema#
properties:
  name:
    type: string
  surname:
    type: string
  age:
    type: integer
required:
  - name
  - surname
  - age

you can load a model with automatic validation, easy attribute access with dots and no exceptions while trying to access a property defined in the schema.

import yaml
import modeler

schema = yaml.load(open('types/schema.yaml').read())

Model = modeler.make_model(schema=schema,)

Model(name='Tommaso', surname='De Rossi', age=19)

Details

Model validate itself as soon as instantiated, if you want to change this behavior overwrite _on_init method. Model will return None if you try to access a property present in the json schema .properties but not in the object. Model will throw if you try to access a property not present in the object and not in the json schema .properties.

Metadata

Release files for modeller 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modeller 0.1.1
File Size Uploaded Provenance
modeller-0.1.1.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for modeller 0.1.1
File Interpreter ABI Platform
modeller-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / modeller-0.1.1.tar.gz

Download URL modeller-0.1.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
42ae688e511826c45a02f05c50dbecd3647b78c5c988a7ff97ad0c3ad58e8cf8
BLAKE2b-256 checksum
How to use checksums
d460a48392d8d95ed1c4493f6d4709e71ceab3a9e5720b990d9b32f6084daebe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / modeller-0.1.1-py3-none-any.whl

Download URL modeller-0.1.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eabdf9773b64d05aa4bd8f9485980cef76d42e37dab3fd225819f1c53b056911
BLAKE2b-256 checksum
How to use checksums
9c428a4db7febcfedee4e0cfb6335e06a92dfb0915553b722295a1a7fd931bf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Security for modeller 0.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page