Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python template fails when using kwargs only #8

Open
gadostal-swordfish opened this issue Jan 11, 2021 · 0 comments
Open

Python template fails when using kwargs only #8

gadostal-swordfish opened this issue Jan 11, 2021 · 0 comments

Comments

@gadostal-swordfish
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant