Skip to main content

Verity

QuickStart

from datetime import datetime
from verity import Type, field

def parse_date(value):
    return datetime.strptime(value, '%Y-%m-%d').date()

class Person(Type):
    name = field(str)
    birthdate = field(parse_date)
>>> data = {'name': 'Bob', 'birthdate': '1980-12-21'}
>>> person = Person(data)
>>> person.birthdate
datetime.date(1980, 12, 21)

Types are nestable:

class Food(Type):
    name = field(str)
    energy = field(float)


class Person(Type):
    name = field(str)
    birthdate = field(parse_date)
    favourite_food = field(Food)
>>> data = {'name': 'Bob', 'birthdate': '1980-12-21', 'favourite_food': {'name': 'Pizza', 'energy': '1200'}}
>>> person = Person(**data)
>>> person.favourite_food.name
'Pizza'

Types can JSON-ify themselves

>>> person.__json__()
{'name': 'Bob', 'birthdate': datetime.date(1980, 12, 21), 'favourite_food': Food()}

Though it’s not recurive.

However, it can cooperate with json_default:

>>> from verity import json
>>> json.dumps(person)
'{"birthdate": "1980-12-21", "favourite_food": {"energy": 1200.0, "name": "Pizza"}, "name": "Bob"}'

Metadata

Release files for verity 0.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 verity 0.1
File Size Uploaded Provenance Actions
verity-0.1.tar.gz 3.4 kB Without provenance Details for verity-0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for verity 0.1
File Interpreter ABI Platform Actions
verity-0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for verity-0.1-py2.py3-none-any.whl

Total release size: 7.5 kB

Release files / verity-0.1.tar.gz

Download URL verity-0.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9a90bb94146f937057a10c630386f631018c77b52805ca86031d5a9ff6926b4e
BLAKE2b-256 checksum
How to use checksums
a16b6261ffeda91e4763e700cf1439038ccbc3b64f520a18f2b61e76c1205b8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / verity-0.1-py2.py3-none-any.whl

Download URL verity-0.1-py2.py3-none-any.whl
Size 4.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0366c9f644a5838064581182e180759181ee37d287fda40400bf6a52231352d9
BLAKE2b-256 checksum
How to use checksums
3cbe1f850f675102be9f8f3a4ddac90f8f5eb705fc82e5d2b74792c458faaa92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for verity 0.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

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