Skip to content

Bug: ignore_extra=False and allow_population_by_alias=True do not work together #257

@dmfigol

Description

@dmfigol
  • OS: macOS
  • Python version import sys; print(sys.version): 3.6.6
  • Pydantic version import pydantic; print(pydantic.VERSION): 0.13

Code snippet:

from pydantic import BaseModel, Schema
from typing import Optional

class Model(BaseModel):
    last_updated_by: Optional[str] = Schema(None, alias="lastUpdatedBy")

    class Config:
        ignore_extra = False
        allow_population_by_alias = True

m1 = Model(lastUpdatedBy="dmitry") # ok
m2 = Model(last_updated_by="dmitry") # fails

# >
"""
ValidationError: 1 validation error
last_updated_by
  extra fields not permitted (type=value_error.extra)
"""

Additional info: read docs, including the warning, but it does not seem like this is an expected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions