Skip to main content

type-annotations-generator provides a function for generating type annotations for a object

Project description

type-annotations-generator

type-annotations-generator provides a function for generating type annotations. That can be useful if you work with a API which has a complex data structure. It supports PEP 585 and PEP 604.

import type_annotations_generator

data = {
    "elements": [
        {
            "name": "foo",
            "age": 42
        }
    ],
    "count": 1
}

print(type_annotations_generator.generate_annotations(data))
# Dict[str, Union[List[Dict[str, Union[str, int]]], int]]

print(type_annotations_generator.generate_annotations(data, pep_585=True))
# dict[str, Union[list[dict[str, Union[str, int]]], int]]

print(type_annotations_generator.generate_annotations(data, pep_585=True, pep_604=True))
# dict[str, list[dict[str, str | int]] | int]

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

type-annotations-generator-1.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

type_annotations_generator-1.0-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

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