관리-도구
편집 파일: dataclasses.cpython-311.pyc
� ���ekD � �p � d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m Z mZmZm Z mZmZmZmZmZmZ ddlmZ ddlmZ dd lmZmZmZmZ dd lmZ ddlm Z ddl!m"Z"m#Z#m$Z$m%Z% dd l&m'Z'm(Z( ddl)m*Z* e r8ddl&m+Z+ ddlm,Z,m-Z- edd�� � Z.eed df Z/ G d� d� � Z0g d�Z1 ed� � Z2ej3 dk r� eej4 e"f�� � eddddddddddd� de5de5d e5d!e5d"e5d#e5d$eeee6 df d%ee5 d&ee5 d'e5d(eee2 gd)f fd*�� � � � Z7 eej4 e"f�� � eddddddddddd� d+ee2 de5de5d e5d!e5d"e5d#e5d$eeee6 df d%ee5 d&ee5 d'e5d(d)fd,�� � � � Z7n� eej4 e"f�� � edddddddddd-� de5de5d e5d!e5d"e5d#e5d$eeee6 df d%ee5 d&ee5 d(eee2 gd)f fd.�� � � � Z7 eej4 e"f�� � edddddddddd-� d+ee2 de5de5d e5d!e5d"e5d#e5d$eeee6 df d%ee5 d&ee5 d(d)fd/�� � � � Z7 eej4 e"f�� � dDddddddddddd� d+eee2 de5de5d e5d!e5d"e5d#e5d$eeee6 df d%ee5 d&ee5 d'e5d(eeee2 gd)f d)f fd0�� � Z7ed1ed d2e5d(eed ddf fd3�� � Z8 G d4� d� � Z9d5ed d$ee d%e5d6e:d(df d7�Z;dEd9�Z<d1ed d:e d(dfd;�Z=edfd5ed d$ee d6ee: d(ed< fd=�Z>dFd?�Z?d>dd@e:d2e d(dfdA�Z@d+ee d(e5fdB�ZAd5ed d$ee d(d8fdC�ZBdS )GaX The main purpose is to enhance stdlib dataclasses by adding validation A pydantic dataclass can be generated from scratch or from a stdlib one. Behind the scene, a pydantic dataclass is just like a regular one on which we attach a `BaseModel` and magic methods to trigger the validation of the data. `__init__` and `__post_init__` are hence overridden and have extra logic to be able to validate input data. When a pydantic dataclass is generated from scratch, it's just a plain dataclass with validation triggered at initialization The tricky part if for stdlib dataclasses that are converted after into pydantic ones e.g. ```py @dataclasses.dataclass class M: x: int ValidatedM = pydantic.dataclasses.dataclass(M) ``` We indeed still want to support equality, hashing, repr, ... as if it was the stdlib one! ```py assert isinstance(ValidatedM(x=1), M) assert ValidatedM(x=1) == M(x=1) ``` This means we **don't want to create a new dataclass that inherits from it** The trick is to create a wrapper around `M` that will act as a proxy to trigger validation without altering default `M` behaviour. � N)�contextmanager)�wraps)� TYPE_CHECKING�Any�Callable�ClassVar�Dict� Generator�Optional�Type�TypeVar�Union�overload)�dataclass_transform� )�gather_all_validators)� BaseConfig� ConfigDict�Extra� get_config)�ValidationError)�DataclassTypeError)�Field� FieldInfo�Required� Undefined)�create_model�validate_model)�ClassAttribute)� BaseModel)�CallableGenerator�NoArgAnyCallable� DataclassT� Dataclass)�bound�DataclassProxyc � � e Zd ZU eeeef ed<