
    iK9                        % S SK r S SKrS SKrS SKJr  S SKJrJrJr  S SK	J
r
  S SKJrJrJrJrJr  S SKJr  S SKJrJr  S SKJrJr  S S	KJr  S S
KJr  S SKJr  S SKJ r   S SK!J"r"  S SK#J$r$J%r%  S SK&J'r'  S SK(J)r)  S SK*J+r+J,r,J-r-J.r.  S\/S\S\/4S jr0S\4S jr1\S\S   S-  S\4S j5       r2\S\3S\S   4S j5       r2S\3S\S   4S jr2\)\S      " S5      r4S\54S jr6S0S jr7\
S  5       r8 " S! S5      r9S" r:S# r;S$\3SS4S% jr<S1S$\/S'\/\=-  \>-  SS4S( jjr?\" 5       r@\\AS)'   \/S*.S+ jrBS&S,.S-\=\>-  S.\/S\=\>-  4S/ jjrCg)2    N)defaultdict)Callable	GeneratorSequence)contextmanager)AnyLiteralNoReturnOptionaloverload)WeakKeyDictionary)	Verbositysettings)InvalidArgumentUnsatisfiedAssumption)BaseExceptionGroup)ConjectureData)observability_enabled)get_pretty_function_description)
check_type)reportverbose_report)note_deprecation)DynamicVariable)
ArgLabelsTIDKeyPrettyPrintFunctionprettywhatframereturnc                 l    UR                   nU  SUR                  R                   SUR                   S3$ )Nz() in z (line ))f_backf_codeco_namef_lineno)r   r    wheres      Q/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/control.py_calling_function_locationr*   !   s4    LLEV6%,,../wu~~6FaHH    c                     [         R                  c  [        SSSS9  [        S[        R
                  " 5       5      n [        5       (       a0  [        5       R                  R                  U    nUR                  SS9  [        U 5      e)Nz:Using `reject` outside a property-based test is deprecated
2023-09-25Fsincehas_codemodreject	condition)_current_build_contextvaluer   r*   inspectcurrentframecurrently_in_test_contextcurrent_build_contextdata_observability_predicatesupdate_countr   )r(   countss     r)   r1   r1   &   st    ##+H	

 'x1E1E1GHE ""&(--GGNe,

&&r+   r3   Fc                     g N r2   s    r)   assumerA   4   s    :=r+   Tc                     g r?   r@   r2   s    r)   rA   rA   6   s    03r+   c                 ~   [         R                  c  [        SSSS9  [        5       (       d  U (       d  [	        S[
        R                  " 5       5      n[        5       (       aH  [        5       (       a9  [        5       R                  R                  U   nUR                  [        U 5      S9  U (       d  [        SU 35      eg)	zCalling ``assume`` is like an :ref:`assert <python:assert>` that marks
the example as bad, rather than failing the test.

This allows you to specify properties that you *assume* will be
true, and let Hypothesis try to avoid similar examples in future.
z:Using `assume` outside a property-based test is deprecatedr-   Fr.   rA   r2   zfailed to satisfy T)r4   r5   r   r   r*   r6   r7   r8   r9   r:   r;   r<   boolr   )r3   r(   r=   s      r)   rA   rA   :   s     ##+H	

 i*8W5I5I5KL ""'@'B'B*,11KKERF$y/:'*<UG(DEEr+   BuildContextc                  &    [         R                  SL$ )aP  Return ``True`` if the calling code is currently running inside an
|@given| or :ref:`stateful <stateful>` test, and ``False`` otherwise.

This is useful for third-party integrations and assertion helpers which
may be called from either traditional or property-based tests, and can only
use e.g. |assume| or |target| in the latter case.
N)r4   r5   r@   r+   r)   r8   r8   T   s     "''t33r+   c                  B    [         R                  n U c  [        S5      eU $ )NzNo build context registered)r4   r5   r   contexts    r)   r9   r9   _   s#    $**G;<<Nr+   c              '      #    SSK Jn  [        R                  " 5       nS v   [        R                  " 5       nXC:w  a7  [	        U5      UR
                  ;  a  [        SU R                  " U6 -   SSSS9  g g g 7f)Nr   )entropyznDo not use the `random` module inside strategies; instead consider `st.randoms()`, `st.sampled_from()`, etc.  z
2024-02-05F   )r/   r0   
stacklevel)hypothesis.internalrK   randomgetstatehash_known_random_state_hashesr   format)fmtargsrK   state_beforestate_afters        r)   deprecate_random_in_strategyrX   f   ss     +??$L	//#K( 	#W%G%GGCEHZZQUEVW	
 H 	$s   A2A4c                       \ rS rSrSS.S\S\S\SS4S	 jjr\S
\	S\
\SS4   4S j5       rSS.S\S\S\\   S\\	\4   S\S-  SS4S jjrS\\	\4   S\\\	\4   \4   4S jrS rS rSrg)rE      F)is_finalr:   r[   wrapped_testr!   Nc                l    Xl         / U l        X l        X0l        [	        [
        5      U l        / U l        g r?   )r:   tasksr[   r\   r   listknown_object_printers_label_path)selfr:   r[   r\   s       r)   __init__BuildContext.__init__   s7     	.0
 (  	"
 ')r+   labelc              #   \  #    [        U R                  R                  5      nU R                  R	                  U5        0 n Uv   U R                  R                  5         [        U R                  R                  5      nX$::  d   eX$:w  a,  X$4X1'   U R                  R                  R                  X$45        g g ! U R                  R                  5         [        U R                  R                  5      nX$::  d   eX$:w  a,  X$4X1'   U R                  R                  R                  X$45        f f = f7fr?   )lenr:   nodesra   appendpop
arg_slicesadd)rb   re   start
arg_labelsends        r)   track_arg_labelBuildContext.track_arg_label   s     DIIOO$&!#
	7  " diioo&C<<|%*L
!		$$((%6    " diioo&C<<|%*L
!		$$((%6 s   =D, B6 A2D,6A3D))D,rn   objfuncrU   kwargsrn   c                h   ^^ U R                   [        U5         R                  X%S.UU4S jj5        g )N)_func_arg_labelsc          	      >   > UR                  U U[        U5      TTUS9$ )Nrr   )maybe_repr_known_object_as_callr   )rs   pcyclerw   rx   rU   ru   s        r)   <lambda>*BuildContext.record_call.<locals>.<lambda>   s/    IjIj/6& Jk Jr+   )r`   r   ri   )rb   rs   rt   rU   ru   rn   s      `` r)   record_callBuildContext.record_call   s/     	""5:.55+/  		
r+   kwarg_strategiesc                 ,   0 n0 nUR                  5        HX  u  pEU R                  U5       n[        SXE5         U R                  R	                  USU 3S9X4'   S S S 5        S S S 5        UW-  nMZ     X24$ ! , (       d  f       N"= f! , (       d  f       N+= f)Nzfrom {}={!r}z	generate:)
observe_as)itemsrp   rX   r:   draw)rb   r   rn   ru   ks	arg_labels          r)    prep_args_kwargs_from_strategies-BuildContext.prep_args_kwargs_from_strategies   s     "$
!#$**,DA$$Q'9,^QB IINN19QCNI	 C ( )#J - !! CB ('s"   B A4B4
B>B
B	c                 n    [         R                  U 5      U l        U R                  R                  5         U $ r?   )r4   
with_valueassign_variable	__enter__)rb   s    r)   r   BuildContext.__enter__   s,    5@@F&&(r+   c                    U R                   R                  XU5        / nU R                   H  n U" 5         M     U(       a"  [        U5      S:X  a  US   Ue[        SU5      Ueg ! [         a  nUR	                  U5         S nAMZ  S nAff = f)NrL   r   zCleanup failed)r   __exit__r^   BaseExceptionri   rg   r   )rb   exc_type	exc_valuetberrorstaskerrs          r)   r   BuildContext.__exit__   s    %%h2>JJD# 
 6{aQiY.$%5v>IM  ! #c""#s   A$$
B
.BB
)ra   r   r:   r[   r`   r^   r\   )__name__
__module____qualname____firstlineno__r   rD   r   rc   r   strr   r   rp   objectr   dictr   r   tupler   r   r   __static_attributes__r@   r+   r)   rE   rE      s    
 	)) 	)
 ) 
), 7S 7Yz47M-N 7 7< )-

 

 v
 S&[!
 %
 

("sCx." 
tCH~z)	*""
Nr+   c                 v    [         R                  nUc  [        S5      eUR                  R	                  U 5        g)a]  Register a function to be called when the current test has finished
executing. Any exceptions thrown in teardown will be printed but not
rethrown.

Inside a test this isn't very interesting, because you can just use
a finally block, but note that you can use this inside map, flatmap,
etc. in order to e.g. insist that a value is closed at the end.
Nz0Cannot register cleanup outside of build context)r4   r5   r   r^   ri   )teardownrI   s     r)   cleanupr      s2     %**GPQQMM"r+   c                      [         R                  n U c  [        S5      eU R                  =(       d+    [        R
                  R                  [        R                  :  $ )Nz#Cannot make notes outside of a test)	r4   r5   r   r[   r   default	verbosityr   verboserH   s    r)   should_noter     sF    $**GCDDNx//99Y=N=NNNr+   r5   c                 z    [        5       (       a,  [        U [        5      (       d  [        U 5      n [	        U 5        gg)z2Report this value for the minimal failing example.N)r   
