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
default_factory field fails with inherited stdlib dataclass #2424
Comments
@PrettyWood What's your take on tackling this issue? AFAICS one has to dig deeper into dynamic type creation from there. |
@ahirner Please have a look at the linked PR. I forgot to add this issue to the list ;) |
Any development on this? I am currently evaluating Minimal reproduction: import dataclasses as dc
import typing as t
import pydantic
print(pydantic.utils.version_info())
@pydantic.dataclasses.dataclass
class Example:
count: int = pydantic.Field(0)
names: t.List[str] = pydantic.Field(default_factory=list)
print(Example())
@dc.dataclass
class Example:
count: int = dc.field(default=0)
names: t.List[str] = dc.field(default_factory=list)
print(Example())
Example = pydantic.dataclasses.dataclass(Example)
print(Example()) Output:
I've already confirmed that #2557 fixes this issue. Using that PR, the output is as expected:
I've further confirmed that the snippet in the original post runs successfully with the PR but fails on published Pydantic 1.9.0. |
@troiganto looks like this is still an issue. I'll be something deep in the way we convert dataclasses. |
@samuelcolvin #2557 fixes this issue. I'll try to work again on this so we can merge it for v1.10 |
Checks
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:dataclasses
tries to deletey
attribute which isn't set.Also fails on
1.7.1
but not on1.7
. Any ideas? I'd be happy to author a fix.The text was updated successfully, but these errors were encountered: