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

'null' extra fields not permitted #560

Closed
matecsaj opened this issue Oct 10, 2022 · 2 comments · Fixed by #603
Closed

'null' extra fields not permitted #560

matecsaj opened this issue Oct 10, 2022 · 2 comments · Fixed by #603
Labels
bug Something isn't working

Comments

@matecsaj
Copy link

matecsaj commented Oct 10, 2022

Describe the bug
In PyCharm's "Problems" pane.
'null' extra fields not permitted :16

To Reproduce

from pydantic import BaseModel, Extra


class Exclusive(BaseModel, extra=Extra.forbid):
    foo: str | None = None
    bar: str | None = None


class Inclusive(BaseModel):
    foo: str | None = None
    bar: str | None = None


params = {'foo': 'one', 'bar': 'two'}

exclusive1 = Exclusive(**params)
exclusive2 = Exclusive(foo='three', bar='four')
print(f"{exclusive1}\n{exclusive2}")


inclusive1 = Inclusive(**params)
inclusive2 = Inclusive(foo='three', bar='four')
print(f"{inclusive1}\n{inclusive2}")

/Users/matecsaj/Documents/Projects/nugget_spiders/venv/bin/python /Users/matecsaj/Library/Application Support/JetBrains/PyCharm2022.2/scratches/scratch.py 
foo='one' bar='two'
foo='three' bar='four'
foo='one' bar='two'
foo='three' bar='four'

Process finished with exit code 0

Expected behavior
Nothing in the "Problems" pane.

Screenshots
Screen Shot 2022-10-10 at 12 03 45 PM

Environments

  • IDE: [PyCharm 2022.2.2 (Professional Edition)] [Build #PY-222.4167.33, built on September 15, 2022]
  • OS: [macOS 10.15.7]
  • Pydantic Version [0.3.13 Jul. 27, 2022]
  • Plugin version [e.g. 0.3.11 ]

Additional context
In Pycharm
Preferences - Plugins
I searched for Pydantic and then installed the only plugin in the list.

@matecsaj
Copy link
Author

matecsaj commented Oct 10, 2022

FYI, I studied some sample code located with Google and found a workaround.
exclusive1 = Exclusive.parse_obj(params)

Is my original code in error, or is the pydantic plugin?

@koxudaxi koxudaxi added the bug Something isn't working label Dec 12, 2022
@koxudaxi
Copy link
Owner

@matecsaj
I'm sorry for my late reply.
I have released the fixed version.
Thank you very much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants