最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - pydantic version update : Field defined on a base class was overridden by a non-annotated attribute - Stack Overflow

programmeradmin1浏览0评论

I updated the pydantic version and code is breaking with the error

Field 'allowed_type' defined on a base class was overridden by a non-annotated attribute. All field
definitions, including overrides, require a type
annotation.

class AllowedType(str, Enum):
    YES = "YES"
    NO = "NO"
class APIResponse(BaseModel):
    allowed_type: AllowedType
    def to_json(self):
        return json.dumps(
            {
                "allowed_type": self.allowed_type,
            }
        )

None of the solutions mentioned here work for me : /2.6/errors/usage_errors/#model-field-overridden

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论