Conversation
Deploying with
|
| Latest commit: |
c1766c0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://600858b6.pydantic-docs2.pages.dev |
| Branch Preview URL: | https://dataclass-docs.pydantic-docs2.pages.dev |
|
please review |
ybressler
left a comment
There was a problem hiding this comment.
Thank you for going through the documentation! Your changes are scrupulous.
I left some comments + requested changes related to style + grammar. Overall, looks really good.
Co-authored-by: Yaakov Bressler <40807730+ybressler@users.noreply.github.com>
|
please review |
ybressler
left a comment
There was a problem hiding this comment.
Looks good! I have one small change about one word ;)
Also, one outstanding thread about how to resolve potential confusion with model_config for basemodels and config for dataclasses. Pending resolution, we should be good to go!
Co-authored-by: Yaakov Bressler <40807730+ybressler@users.noreply.github.com>
…into dataclass-docs
|
Please review |
| Pydantic dataclasses do not support [`extra='allow'`](model_config/#extra-attributes), where extra fields passed | ||
| to the initializer would be stored as extra attributes on the dataclass. |
There was a problem hiding this comment.
Hi @tpdorsey! Could you help me understand what you meant by this diff? It looks to me like the current support for extra="allow" is the same as it was after #2557 (the PR where the removed copy was introduced), but I'm wondering if I'm missing something.
With extra="allow", extra values passed to __init__ still end up in the instantiated object, but just aren't surfaced via __str__. Example script:
from pydantic.dataclasses import dataclass
@dataclass(config=dict(extra="allow"))
class Example:
...
obj = Example(a=1, b=2)
print(obj)
print(f"Extra: a={obj.a}, b={obj.b}")This script yields the following output when running with the latest pydantic==2.3.0:
Example()
Extra: a=1, b=2
There was a problem hiding this comment.
Hey, Could you please make an issue or ask this in a GitHub discussion?
There was a problem hiding this comment.
Thanks for the quick response, @hramezani — opened #7362 to discuss.
Change Summary
Related issue number
Closes PYD-54
Checklist
changes/<pull request or issue id>-<github username>.mdfile added describing change(see changes/README.md for details)
Selected Reviewer: @davidhewitt