Skip to content

Problem with inheritance and Config.fields #55

@samuelcolvin

Description

@samuelcolvin
from pydantic import BaseModel


class Foo(BaseModel):
    a: int


class Bar(Foo):
    b: str

    class Config:
        fields = {
            'a': 'aaa',
            'b': 'bbb',
        }


print(Bar(aaa=1, bbb='s'))

Doesn't work.

  1. should give explicit error if fields which aren't defined are referenced in Config.fields
  2. should allow aliases for fields in inherited models.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions