HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/pydantic/v1/__pycache__/_hypothesis_plugin.cpython-310.pyc
o

|��g�9�@sUdZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
mZddlmZddlZddlZddlZddlmZzddlZWn	eyTYn-wdedefdd	�Ze�eje���e��e�ej e�!d
j"ej#ddd
�e���e���e�ej$e�%dd�e&e'e��D���d�(ej)j*ej)j+ej)j,ej)j-ej)j.ej)j/f��0ej)j1d��0ej)j2d��0ej)j3d�Z4e�ej)j5e�6e�%e&ej)j7��e�8e�9dd�e�9dd�e�9dd�e�:�e�;dd�Be�;dd��<dj"�B�ej#e4dd
���dedefdd�Z=dZ>e�ej?ej#d�(e>�dd
��<e=��e�ej@ejAdd��e�ejBejAdd��e�ejCejAdd��e�ejDejAdd��e�ejEe�F��<ejE��e�ejGe�H��<ejG��e�ejIe�J��e�ejKe�LejM�e�LejN�B�e�ejOe�LejP�e�LejQ�B�e�ejRe�S��e�ejTe�H��e�ejUejVejW�X�ejYdd �d!��e�ejZejVejW�X�ejYdd �d"��iZ[e
e\e	e\gej]ffe^d#<ed$eej_j`deej_j`fd%d&��Zaed$ej_jbdej_jbfd'd&��Zad$eeej_j`ej_jbfdeeej_j`ej_jbffd(d&�Zad$ee\ej_jbfde	e	d)ej]fge	d)ej]fffd*d+�Zcecejd�d,d-��Zeecejf�d.d/��Zgecejh�d0d1��Ziecejj�d2d3��Zkecejl�d4d5��Zmecejn�d6d7��Zoecejp�d8d9��Zqerej_js�D]Zteaet��qteaej__ae�ejuee�dS):a�
Register Hypothesis strategies for Pydantic custom types.

This enables fully-automatic generation of test data for most Pydantic classes.

Note that this module has *no* runtime impact on Pydantic itself; instead it
is registered as a setuptools entry point and Hypothesis will import it if
Pydantic is installed.  See also:

https://hypothesis.readthedocs.io/en/latest/strategies.html#registering-strategies-via-setuptools-entry-points
https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.register_type_strategy
https://hypothesis.readthedocs.io/en/latest/strategies.html#interaction-with-pytest-cov
https://docs.pydantic.dev/usage/types/#pydantic-types

Note that because our motivation is to *improve user experience*, the strategies
are always sound (never generate invalid data) but sacrifice completeness for
maintainability (ie may be unable to generate some tricky but valid data).

Finally, this module makes liberal use of `# type: ignore[<code>]` pragmas.
This is because Hypothesis annotates `register_type_strategy()` with
`(T, SearchStrategy[T])`, but in most cases we register e.g. `ConstrainedInt`
to generate instances of the builtin `int` type which match the constraints.
�N)�Fraction)�Callable�Dict�Type�Union�cast�overload)�lenient_issubclass�s�returncCs,z
tj|dd�WdStjyYdSw)NF)�check_deliverabilityT)�email_validator�validate_email�EmailNotValidError�r
�r�I/usr/local/lib/python3.10/dist-packages/pydantic/v1/_hypothesis_plugin.py�is_valid_email:s�rz{} <{}>z"[A-Za-z0-9_]+( [A-Za-z0-9_]+){0,5}T��	fullmatchcCs(g|]}|�d�sttjd|����qS)�_zmath.)�
startswithr�pydantic�PyObject)�.0�namerrr�
<listcomp>Ss(r�|z#(?:(\d\d?(?:\.\d+)?|100(?:\.0+)?)%)z+(?:(0(?:\.\d+)?|1(?:\.0+)?|\.\d+|\d{1,2}%))zB(?:((?:\d|\d\d|[01]\d\d|2[0-4]\d|25[0-4])(?:\.\d+)?|255(?:\.0+)?))���dz{}%�card_numberc	CsXdD]%}t�t��tj�||�||Wd�S1s"wYqtd��)N�
0123456789�Unreachable)�
contextlib�suppress�	Exceptionr�PaymentCardNumber�validate_luhn_check_digit�AssertionError)r!�digitrrr�add_luhn_digitzs&�r+)z
4[0-9]{14}z5[12345][0-9]{13}z3[47][0-9]{12}z[0-26-9][0-9]{10,17})�version�����days)�	min_value)�	max_value�	RESOLVERS�typcC�dS�Nr�r5rrr�_registered��r9cCr6r7rr8rrrr9�r:cCsRtjj�|�t��D]\}}t||�r t�|||��|Sqt	d|�d���)Nz
Unknown type z has no resolver to register)
r�types�_DEFINED_TYPES�addr4�items�
issubclass�st�register_type_strategy�NotImplementedError)r5�	supertype�resolverrrrr9�s
�.cs�fdd�}|S)Ncs|tvsJ�|t�<|Sr7)r4)�fr8rr�inner�szresolves.<locals>.innerr)r5rFrr8r�resolves�srGcCs�z|jdur
t��nt�|j�}Wn(ty9tjddd�}tjt�t��t��t�	�|t�
��dd�d�}Ynwt|dd�}tjt
|tj�rL|jjntj|t��t��t�	dd�Bt��d	�S)
NF)�allow_infinity�	allow_nancSst�|�t�t��|�BSr7)r@�lists�dictionaries�text��xrrr�<lambda>�szresolve_json.<locals>.<lambda>)�base�extend�
inner_typer�)�ensure_ascii�indent�	sort_keys)rRr@�none�	from_typer&�floats�	recursive�one_of�booleans�integersrL�getattr�buildsr	r�	BaseModel�json�dumps)�clsrF�finiterRrrr�resolve_json�s"" 
���recCs�|jpd}|j}|jstj||d�Sd�|dkr|dnd|p ddkr'|dnd�}|dkr5d|�d�}n|dkr@d	|�d
�}n|dksFJ�d|�d�}tj|��d
d�S)Nr��min_size�max_size�	{{{},{}}}���\W.�\Wr�\W(.�\W)?�(\W(.�\W)?)?Tr)�
min_length�
max_length�strip_whitespacer@�binary�format�
from_regex�encode)rcrgrh�repeats�patternrrr�resolve_conbytes�s
�r{cs��j}�j}�jdur|dusJd���j}�jdur&|dus#Jd���j}tj||d�jd�}�jdur>|��fdd��}�jdurL|��fdd��}|S)N�Set `gt` or `ge`, but not both�Set `lt` or `le`, but not bothF)rI�placescs
|�jkSr7)�lt��d�rcrrrO�
z$resolve_condecimal.<locals>.<lambda>cs
�j|kSr7)�gtr�r�rrrOr�)�ge�ler�rr@�decimals�decimal_places�filter)rcr2r3r
rr�r�resolve_condecimals



