我正在使用python,尝试使用marshmallow
和marshmallow-dataclass
为我的数据类创建数据模式。我相信我已经遵循了文档,将修饰符添加到相关的数据类中,并将NewType
添加到非标准python对象的字段中。但是,在加载程序之前我遇到了一个错误。
错误与str
不是数据类有关,我也不知道装饰器如何处理字符串而不是数据类。
我敢肯定,我错过了一些简单的事情,如果是这样,请提前道歉。
该代码的摘要版本为:
from marshmallow_dataclass import dataclass as m_dataclass, NewType
ProjectileDataType = NewType("ProjectileDataType", Any)
@m_dataclass
class ProjectileData:
Schema: ClassVar[Type[Schema]] = Schema
# what created it?
skill_name: str = field(default="None")
# what does it look like?
sprite: str = field(default="None")
defintions.py:https://pastebin.com/tHnVE2Gc 错误回溯:https://pastebin.com/htuqhKSU 文件:https://github.com/lovasoa/marshmallow_dataclass,https://marshmallow.readthedocs.io/en/stable/quickstart.html