Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dmfigol opened this Issue Sep 4, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@dmfigol
Copy link

dmfigol commented Sep 4, 2018

  • 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.

@dmfigol dmfigol changed the title Bug: ignore_extra=False and allow_population_by_alias do not work together Bug: ignore_extra=False and allow_population_by_alias=True do not work together Sep 4, 2018

@samuelcolvin

This comment has been minimized.

Copy link
Owner

samuelcolvin commented Sep 4, 2018

This is exactly what you would expect unless I'm missing something.

@samuelcolvin

This comment has been minimized.

Copy link
Owner

samuelcolvin commented Sep 4, 2018

Oh, I missed allow_population_by_alias.

I guess this is wrong but I think that setting is dumb anyway, maybe we shouldn't have included it.

@samuelcolvin samuelcolvin reopened this Sep 4, 2018

@samuelcolvin samuelcolvin added the bug label Sep 11, 2018

samuelcolvin added a commit that referenced this issue Dec 29, 2018

samuelcolvin added a commit that referenced this issue Dec 29, 2018

@samuelcolvin samuelcolvin referenced this issue Dec 29, 2018

Merged

fix allow_population_by_alias #346

3 of 4 tasks complete

samuelcolvin added a commit that referenced this issue Dec 29, 2018

fix allow_population_by_alias (#346)
* fix allow_population_by_alias, fix #257

* update history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.