Skip to content

Python template fails when using kwargs only #8

@gadostal-swordfish

Description

@gadostal-swordfish

Template is here

    def __init__(self, data=None, **kwargs):
        """Initialization for the {{Name}} object.
        It can be initialized with an object, or by passing each
        object property as a keyword argument.
        """
        new_data = {}
        {%-for propName, propSchema in schema.properties.items()%}
        try:
            prop = data["{{propName}}"] if ("{{propName}}" in data) else kwargs["{{propName}}"]

The last line should read:

            prop = data["{{propName}}"] if (data is not None and "{{propName}}" in data) else kwargs["{{propName}}"]

Otherwise when data is None, it will fail every time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions