The workspace tree has folders with a parent and a created timestamp. Since parent was added to FolderSchema, creating the schema fails. Renaming the field to anything else makes the error go away, which is not an option…
The workspace tree has folders with a parent and a created timestamp. Since parent was added to FolderSchema, creating the schema fails. Renaming the field to anything else makes the error go away, which is not an option for a public API.
import datetime as dt
from marshmallow import Schema, fields
class FolderSchema(Schema):
parent = fields.String()
created = fields.DateTime()
FolderSchema().dump({"parent": "root", "created": dt.datetime(2019, 8, 21, 14, 30)})
{"parent": "root", "created": "2019-08-21T14:30:00"}
AttributeError: 'NoneType' object has no attribute 'opts'
parent, whatever its type, and the schema must behave as it does with any other field name.Meta.datetimeformat, Meta.dateformat), also when they sit inside a List, Tuple or Dict, and also inside a nested schema that has a parent field of its own.parent work today and must keep working.Adapted from marshmallow-code/marshmallow (MIT).
Visible test command
pytest testsThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
field-named-parent-crashes-schema
Changes under src/ are evaluated.