Skip to content

Error construct schema for ListAttribute without of #2

@askerka

Description

@askerka

Hi!
There is a problem with ListAttribute():

from pynamodb.models import Model
from marshmallow_pynamodb import ModelSchema


class User(Model):
    nick_names = ListAttribute()


class UserSchema(ModelSchema):
    class Meta:
        model = User
/marshmallow_pynamodb/schema.py", line 39, in get_declared_fields
    element_type = type(attribute.element_type.__name__, (ModelSchema, ), {'Meta': Meta})
AttributeError: 'NoneType' object has no attribute '__name__'

It is understandable that is not so much sense for schema with list without type specification but it is valid model and possible use case.

So it seems two way to handle this issue. First option is forbid create list attribute without specifying type and second is handle this situation and create schema and validate only container type.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions