Skip to content

Commit

Permalink
fix: when there are no schema properties, we add 'pass' to the constr…
Browse files Browse the repository at this point in the history
…uctor (#85)

* fix: when there are no schema properties, we add 'pass' to the schema's constructor.

* Made formatting of template vars more consistent.
  • Loading branch information
damaru-inc committed Oct 20, 2021
1 parent d0a3b60 commit d58553d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions partials/model-class
Expand Up @@ -5,7 +5,7 @@
{% set indent3 = indentLevel | indent3 -%}
{% set indent4 = indentLevel | indent4 -%}

{{ indent1 }}class {{name | upperFirst}}(Entity):
{{ indent1 }}class {{ name | upperFirst }}(Entity):
{% for name, prop in properties -%}
{%- set typeInfo = [name, prop] | getTypeInfo -%}
{%- if typeInfo.recursive -%}
Expand All @@ -17,18 +17,19 @@
{% endfor -%}
{%- endif %}
{%- endfor %}
{{indent2}}def __init__(
{{ indent2 }}def __init__(
{{ indent4 }}self
{%- for name, prop in properties -%}
{%- set typeInfo = [name, prop] | getTypeInfo -%}
,
{{ indent4 }}{{typeInfo.pythonName}}{{ ": " + typeInfo.pythonType if typeInfo.pythonType else ""}}
{{ indent4 }}{{ typeInfo.pythonName }}{{ ": " + typeInfo.pythonType if typeInfo.pythonType else "" }}
{%- endfor -%}
):
{%- for name, prop in properties -%}
{%- set typeInfo = [name, prop] | getTypeInfo %}
{{ indent3}}self.{{typeInfo.pythonName}} = {{typeInfo.pythonName}}
{{ indent3 }}self.{{ typeInfo.pythonName }} = {{ typeInfo.pythonName }}
{%- else %}
{{ indent3 }}pass
{%- endfor %}


{% endmacro -%}

0 comments on commit d58553d

Please sign in to comment.