mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
0b9cd4e537
* fix: pydantic dataclasses can inherit from stdlib dataclasses closes #2042 * docs: add some documentation * fix: support arbitrary_types_allowed with stdlib dataclass closes #2054 * docs: add documentation for custom types
28 lines
310 B
Python
28 lines
310 B
Python
import dataclasses
|
|
|
|
import pydantic
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class Z:
|
|
z: int
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class Y(Z):
|
|
y: int = 0
|
|
|
|
|
|
@pydantic.dataclasses.dataclass
|
|
class X(Y):
|
|
x: int = 0
|
|
|
|
|
|
foo = X(x=b'1', y='2', z='3')
|
|
print(foo)
|
|
|
|
try:
|
|
X(z='pika')
|
|
except pydantic.ValidationError as e:
|
|
print(e)
|