# Type definitions

> [Index](../README.md) > [{{ service_name.class_name }}](./README.md) > Type definitions

{% include "common/header_note.md.jinja2" with context %}

{% for named_union in package.iterate_named_unions() -%}

## {{ named_union.name }}

```python
# {{ named_union.name }} Union usage example

from {{ package.name }}.type_defs import {{ named_union.name }}


def get_value() -> {{ named_union.name }}:
    return ...


# {{ named_union.name }} definition

{{ named_union.name }} = Union[
{% for child in named_union.iterate_children() -%}
    {% with type_annotation=child -%}
        {{ '    ' -}}
        {% include "common/type_annotation_code.md.jinja2" with context -%}
        {{ ',' -}}
        {% if child in named_union.type_hint_annotations -%}
            {{ '  # (' -}}{{ named_union.type_hint_annotations.index(child) + 1 -}}{{ ')' -}}
        {% endif -%}
    {% endwith -%}
    {{ '\n' -}}
{% endfor -%}
{{ ']\n' -}}
```

{% for type_annotation in named_union.type_hint_annotations -%}
{{ loop.index -}}{{ '. See ' -}}
{% include "common/type_hint.md.jinja2" with context -%}
{{ '\n' -}}
{% endfor -%}
{{ '\n' -}}

{% endfor %}

{% for typed_dict in package.iterate_typed_dicts() -%}
## {{ typed_dict.name }}

```python
# {{ typed_dict.name }} TypedDict usage example

from {{ package.name }}.type_defs import {{ typed_dict.name }}


def get_value() -> {{ typed_dict.name }}:
    return {
        "{{ typed_dict.children[0].name -}}": ...,
    }


# {{ typed_dict.name }} definition

class {{ typed_dict.name }}(TypedDict):
{% for child in typed_dict.iterate_children() -%}
    {{ '    ' -}}{{ child.name -}}{{ ': ' -}}
    {% with type_annotation=child.get_type_annotation() -%}
        {% include "common/type_annotation_code.md.jinja2" with context -%}
        {{ ',' -}}
        {% if child.type_annotation in typed_dict.type_hint_annotations -%}
            {{ '  # (' -}}{{ typed_dict.type_hint_annotations.index(child.type_annotation) + 1 -}}{{ ')' -}}
        {% endif -%}
    {% endwith -%}
    {{ '\n' -}}
{% endfor -%}
```

{% for type_annotation in typed_dict.type_hint_annotations -%}
{{ loop.index -}}{{ '. See ' -}}
{% include "common/type_hint.md.jinja2" with context -%}
{{ '\n' -}}
{% endfor -%}

{% endfor %}
