Python 3.7 dataclasses
See original GitHub issueI don’t know if this is supposed to work. Would be nice. I can try to fix it if you propose the way.
@dataclasses.dataclass
class C(pydantic.BaseModel):
i:int
c = C(1)
....
RecursionError: maximum recursion depth exceeded
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:19 (7 by maintainers)
Top Results From Across the Web
dataclasses — Data Classes — Python 3.11.1 documentation
The dataclass() decorator examines the class to find field s. A field is defined as a class variable that has a type annotation....
Read more >Data Classes in Python 3.7+ (Guide)
Data classes are one of the new features of Python 3.7. With data classes you do not have to write boilerplate code to...
Read more >The Ultimate Guide to Data Classes in Python 3.7
Data Class is a new concept introduced in Python 3.7 version. You can use data classes not only as a knowledge container but...
Read more >dataclasses — Data Classes — Stackless-Python 3.7.9 ...
This function is a decorator that is used to add generated special methods to classes, as described below. The dataclass() decorator examines ...
Read more >Python Dataclasses - Python Cheatsheet
Dataclasses are python classes, but are suited for storing data objects. This module provides a decorator and functions for automatically adding generated ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Proposal:
pydantic adds a decorator to validate dataclasses input data and equivalently it’s own version of
dataclass
which performs the same as normal dataclasses except for validating input data.Something like:
@Gaunt @pawelswiecki, if this was achievable, would be work for you?
This would require a significant rewrite of pydantic, but I think it would be worth it to support a big new language feature.
I disagree on the point about data classes: I don’t think it will get rich serialization and validation in the core. The standard library is very conservative.
—Paul