Skip to main content
https://github.com/avanov/typeit/workflows/CI/badge.svg?branch=develop https://coveralls.io/repos/github/avanov/typeit/badge.svg?branch=develop Requirements Status Documentation Status Latest PyPI Release

Typeit

typeit infers Python types from a sample JSON/YAML data, and provides you with the tools for serialising and parsing it. It also provides you with smart constructors for arbitrarily nested data structures. The library works superb on Python 3.7 and above.

Start using it by generating types for your JSON payloads:

$ echo '{"first-name": "Hello", "initial": null, "last_name": "World"}' | typeit gen

The snipped above produces output similar to this:

from typing import Any, NamedTuple, Optional, Sequence
from typeit import TypeConstructor


class Main(NamedTuple):
    first_name: str
    initial: Optional[Any]
    last_name: str


overrides = {
    Main.first_name: 'first-name',
}


mk_main, serialize_main = TypeConstructor & overrides ^ Main

Use these functions to construct and serialize your payloads:

payload = {"first-name": "Hello", "initial": None, "last_name": "World"}

data = mk_main(payload)
assert isinstance(data, Main)
assert serialize_main(data) == payload

Documentation

Documentation is hosted on ReadTheDocs: https://typeit.readthedocs.io/en/develop/

Test framework

Run existing test suite with

$ make test

Changelog

See CHANGELOG.

Metadata

Release files for typeit 3.11.1.3

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

Source distribution (sdist)

Source distribution for typeit 3.11.1.3
File Size Uploaded
typeit-3.11.1.3.tar.gz 30.6 kB Details

Built distribution (wheel)

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

Total release size: 66.0 kB

Release files / typeit-3.11.1.3.tar.gz

Download URL typeit-3.11.1.3.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
585bdb5d7b13a82ff3d842538b960e4b1f445d0c9c90863a2aec942d85600549
BLAKE2b-256 checksum
How to use checksums
4fc24453e98dd624feaa2f19aedb907701acc7024692f2dcf83df125bd5b7ba1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / typeit-3.11.1.3-py3-none-any.whl

Download URL typeit-3.11.1.3-py3-none-any.whl
Size 35.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71df66c6d840f966ca25b2dbf643826d228b5ecb727de6ea174148daba71d45c
BLAKE2b-256 checksum
How to use checksums
5eb917236686e661428cc1a3a71b54b38cf338b261d892d93641dc1b2c37d3c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

3.11.1.3 This release

2 release files

0.27.2

2 release files

0.27.1

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

3 release files

0.1.0

2 release files

0.0.1

2 release files

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