File: msgspec.jinja2

package info (click to toggle)
python-datamodel-code-generator 0.26.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: python: 9,525; makefile: 14
file content (42 lines) | stat: -rw-r--r-- 1,174 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{% for decorator in decorators -%}
{{ decorator }}
{% endfor -%}
{%- if base_class %}
class {{ class_name }}({{ base_class }}{%- for key, value in (base_class_kwargs|default({})).items() -%}
, {{ key }}={{ value }}
{%- endfor -%}):
{%- else %}
class {{ class_name }}:
{%- endif %}
{%- if description %}
    """
    {{ description | indent(4) }}
    """
{%- endif %}
{%- if not fields and not description %}
    pass
{%- endif %}
{%- for field in fields -%}
    {%- if not field.annotated and field.field %}
    {{ field.name }}: {{ field.type_hint }} = {{ field.field }}
    {%- else %}
    {%- if field.annotated and not field.field %}
    {{ field.name }}: {{ field.annotated }}
    {%- elif field.annotated and field.field %}
    {{ field.name }}: {{ field.annotated }} = {{ field.field }}
    {%- else %}
    {{ field.name }}: {{ field.type_hint }}
    {%- endif %}
    {%- if not field.field and (not field.required or field.data_type.is_optional or field.nullable)
            %} = {{ field.represented_default }}
    {%- endif -%}
    {%- endif %}



    {%- if field.docstring %}
    """
    {{ field.docstring | indent(4) }}
    """
    {%- endif %}
{%- endfor -%}