isinstancer   r   r   )r5   s    r)   noter   	  s+    }}%%%5MEu r+    payloadc                     [         R                  nUc  [        S5      eUR                  R                  R
                  n[        U[        [        [        4US9n[        XS9n XR                  R                  U '   g)aI  Record an event that occurred during this test. Statistics on the number of test
runs with each event will be reported at the end if you run Hypothesis in
statistics reporting mode.

Event values should be strings or convertible to them.  If an optional
payload is given, it will be included in the string for :ref:`statistics`.
Nz&Cannot record events outside of a test)allowed_typesavoid_realization)r   )r4   r5   r   r:   providerr   _event_to_stringr   intfloatevents)r5   r   rI   r   s       r)   eventr     sm     %**GFGG--??S%0DUG UHE!(LLr+   _events_to_strings)r   c                    [        X5      (       a  U $ U(       a  [        U 5      $  [        U    $ ! [        [        4 a     Of = f[        U 5      n U[        U '   U$ ! [         a     U$ f = fr?   )r   r   r   KeyError	TypeError)r   r   r   results       r)   r   r   (  s    %''
 5z!%((i   ZF$*5! M  Ms!   / AA	A 
A*)A*)re   observationre   c                &   [        [        [        4U S5        [        R                  " U 5      (       d  [        SU < S35      e[        [        US5        [        R                  nUc  [        S5      eUR                  R                  R                  (       a  U $ [        SU < SU< S35        XR                  R                  ;   a3  [        S	U < SU< S
UR                  R                  U   < SU< S3	5      eXR                  R                  U'   U $ )a  Calling this function with an ``int`` or ``float`` observation gives it feedback
with which to guide our search for inputs that will cause an error, in
addition to all the usual heuristics.  Observations must always be finite.

Hypothesis will try to maximize the observed value over several examples;
almost any metric will work so long as it makes sense to increase it.
For example, ``-abs(error)`` is a metric that increases as ``error``
approaches zero.

Example metrics:

- Number of elements in a collection, or tasks in a queue
- Mean or maximum runtime of a task (or both, if you use ``label``)
- Compression ratio for data (perhaps per-algorithm or per-level)
- Number of steps taken by a state machine

The optional ``label`` argument can be used to distinguish between
and therefore separately optimise distinct observations, such as the
mean and standard deviation of a dataset.  It is an error to call
``target()`` with any label more than once per test case.

.. note::
    The more examples you run, the better this technique works.

    As a rule of thumb, the targeting effect is noticeable above
    :obj:`max_examples=1000 <hypothesis.settings.max_examples>`,
    and immediately obvious by around ten thousand examples
    *per label* used by your test.

:ref:`statistics` include the best score seen for each label,
which can help avoid `the threshold problem
<https://hypothesis.works/articles/threshold-problem/>`__ when the minimal
example shrinks right down to the threshold of failure (:issue:`2180`).
r   zobservation=z must be a finite float.re   zvCalling target() outside of a test is invalid.  Consider guarding this call with `if currently_in_test_context(): ...`zSaw target(z, label=r#   zCalling target(z) would overwrite target()r   r   r   mathisfiniter   r   r4   r5   r:   r   r   r   target_observations)r   re   rI   s      r)   targetr   ?  s   F U|[-8==%%.FGHHsE7#$**GU
 	
 
			0	0 [y%;<000k_Iuh 7ll66u=@	5(!M
 	

 3>((/r+   )r!   rE   )r   )Dr6   r   rO   collectionsr   collections.abcr   r   r   
contextlibr   typingr   r	   r
   r   r   weakrefr   
hypothesisr   r   hypothesis.errorsr   r   hypothesis.internal.compatr   #hypothesis.internal.conjecture.datar   !hypothesis.internal.observabilityr   hypothesis.internal.reflectionr   hypothesis.internal.validationr   hypothesis.reportingr   r   hypothesis.utils.deprecationr   !hypothesis.utils.dynamicvariablesr   hypothesis.vendor.prettyr   r   r   r   r   r*   r1   rA   r   r4   rD   r8   r9   rX   rE   r   r   r   r   r   r   r   __annotations__r   r   r@   r+   r)   <module>r      s      # 9 9 % = = % * D 9 > C J 5 7 9 = S SIS I I I
' ' 
 =gent+ = = 
 =	 3f 3 3 
 3f  . ).)AB4H 44 4 "
 "
JdN dNN#O 4 ) )sSy50 )$ )( ):(; % ; .1 . 68 =e =s =C%K =r+   