r�cs��j}�j}d}d}�jdur|dusJd���j}d}�jdur.|dus)Jd���j}d}�jdur=tj||||dd�S|durOt�|�j�}|rO|d}|durj|�jks\Jd��t�	|�j�}|rj|d}t�
||���fdd	��S)
NFr|Tr})�exclude_min�exclude_maxrIrz:Cannot build model with max value smaller than multiple ofc�
|�jSr7��multiple_ofrMr�rrrO6r�z"resolve_confloat.<locals>.<lambda>)r�r�r�rr�r@rY�math�ceil�floorr]�map)rcr2r3r�r�rr�r�resolve_confloats0


r�cs��j}�j}�jdur|dusJd���jd}�jdur*|dus%Jd���jd}�jdus4�jdkr:t�||�S|durJt�t	|�t	�j��}|durZt�
t	|�t	�j��}t�||���fdd��S)Nr|rr}cr�r7r�rMr�rrrOMr�z resolve_conint.<locals>.<lambda>)r�r�r�rr�r@r]r�r�rr�r��rcr2r3rr�r�resolve_conint9s



r�cCs�|jdur|jdusJd��|j}n|jdur!|jtjdd�}ntjj}|jdur7|jdus3Jd��|j}n|jdurF|jtjdd�}ntjj}t	�
||�S)Nr|rr0r})r�r��datetime�	timedelta�date�minr�r�maxr@�datesr�rrr�resolve_condatePs



r�cs(|jpd�|j�|jdur|jstj��d�S|jdur-t�|j�}|jr,|�dd��}nF|jrsd��dkr:�dnd�p>ddkrE�dnd�}�dkrVt�d|�d	��}n�d
krdt�d|�d��}n�dksjJ�t�d
|�d��}�dkr}�dur}|S�dur�|��fdd��S|���fdd��S)NrrfcSs||��kSr7)�striprrrrrOn�z resolve_constr.<locals>.<lambda>rirjrkrlrmrrnrorprqcs�t|�kSr7��lenr)rgrrrOr�cs�t|�ko�kSSr7r�r�rhrgrrrO�s)	rrrs�regexrtr@rLrwr�rv)rc�strategyryrr�r�resolve_constrcs2

��r�)v�__doc__r$r��	ipaddressrar��	fractionsr�typingrrrrrr�hypothesis.strategies�
strategiesr@r�pydantic.color�pydantic.types�pydantic.v1.utilsr	r
�ImportError�str�boolrrA�EmailStr�emailsr��	NameEmailr_rvrwr�sampled_from�sorted�vars�join�color�r_hex_short�
r_hex_long�r_rgb�r_rgba�r_hsl�r_hsla�replace�_r_sl�_r_alpha�_r_255�_color_regexes�Colorr[�COLORS_BY_NAME�tuplesr]rWrYr�r+�
card_patternsr'�UUID1�uuids�UUID3�UUID4�UUID5�SecretBytesru�	SecretStrrL�
IPvAnyAddress�ip_addresses�IPvAnyInterfacerX�
IPv4Interface�
IPv6Interface�
IPvAnyNetwork�IPv4Network�IPv6Network�
StrictBoolr\�	StrictStr�
FutureDater�r��todayr��PastDater4�type�SearchStrategy�__annotations__r;�Tr9�ConstrainedNumberMetarG�JsonWrapperre�ConstrainedBytesr{�ConstrainedDecimalr��ConstrainedFloatr��ConstrainedIntr��ConstrainedDater��ConstrainedStrr��listr<r5�Jsonrrrr�<module>s� ���
��	���


&���	���(( $�
�� 
