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

False positive detection of "extra fields not permitted" #367

Closed
finswimmer opened this issue Sep 6, 2021 · 1 comment
Closed

False positive detection of "extra fields not permitted" #367

finswimmer opened this issue Sep 6, 2021 · 1 comment
Labels

Comments

@finswimmer
Copy link

Describe the bug
When a subclass of a BaseModel sets extra=forbid all attributes of the parent class are marked as "not permitted" on initialization.

To Reproduce

from pydantic import BaseModel, Extra


class A(BaseModel):
    id: int


class B(A):
    data: List[int]
    
    class Config:
        extra = Extra.forbid


d = B(id=1, data=[1,2,3])

id is now reported as: 'id' extra fields not permitted

Expected behavior
Attributes inherited from parent class should not be reported as "not permitted"

Screenshots
image

Environments (please complete the following information):

  • IDE: PyCharm 2020.2.1
  • OS: Ubuntu 18.04, Windows 10
  • Pydantic Version: 1.8.2
  • Plugin version: 0.3.5

Additional context
Reporting detection of not permitted extra fields was introduced by #324 I guess inheritance wasn't considered.

Thanks a lot for this wonderful plugin 😃

@koxudaxi
Copy link
Owner

@finswimmer
I'm sorry that I forget to say the fixed version had been released 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants