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

fix: pydantic dataclass can inherit from stdlib dataclass and arbitrary_types_allowed is supported #2051

Merged
merged 4 commits into from
Oct 28, 2020

Conversation

PrettyWood
Copy link
Member

@PrettyWood PrettyWood commented Oct 27, 2020

Change Summary

#1817 introduced a regression when pydantic dataclass inherits from a stdlib dataclass.
This fixes the expected behaviour. Some extra documentation has also been added.

Related issue number

closes #2042
closes #2054

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)

@PrettyWood PrettyWood changed the title Fix/dataclass inheritance fix: pydantic dataclass can inherit from stdlib dataclass Oct 27, 2020
@codecov
Copy link

codecov bot commented Oct 27, 2020

Codecov Report

Merging #2051 into master will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #2051   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         4094      4096    +2     
  Branches       821       821           
=========================================
+ Hits          4094      4096    +2     
Impacted Files Coverage Δ
pydantic/dataclasses.py 100.00% <100.00%> (ø)
pydantic/validators.py 100.00% <100.00%> (ø)
pydantic/fields.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95435de...b4cd195. Read the comment docs.

@PrettyWood PrettyWood changed the title fix: pydantic dataclass can inherit from stdlib dataclass fix: pydantic dataclass can inherit from stdlib dataclass and arbitrary_types_allowed is supported Oct 27, 2020
Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM.

@@ -57,6 +57,14 @@ them with `pydantic.dataclasses.dataclass`.
```
_(This script is complete, it should run "as is")_

Stdlib dataclasses (nested or not) can also be inherited and _pydantic_ will automatically validate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also add a comment about the arbitrary_types_allowed logic change since that now behaves different from nested pydantic dataclasses or next pydantic models.

@samuelcolvin
Copy link
Member

Just waiting on this (and #2046 which I can tweak) before releasing v1.7.1, if you're okay with that?

@PrettyWood
Copy link
Member Author

PrettyWood commented Oct 28, 2020

Just waiting on this (and #2046 which I can tweak) before releasing v1.7.1, if you're okay with that?

Yes perfect! I'm adding documentation right now. I feel like #2055 should also be part of v1.7.1 since it fixes typing issues from #1663
EDIT : @samuelcolvin done! I added also some subsections in the doc! Feel free to tweak it 👍

@samuelcolvin samuelcolvin merged commit 0b9cd4e into pydantic:master Oct 28, 2020
@PrettyWood PrettyWood deleted the fix/dataclass_inheritance branch December 17, 2020 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants