
    iY                        S r SSKrSSKrSSKrSSKJr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JrJrJr  SS	KJr  SS
KJr  SSKJrJrJr  SSKJ r J!r!  SSK"J#r#J$r$  SSK%J&r&J'r'J(r(  SSK)J*r*J+r+  SSK,J-r-  SSK.J/r/  SSK0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7J8r8J9r9J:r:  SSK;J<r<  SSK=J>r>J?r?  SSK@JArA  SSKBJCrCJDrDJErEJFrF  SSKGJHrH  SSKIJJrJ  \" S5      rK\1" S5      rLS\MS\N4S  jrO " S! S"5      rP " S# S$5      rQSSSS%.S& jrRSSS'.S( jrS " S) S*\T5      rU\" S+S+S,9 " S- S.5      5       rV " S/ S0\US19rW\" S+S2S,9 " S3 S45      5       rX\R                  " 5       rZ " S5 S6\E5      r[ " S7 S8\E\C   5      r\ " S9 S:\\\C   5      r]S;\\\C   S\E\C   4S< jr^\" S+S+S,9 " S= S>\\C   5      5       r_S?\KS\_\K   4S@ jr`SA raSBrbSCrcSDrdSEre\SF\_\C   \C-  4   rf\\f\C   /\f\C   4   rgSG\S\h4SH jri\SFSI.SJ\\\\C      SKSSL\ES\g\C   4SM jj5       rj\SFSN.SK\\\C   SJ\PSL\ES\g\C   4SO jj5       rj\SFSFSP.SKSSJ\PSL\ES\\SQ   /\SQ   4   4SR jj5       rjSSSST.SJ\\\\C      \P-  SK\\\C   S-  SL\ES\g\C   \\SQ   /\SQ   4   -  4SU jjrj\SFSI.SJ\\\\C      SKSSL\ES\g\C   4SV jj5       rk\SFSN.SK\\\C   SJ\PSL\ES\g\C   4SW jj5       rk\SFSFSP.SKSSJ\PSL\ES\\SQ   /\SQ   4   4SX jj5       rkSSSST.SJ\\\\C      \P-  SK\\\C   S-  SL\ES\g\C   \\SQ   /\SQ   4   -  4SY jjrk\" S+S+S,9 " SZ S[5      5       rlS\\\/\N4   S\\#/\#4   4S] jrm\" S+S+S,9 " S^ S_5      5       rnS2S`.Sa\NS\\#/\#4   4Sb jjro " Sc Sd\E5      rpg)ea  This module provides support for a stateful style of testing, where tests
attempt to find a sequence of operations that cause a breakage rather than just
a single value.

Notably, the set of steps available at any point may depend on the
execution to date.
    N)CallableIterableSequence)	dataclassfield)	lru_cache)StringIO)perf_counter)AnyClassVarTypeVaroverload)TestCase)
strategies)HealthCheck	Verbositysettings)_current_build_contextcurrent_build_context)TestFuncgiven)FlakyStrategyDefinitionInvalidArgumentInvalidDefinition)add_notebatched)BUFFER_SIZE)gc_cumulative_time)calc_label_from_name)fail_health_check)observability_enabled)function_digestget_pretty_function_descriptionnicereprproxies)
check_type)current_verbosityreport)FeatureStrategy)ExOneOfStrategySearchStrategycheck_strategy)note_deprecation)RepresentationPrinterTzanother state machine stepobjreturnc                     [        U [        5      (       a  SU s=::  a  S::  a   g  [        U [        5      =(       d    U SL $ )za
Returns True if two separately created instances of v will have the same id
(due to interning).
   TN)
isinstanceintbool)r1   s    R/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/stateful.py_is_singletonr:   C   s=     #sc 0S 0 !1 c4 /C4K/    c                       \ rS rSrSrSrg)_OmittedArgumentQ   ziSentinel class to prevent overlapping overloads in type hints. See comments
above the overloads of @rule. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r?   r;   r9   r=   r=   Q   s    %r;   r=   c                   *    \ rS rSrSS jrS rS rSrg)TestCasePropertyV   Nc                 >    Ub  [        U5      nUR                  5       $ N)type_to_test_case)selfr1   typs      r9   __get__TestCaseProperty.__get__W   s    ?s)C  ""r;   c                     [        S5      e)NzCannot set TestCaseAttributeError)rM   r1   values      r9   __set__TestCaseProperty.__set__\   s    233r;   c                     [        S5      e)NzCannot delete TestCaserR   )rM   r1   s     r9   
__delete__TestCaseProperty.__delete___   s    566r;   r?   rJ   )r@   rA   rB   rC   rO   rU   rX   rE   r?   r;   r9   rG   rG   V   s    #
47r;   rG   r   
_min_steps_flaky_statec                2  ^ ^^^ Tc(   T R                   R                  m[        [        TS5        [        [        TS5        [        [        TS5        TS:  a  [        ST S35      eT=(       d    0 mT[        [        R                  " 5       5      UUUU 4S j5       5       n[        T 5      UR                  R                  l        [!        T S	S 5      Ul        [!        T S
S 5      Ul        SUl        U$ ! [         a    [        S [        [        5      S9m Nf = f)Nz'state_machine_factory.TestCase.settingsdeadlinesuppress_health_checkr   r[   r   z_min_steps=z must be non-negative.c           	        >^^ U R                   mT" 5       n[        [        US5        UTl        TR                  Ul        [        5       R                  =(       d    [        5       [        R                  :  m/ Tl
        UU4S jn U" SUR                  R                   S35        UR                  TUTR                  5        TR                  nSn TR!                  ["        5        S nXC:  a  SnO"UT::  a  SnOTR$                  S[&        -  :  a  Sn[)        5       n[+        5       nTR-                  S	US
9(       a  GOUS-  nSTS'   UR.                  (       a  UR.                   Vs/ s HL  n[0        R2                  " [0        R4                  " U5      [0        R6                  " UR8                  5      5      PMN     n	nTR;                  [0        R<                  " U	5      5      u  pUR.                  R?                  U5        OTR;                  UR@                  5      u  pSTS'   SURB                  R                   3n
TRD                  RG                  U
S5        [+        5       U-
  nTRD                  U
==   [)        5       U-
  U-
  -  ss'   T(       d  [I        5       (       a3  U RK                  5        VVs0 s H  u  pXRM                  U5      _M     nnn[O        5       n [Q        U 5      n [S        U RK                  5       5       H  u  p[U        U[V        5      (       a  URX                  URZ                     X'   M7  [U        U[R        5      (       d  MN  []        S U 5       5      (       d  Mg  U Vs/ s H  nURX                  URZ                     PM     snX'   M     SURB                  R                   3n[)        5       n[+        5       nURB                  " U40 U D6n[+        5       U-
  nTR                  U==   [)        5       U-
  U-
  -  ss'   UR^                  (       aZ  [U        U[`        5      (       a'  URc                  UR^                  URd                  5        OWURc                  UR^                  U/5        O9Ub6  [g        TSURB                  Rh                   SU< 3[j        Rl                  5        T(       d  [I        5       (       a  U" URo                  UWU5      5        UR                  TUTR                  5        TRq                  5         GM:  U" S5        URs                  5         g s  snf s  snnf s  snf ! T(       d  [I        5       (       a  U" URo                  UWU5      5        f f = f! U" S5        URs                  5         f = f)Nzstate_machine_factory()c                    > T(       a  [        U 5        [        5       (       a  TR                  R                  U 5        g g rJ   )r(   r!   _stateful_repr_partsappend)scdprint_stepss    r9   outputAget_state_machine_test.<locals>.run_state_machine.<locals>.output   s/    q	$&&''..q1 'r;   zstate = ()r   TFg?g      >)pforced   selecting_rulezgenerate:rule:g        c              3   B   #    U  H  n[        U[        5      v   M     g 7frJ   r6   VarReference.0items     r9   	<genexpr>Dget_state_machine_test.<locals>.run_state_machine.<locals>.<genexpr>   s      9GHtJt\::q   zexecute:rule:z<Rules should return None if they have no target bundle, but 
 returned zstate.teardown()):conjecture_datar&   RuleBasedStateMachinehypothesis_runner_observability_predicatesr   is_finalr'   r   debugrc   	__class__r@   check_invariants_stateful_run_timesstateful_step_count
start_spanSTATE_MACHINE_RUN_LABELlengthr   r
   r   draw_boolean_initialize_rules_to_runsttuplesjustfixed_dictionaries	argumentsdrawone_ofremove_rules_strategyfunction
draw_times
setdefaultr!   items_pretty_printmultipledictlistr6   rq   names_to_valuesnamealltargetsMultipleResults_add_results_to_targetsvaluesr    rB   r   return_value
_repr_step	stop_spanteardown)datamachinerh   	max_steps	steps_run	must_stop
start_drawstart_gcrule
init_rules
draw_label	in_gctimekvdata_to_printresultrt   labelstartrf   rg   r\   r[   r   state_machine_factorys                      @@r9   run_state_machine1get_state_machine_test.<locals>.run_state_machinev   s    !!)>)@('3LM&,.,H,H) "#,,V0A0Cy0V 	 #%	2b	Xg//889<=$$Xvr7M7MN 44II 56 	) $I*, %IYY#"34 !%I)^
-/??VI?>Q	 26-.33 %,$D$D"$DD 		"''$-1F1Ft~~1VW$D  " "$:)>!?JD44;;DA!#)@)@!AJD16-.-dmm.D.D-EF
((S9.08;	j)\^j-H9-TT) "7"9"9@D

%@L0033 " %
 ""P:D $TZZ\ 2%a66&-&=&=aff&EDG'400S 9GH9 6 6 WX&XVWdw'>'>tyy'IVW&XDG !3 ,DMM,B,B+CDE(NE13H!]]7;d;F 2 4x ?I**51\^e5Ki5WW1||%fo>>#;;DLL&--X#;;DLL6(S+)$##'==#=#=">j
T'44	 #&;&=&= w11$vNO((62;Q;QRs v %&A"&% 'Y, #&;&=&= w11$vNO	 '> %&sf   C!U) &AT$9C7U) 0T)U) A.T4 T4 &T4 *#T/DT4 ,AU) $U) /T4 42U&&U) )V_hypothesis_internal_use_seed*_hypothesis_internal_use_reproduce_failureF)r   r   r&   SettingsrS   r   r   r7   r   r   r   r   r"   
hypothesis
inner_test_hypothesis_internal_add_digestgetattrr   r   %_hypothesis_internal_print_given_args)r   r   r[   r\   r   s   ```` r9   get_state_machine_testr   c   s"   
 	X,55>>Hx+TU x:.sJ-A~ J<7MNOO%2L
2779t  tp 	-.   ++K 7>>73 DKKTD@ ?D;]  	XT+EVWH	Xs   'C2 2!DD)r   r[   c                    SS0n[        U UUUS9n U" 5         g! [         a  nUS   (       a  [        US5        e SnAff = f)a\  Run a state machine definition as a test, either silently doing nothing
or printing a minimal breaking program and raising an exception.

state_machine_factory is anything which returns an instance of
RuleBasedStateMachine when called with no arguments - it can be a class or a
function. settings will be used to control the execution of the test.
rn   FrZ   zwwhile selecting a rule to run. This is usually caused by a flaky precondition, or a bundle that was unexpectedly empty.N)r   r   r   )r   r   r[   flaky_statestate_machine_testerrs         r9   run_state_machine_as_testr      s_     $U+K/ 		" '(Q
 	s    
A ;A c                   (   ^  \ rS rSrU 4S jrSrU =r$ )StateMachineMetai  c                    > US:X  ab  [        U[        5      (       aM  SUR                  5        S3n[        SU R                   SU SU R                   SU SU R                   S	35      e[
        TU ]  X5      $ )
Nr   	settings()z
Assigning z.settings = z does nothing. Assign to .TestCase.settings, or use @ as a decorator on the  class.)r6   r   show_changedrS   r@   super__setattr__)clsr   rT   descrr   s       r9   r   StateMachineMeta.__setattr__  s    :*UH"="= 2 2 45Q7E S\\N,ug >ll^#?w G,,w0 
 w"4//r;   r?   )r@   rA   rB   rC   r   rE   __classcell__r   s   @r9   r   r     s    0 0r;   r   T)slotsfrozenc                   F    \ rS rSr% \S   \S'   \S   \S'   \S   \S'   Srg)	_SetupStatei$  Rulerules	Invariant
invariantsinitializersr?   N)r@   rA   rB   rC   r   __annotations__rE   r?   r;   r9   r   r   $  s!    <[!!v,r;   r   c                       \ rS rSr% Sr0 r\\\\	4      \
S'   SS jrS rS rS	 rS
\S\\   4S jrS r\S 5       rSSS\S\S\4S jrS rS rS r\" 5       r\\S 5       5       rSrg)rz   i+  a  A RuleBasedStateMachine gives you a structured way to define state machines.

The idea is that a state machine carries the system under test and some supporting
data. This data can be stored in instance variables or
divided into Bundles. The state machine has a set of rules which may read data
from bundles (or just from normal strategies), push data onto
bundles, change the state of the machine, or verify properties.
At any given point a random applicable rule will be executed.
_setup_state_per_classr2   Nc                    U R                  5       nUR                  (       d"  [        S[        U 5      R                   S35      e[        [        [        U 5      5      R                  S5      =n[        5      (       aA  [        U 5      R                  nSUR                  5        S3n[        SU SU SU S	U S
3	5      eUR                  U l        UR                  U l
        UR                  R                  5       U l        0 U l        [        R                   " 5       U l        / U l        0 U l        [)        5       U l        [-        U R*                  [.        R0                  S9U l        [5        U 5      U l        g )NzState machine z defines no rulesr   r   r   zAssigning settings = z. as a class attribute does nothing. Assign to r   r   r   )context)setup_stater   r   rK   r@   r6   varsgetr   r   r   r   copyr   bundlescollectionsCounternames_counters
names_listr   r	   _RuleBasedStateMachine__streamr/   r   rT   _RuleBasedStateMachine__printerRuleStrategyr   )rM   r   re   tnamer   s        r9   __init__RuleBasedStateMachine.__init__8  sP   &&(  # d!4!4 55FG  4T
+//
;;aXFFJ''E 013E#'w /"G#?w G)  !&&
%00(3(@(@(E(E(G%(*3>3F3F3H%'/1 
.MM#9#?#?
  ,D1r;   c                    [        U[        5      (       a  UR                  $ [        U[        5      (       aH  [	        S U 5       5      (       a1  SSR                  U Vs/ s H  o"R                  PM     sn5      -   S-   $ U R                  R                  S5        U R                  R                  S5        SU R                  l
        SU R                  l        U R                  R                  R                  5         U R                  R                  U5        U R                  R                  5         U R                  R!                  5       $ s  snf )Nc              3   B   #    U  H  n[        U[        5      v   M     g 7frJ   rp   rr   s     r9   ru   6RuleBasedStateMachine._pretty_print.<locals>.<genexpr>Z  s      -
7<tJt\**urw   [, ]r   )r6   rq   r   r   r   joinr   seektruncater   output_widthbuffer_widthbufferclearprettyflushgetvalue)rM   rT   rt   s      r9   r   #RuleBasedStateMachine._pretty_printW  s    e\**::t$$ -
7<-
 *
 *
 %#@%$II%#@AACGG1q!&'#&'###%e$}}%%'' $As   E

c                 ^    [        U 5      R                   S[        U R                  5       S3$ )N(r   )rK   r@   r$   r   rM   s    r9   __repr__RuleBasedStateMachine.__repr__g  s*    t*%%&a(>'?qAAr;   c                     U SU R                   U    3nU R                   U==   S-  ss'   U R                  R                  U5        U$ )N_rm   )r   r   rd   )rM   targetr   s      r9   	_new_nameRuleBasedStateMachine._new_namej  sK    81T0089:F#q(#v&r;   nc                 \    [        U R                  5      nX!:  d   eU R                  X!-
  S  $ rJ   )lenr   )rM   r  len_s      r9   _last_names!RuleBasedStateMachine._last_namesp  s-    4??#yytxz**r;   c                 :    U R                   R                  U/ 5      $ rJ   )r   r   )rM   r   s     r9   bundleRuleBasedStateMachine.bundleu  s    ||&&tR00r;   c                     U R                   U    $ ! [         a     Of = f/ n/ n/ n[        R                  " U 5       H  u  pE[	        U[
        S 5      n[	        U[        S 5      n[	        U[        S 5      nUb  UR                  U5        Ub  UR                  U5        Ub  UR                  U5        [	        U[        S 5      c  M  Ub  M  Ub  M  [        [        U5       S35      e   [        XUS9n	XR                   U '   U	$ )Nz has been decorated with @precondition, but not @rule (or @invariant), which is not allowed. A precondition must be combined with a rule or an invariant, since it has no effect alone.)r   r   r   )r   KeyErrorinspect
getmembersr   RULE_MARKERINITIALIZE_RULE_MARKERINVARIANT_MARKERrd   PRECONDITIONS_MARKERr   _rule_qualnamer   )
r   r   r   r   _namefr   initializer	invariantstates
             r9   r   !RuleBasedStateMachine.setup_statex  s   	--c22 		 #%&(
**3/HE1k40D!!%;TBK#3T:IT"&##K0$!!), /6BL%'%a() *4 4 ! 0. z
 +0""3's    
r   r   r   r   c                 V   Sn/ nUR                   (       Ga5  [        U[        5      (       a  [        UR                  5      OSn[        UR                   5      U-  nU R                  U5      n[        U[        5      (       a  [        UR                  5      S:X  a+  U V	s/ s H	  n	SU	 S3PM     n
n	SR                  U
5      S-   nOUR                  (       aa  [        [        X5      5      nSR                  US   5      nUS-   nUSS   H+  nSR                  U5      nUR                  US-   U-   5        M-     OSR                  U5      S-   nSR                  S UR                  5        5       5      nU S	UR                  R                   SU S
3nSR                  U/U-   5      $ s  sn	f )N rm   r  z,)z = r   r   c              3   4   #    U  H  u  pU S U 3v   M     g7f)=Nr?   )rs   r   r   s      r9   ru   3RuleBasedStateMachine._repr_step.<locals>.<genexpr>  s     =A3ass   state.r   
)r   r6   r   r  r   r  r   r   r   rd   r   r   r@   )rM   r   r   r   output_assignmentextra_assignment_linesnumber_of_resultsnumber_of_last_names
last_namesr   output_per_targetnames_per_targetfirst_target_outputother_target_namesother_target_outputargsoutput_lines                    r9   r    RuleBasedStateMachine._repr_step  s   !#<<<&0&I&IFMM"q  $'t||#47H#H ))*>?J&/22v}}%*BL(M*$1TF"*%(M(-

3D(E(M%]] (,GJ,R'S$*.))4DQ4G*H'(;e(C%.>qr.B*.2ii8J.K+.55/%7:MM /C %*JJz$:U$B!yy=

==*+6$--2H2H1I4&PQRyy+)??@@% )Ns   F&c                 X   U H  nU H  nU R                  U5      nU4S jn[        U5      (       d/  U R                  R                  R	                  [        U5      U5        X@R                  U'   U R                  R	                  U/ 5      R                  [        U5      5        M     M     g )Nc                 $    UR                  U5      $ rJ   )text)r1   rk   cycler   s       r9   printer>RuleBasedStateMachine._add_results_to_targets.<locals>.printer  s    66$<'r;   )
r  r:   r   singleton_pprintersr   idr   r   rd   rq   )rM   r   resultsr  r   r   r>  s          r9   r   -RuleBasedStateMachine._add_results_to_targets  s    F!~~f-04 (
 %V,,NN66AA"V*gV-3$$T*''3::<;MN " r;   c           	      x  ^  T R                    GH(  nT R                  (       a  UR                  (       d  M(  [        U 4S jUR                   5       5      (       d  MN  UR
                  R                  n[        5       R                  (       d-  UR                  [        R                  :  d  [        5       (       a  U" SU S35        [        5       nUR                  T 5      nUSU 3==   [        5       U-
  -  ss'   Uc  M  [        USUR
                  R                   SU< S3[         R"                  5        GM+     g )Nc              3   2   >#    U  H  o" T5      v   M     g 7frJ   r?   )rs   precondrM   s     r9   ru   9RuleBasedStateMachine.check_invariants.<locals>.<genexpr>  s     H4Gwt}}4Gs   r+  rj   zexecute:invariant:z9The return value of an @invariant is always ignored, but rx   z instead of None)r   r   check_during_initr   preconditionsr   r@   r   r}   	verbosityr   r~   r!   r
   r    rB   r   r   )rM   r   rh   runtimesinvarr   r   r   s   `       r9   r   &RuleBasedStateMachine.check_invariants  s    __E,,U5L5LHE4G4GHHH>>**D%'00%%8(**vR() NE^^D)F)$01\^e5KK1!!O~~223:fZ H&&  ,,! %r;   c                     g)zeCalled after a run has finished executing to clean up any necessary
state.

Does nothing by default.
Nr?   r  s    r9   r   RuleBasedStateMachine.teardown  s    r;   c                 |   ^   " U 4S jS[         5      nT R                  S-   Ul        T R                  S-   Ul        U$ )Nc                   Z   > \ rS rSr\" S\" \5      S9rU 4S jrS\l	         Y \l
        Srg)ARuleBasedStateMachine._to_test_case.<locals>.StateMachineTestCasei  Nr^   c                 .   > [        TU R                  S9  g )N)r   )r   r   )rM   r   s    r9   runTestIRuleBasedStateMachine._to_test_case.<locals>.StateMachineTestCase.runTest  s    )#Fr;   Tr?   )r@   rA   rB   rC   r   r   r   r   rT  is_hypothesis_test_hypothesis_state_machine_classrE   )r   s   r9   StateMachineTestCaserR    s,    T+EVWHG *.G&69G3r;   rX  z	.TestCase)r   r@   rB   )r   rX  s   ` r9   rL   #RuleBasedStateMachine._to_test_case  s=    	:8 	: ),{(B%,/,<,<{,J)##r;   )
	__printer__streamr   r   r   r   r   r   r   r   )r2   N) r@   rA   rB   rC   rD   r   r   r   rK   r   r   r   r   r  r  r7   r   strr  r  classmethodr   r   r   r   r   r   rG   r   r   rL   rE   r?   r;   r9   rz   rz   +  s     ACHT$*;%<=B2>( B+S +T#Y +
1 % %NAv AS A# A# A@O 2  !H$  $r;   rz   )	metaclassFc                       \ rS rSr% \\S'   \\S'   \\S'   \\S'   \" SS9r\S   \S	'   \" SS
S9r	\
S
-  \S'   \" SS
S9r\S
-  \S'   \" S\S9r\\\4   \S'   S rS\4S jrS rSrg
)r   i  r   r   r   rI  F)init)Bundle.r   N)r`  default_cached_hash_cached_repr)r`  default_factoryarguments_strategiesc                 ^   / n[        U R                  R                  5       5       Ht  u  p#[        U[        5      (       a   e[        U[
        5      (       a5  UR                  U5        [        U[        5      n[	        UR                  US9nX0R                  U'   Mv     [        U5      U l        g Nconsume)sortedr   r   r6   BundleReferenceStrategyra  rd   BundleConsumerr   rf  tupler   )rM   r   r   r   rj  s        r9   __post_init__Rule.__post_init__  s    4>>//12DA!!%<====!V$$q!$Q7+AFFGD+,%%a( 3 W~r;   r2   c                 x   U R                   c  [        R                  " U 5       Vs/ s HL  n[        XR                  5      (       d  M  UR                   S[        [        XR                  5      5       3PMN     nnU R                  R                   SSR                  U5       S3U l         U R                   $ s  snf )Nr)  r  r   r   )	rd  dataclassesfieldsr   r   r#   r   r@   r   )rM   r   bitss      r9   r  Rule.__repr__  s    $ )//5 6E4,P5::,a2743LMNP5   $(>>#:#:";1TYYt_<MQ OD   s   B71B7c                     U R                   c^  [        U R                  U R                  [	        U R
                  R                  5       5      U R                  U R                  45      U l         U R                   $ rJ   )	rc  hashr   r   rn  r   r   rI  r   r  s    r9   __hash__Rule.__hash__$  sc     $ $LLMM$....01&&LL!D    r;   )rc  rd  r   )r@   rA   rB   rC   r   r   r   r   rn  rc  r7   rd  r\  r   rf  ro  r  rx  rE   r?   r;   r9   r   r     s    LMN$)u$5GU=!5$%>L#*>$%>L#*>+0eT+R$sCx.R	&	!# 	!!r;   r   c                   B   ^  \ rS rSrSS.S\S\4U 4S jjjrS rSrU =r	$ )	rl  i7  Fri  r   rj  c                :   > [         TU ]  5         Xl        X l        g rJ   )r   r   r   rj  )rM   r   rj  r   s      r9   r    BundleReferenceStrategy.__init__8  s    	r;   c                 F   UR                  [        5      nUR                  U R                  5      nU(       d  UR	                  SU R                  < 35        UR                  S[        U5      S-
  [        U5      S9nU R                  (       a  UR                  U5      $ X4   $ )NzCannot draw from empty bundle r   rm   )shrink_towards)	r   self_strategyr  r   mark_invaliddraw_integerr  rj  pop)rM   r   r   r  positions        r9   do_drawBundleReferenceStrategy.do_draw=  s    ))M*		* >tyymLM $$QFaF$T<<::h''##r;   )rj  r   )
r@   rA   rB   rC   r\  r8   r   r  rE   r   r   s   @r9   rl  rl  7  s(    5: S d  
$ $r;   rl  c            	       t   ^  \ rS rSrSrSSS.S\S\S\S	S
4U 4S jjjrS rS r	S r
S rU 4S jrS rSrU =r$ )ra  iL  a  A collection of values for use in stateful testing.

Bundles are a kind of strategy where values can be added by rules,
and (like any strategy) used as inputs to future rules.

The ``name`` argument they are passed is the they are referred to
internally by the state machine; no two bundles may have
the same name. It is idiomatic to use the attribute
being assigned to as the name of the Bundle::

    class MyStateMachine(RuleBasedStateMachine):
        keys = Bundle("keys")

Bundles can contain the same value more than once; this becomes
relevant when using :func:`~hypothesis.stateful.consumes` to remove
values again.

If the ``consume`` argument is set to True, then all values that are
drawn from this bundle will be consumed (as above) when requested.
FTrj  draw_referencesr   rj  r  r2   Nc                V   > [         TU ]  5         Xl        [        XS9U l        X0l        g rh  )r   r   r   rl  _Bundle__reference_strategyr  )rM   r   rj  r  r   s       r9   r   Bundle.__init__b  s(     		$;D$R!.r;   c                     UR                  [        5      nUR                  U R                  5      nUR                  UR                     $ rJ   )r   r  r  r   r   )rM   r   r   	references       r9   r  Bundle.do_drawj  s9    ))M*IId778	&&y~~66r;   c                     U R                   R                  nUSL a  SU R                  < S3$ SU R                  < SU< S3$ )NFzBundle(name=r   z
, consume=)r  rj  r   )rM   rj  s     r9   r  Bundle.__repr__o  sG    ++33e!$))a00dii]+WJa88r;   c                     g)NFr?   )rM   recurs     r9   calc_is_emptyBundle.calc_is_emptyu  s    r;   c                 ~    UR                  [        5      n[        UR                  U R                  5      5      (       + $ rJ   )r   r  r8   r  r   )rM   r   r   s      r9   is_currently_emptyBundle.is_currently_emptyy  s-     ))M*tyy1222r;   c                    > U R                   (       a>  [        U 5      " U R                  U R                  R                  SS9R                  U5      $ [        TU ]  U5      $ )NFr  )r  rK   r   r  rj  flatmapr   )rM   expandr   s     r9   r  Bundle.flatmap  sR    :		1199 % gfo	
 wv&&r;   c                 0    [        SU R                  45      $ )Nra  )rw  r   r  s    r9   rx  Bundle.__hash__  s     Xtyy)**r;   )__reference_strategyr  r   )r@   rA   rB   rC   rD   r\  r8   r   r  r  r  r  r  rx  rE   r   r   s   @r9   ra  ra  L  s\    , -24//%)/DH/	/ /7
93'+ +r;   ra  c                   :   ^  \ rS rSrS\\   SS4U 4S jjrSrU =r$ )rm  i  r  r2   Nc                 6   > [         TU ]  UR                  SS9  g )NTri  )r   r   r   )rM   r  r   s     r9   r   BundleConsumer.__init__  s    d3r;   r?   )	r@   rA   rB   rC   ra  r*   r   rE   r   r   s   @r9   rm  rm    s    4vbz 4d 4 4r;   rm  r  c                 X    [        U [        5      (       d  [        S5      e[        U 5      $ )a   When introducing a rule in a RuleBasedStateMachine, this function can
be used to mark bundles from which each value used in a step with the
given rule should be removed. This function returns a strategy object
that can be manipulated and combined like any other.

For example, a rule declared with

``@rule(value1=b1, value2=consumes(b2), value3=lists(consumes(b3)))``

will consume a value from Bundle ``b2`` and several values from Bundle
``b3`` to populate ``value2`` and ``value3`` each time it is executed.
z)Argument to be consumed must be a bundle.)r6   ra  	TypeErrorrm  )r  s    r9   consumesr    s(     ff%%CDD&!!r;   c                   0    \ rS rSr% \\S4   \S'   S rSrg)r   i  .r   c                 ,    [        U R                  5      $ rJ   )iterr   r  s    r9   __iter__MultipleResults.__iter__  s    DKK  r;   r?   N)	r@   rA   rB   rC   rn  r*   r   r  rE   r?   r;   r9   r   r     s    "c'N!r;   r   r7  c                      [        U 5      $ )a  This function can be used to pass multiple results to the target(s) of
a rule. Just use ``return multiple(result1, result2, ...)`` in your rule.

It is also possible to use ``return multiple()`` with no arguments in
order to end a rule without passing any result.
)r   )r7  s    r9   r   r     s     4  r;   c           	         Ub'  U (       a  [        SU < SU< S/ U QUP7< S35      eU4n / nU  H  n[        U[        5      (       d4  Sn[        U[        5      (       a  US-  n[        XC[	        U5      4-  5      e[        U[        5      (       aR  [        U[
        5      (       a  [        SUR                   S3S	S
SS9  UR                  n[        U[        5      (       a  MR  UR                  U5        M     [        U5      $ )z4Single validator and converter for target arguments.zPassing both targets=z and target=z is redundant - pass targets=z	 instead.zBGot invalid target %r of type %r, but all targets must be Bundles.z
It looks like you passed `one_of(a, b)` or `a | b` as a target.  You should instead pass `targets=(a, b)` to add the return value of this rule to both the `a` and `b` bundles, or define a rule for each target if it should be added to exactly one.zUsing consumes(z`) doesn't makes sense in this context.  This will be an error in a future version of Hypothesis.z
2021-09-08F   )sincehas_codemod
stacklevel)
r   r6   ra  r+   rK   rm  r.   r   rd   rn  )r   r  converted_targetstmsgs        r9   _convert_targetsr    s   !'{,vj I,,>g,>v,>+AL  )!V$$VC!]++6 "#DG"455F##!^,, %affX .O O& %  A F## 	  #- . "##r;   hypothesis_stateful_rule#hypothesis_stateful_initialize_rule!hypothesis_stateful_preconditionshypothesis_stateful_invariant.r!  c                 >    U R                   R                  S5      S   $ )Nz	<locals>.)rB   rsplit)r!  s    r9   r  r    s     >>  -b11r;   )r  r   r  kwargsc                     g rJ   r?   r   r  r  s      r9   r   r          r;   )r   c                     g rJ   r?   r  r   r  s      r9   r   r          r;   )r  r   ).Nc                     g rJ   r?   r  s      r9   r   r     r  r;   r?   )r   r  c                 r   ^^ [        X5      mTR                  5        H  u  p4[        XCS9  M     UU4S jnU$ )a  Decorator for RuleBasedStateMachine. Any Bundle present in ``target`` or
``targets`` will define where the end result of this function should go. If
both are empty then the end result will be discarded.

``target`` must be a Bundle, or if the result should be replicated to multiple
bundles you can pass a tuple of them as the ``targets`` argument.
It is invalid to use both arguments for a single rule.  If the result
should go to exactly one of several bundles, define a separate rule for
each case.

kwargs then define the arguments that will be passed to the function
invocation. If their value is a Bundle, or if it is ``consumes(b)``
where ``b`` is a Bundle, then values that have previously been produced
for that bundle will be provided. If ``consumes`` is used, the value
will also be removed from the bundle.

Any other kwargs should be strategies and values from them will be
provided.
r   c                   >^  [        T [        S 5      (       a  [        [        T 5       S35      e[        T [        S 5      n[        T [
        S 5      nUb  [        [        T 5       S35      eUb  [        [        T 5       S35      e[        T [        S5      n[        TTT US9n[        T 5      U 4S j5       n[        U[        U5        U$ )Nz} is used with both @rule and @invariant, which is not allowed. A function may be either a rule or an invariant, but not both.z; has been decorated with @rule twice, which is not allowed.J has been decorated with both @rule and @initialize, which is not allowed.r?   r   r   r   rI  c                     > T" U 0 UD6$ rJ   r?   r7  r  r!  s     r9   rule_wrapper*rule.<locals>.accept.<locals>.rule_wrappera      d%f%%r;   
r   r  r   r  r  r  r  r   r%   setattrr!  existing_ruleexisting_initialize_rulerI  r   r  r  r  s   `     r9   acceptrule.<locals>.acceptE  s    1&--#!!$% &+ + 
  ;5#*1.Dd#K $#!!$% &   $/#!!$% &5 5 
  #7<%'	
 
	& 
	& 	k40r;   r  r   r-   r   r  r  r   r   r  r  s     `   @r9   r   r   (  s7    2 )9q! !F Mr;   c                     g rJ   r?   r  s      r9   
initializer  l  r  r;   c                     g rJ   r?   r  s      r9   r  r  v  r  r;   c                     g rJ   r?   r  s      r9   r  r  }  r  r;   c                 r   ^^ [        X5      mTR                  5        H  u  p4[        XCS9  M     UU4S jnU$ )a  Decorator for RuleBasedStateMachine.

An initialize decorator behaves like a rule, but all ``@initialize()`` decorated
methods will be called before any ``@rule()`` decorated methods, in an arbitrary
order.  Each ``@initialize()`` method will be called exactly once per run, unless
one raises an exception - after which only the ``.teardown()`` method will be run.
``@initialize()`` methods may not have preconditions.
r  c                   >^  [        T [        S 5      (       a  [        [        T 5       S35      e[        T [        S 5      n[        T [
        S 5      nUb  [        [        T 5       S35      eUb  [        [        T 5       S35      e[        T [        S5      nU(       a  [        [        T 5       S35      e[        TTT US9n[        T 5      U 4S j5       n[        U[
        U5        U$ )Nz is used with both @initialize and @invariant, which is not allowed. A function may be either an initialization rule or an invariant, but not both.r  zA has been decorated with @initialize twice, which is not allowed.r?    has been decorated with both @initialize and @precondition, which is not allowed. An initialization rule runs unconditionally and may not have a precondition.r  c                     > T" U 0 UD6$ rJ   r?   r  s     r9   r  0initialize.<locals>.accept.<locals>.rule_wrapper  r  r;   r  r  s   `     r9   r  initialize.<locals>.accept  s$   1&--#!!$% &6 6 
  ;5#*1.Dd#K $#!!$% &5 5  $/#!!$% &( (   #7<#!!$% &H H 
 %'	
 
	& 
	& 	4d;r;   r  r  s     `   @r9   r  r    s7     )9q! &P Mr;   c                        \ rS rSr% \\S'   Srg)rq   i  r   r?   N)r@   rA   rB   rC   r\  r   rE   r?   r;   r9   rq   rq     s    
Ir;   rq   rF  c                    ^  U 4S jnU$ )aa  Decorator to apply a precondition for rules in a RuleBasedStateMachine.
Specifies a precondition for a rule to be considered as a valid step in the
state machine, which is more efficient than using :func:`~hypothesis.assume`
within the rule.  The ``precond`` function will be called with the instance of
RuleBasedStateMachine and should return True or False. Usually it will need
to look at attributes on that instance.

For example::

    class MyTestMachine(RuleBasedStateMachine):
        state = 1

        @precondition(lambda self: self.state != 0)
        @rule(numerator=integers())
        def divide_with(self, numerator):
            self.state = numerator / self.state

If multiple preconditions are applied to a single rule, it is only considered
a valid step when all of them return True.  Preconditions may be applied to
invariants as well as rules.
c           
        >^  [        T 5      U 4S j5       n[        T [        S 5      nUb  [        [	        T 5       S35      e[        T [
        S 5      n[        T [        S 5      nUb<  Ub   e[        R                  " U/ UR                  QTP7S9n[        U[
        U5        U$ Ub<  Ub   e[        R                  " U/ UR                  QTP7S9n[        U[        U5        U$ [        U[        / [        T [        S5      QTP75        U$ )Nc                     > T" U 0 UD6$ rJ   r?   r  s     r9   precondition_wrapper=precondition.<locals>.decorator.<locals>.precondition_wrapper  r  r;   r  )rI  r?   )r%   r   r  r   r  r  r  rr  replacerI  r  r  )r!  r  r  r   r#  new_rulenew_invariantrF  s   `      r9   	decoratorprecondition.<locals>.decorator  sB   		& 
	& $+1.Dd#K #/#!!$% &H H  q+t,A/6	$$$"**$Bd&8&8$B'$BH (+x@ $# "<<'//)L9+B+B)LG)LM (*:MJ $# $$@'!126@@ $#r;   r?   )rF  r  s   ` r9   preconditionr    s    ."$H r;   c                   B    \ rS rSr% \\S'   \\S'   \\S'   S\4S jrSr	g)	r   i	  r   rI  rH  r2   c                     S[        U R                  5       3SU R                  < 3SU R                  < 3/nSSR	                  U5       S3$ )Nz	function=zself.preconditions=zself.check_during_init=z
Invariant(r   r   )r#   r   rI  rH  r   )rM   partss     r9   r  Invariant.__repr__  s[    7FGH"t!!#$&t%%'(

 DIIe,-Q//r;   r?   N)
r@   rA   rB   rC   r   r   r8   r\  r  rE   r?   r;   r9   r   r   	  s    M0# 0r;   r   )rH  rH  c                 6   ^  [        [        T S5        U 4S jnU$ )a<  Decorator to apply an invariant for rules in a RuleBasedStateMachine.
The decorated function will be run after every rule and can raise an
exception to indicate failed invariants.

For example::

    class MyTestMachine(RuleBasedStateMachine):
        state = 1

        @invariant()
        def is_nonzero(self):
            assert self.state != 0

By default, invariants are only checked after all
:func:`@initialize() <hypothesis.stateful.initialize>` rules have been run.
Pass ``check_during_init=True`` for invariants which can also be checked
during initialization.
rH  c                 h  >^  [        T [        S 5      (       d  [        T [        S 5      (       a  [        [	        T 5       S35      e[        T [
        S 5      nUb  [        [	        T 5       S35      e[        T [        S5      n[        T UTS9n[        T 5      U 4S j5       n[        U[
        U5        U$ )NzI has been decorated with both @invariant and @rule, which is not allowed.z@ has been decorated with @invariant twice, which is not allowed.r?   )r   rI  rH  c                     > T" U 0 UD6$ rJ   r?   r  s     r9   invariant_wrapper4invariant.<locals>.accept.<locals>.invariant_wrapper@  r  r;   )
r   r  r  r   r  r  r  r   r%   r  )r!  existing_invariantrI  rL  r  rH  s   `    r9   r  invariant.<locals>.accept-  s    1k4((GA7Mt,T,T#!!$% &/ /  %Q(8$?)#!!$% &( (   #7<'/
 
	& 
	& 	!#3U;  r;   )r&   r8   )rH  r  s   ` r9   r#  r#    s    & t&(;<!4 Mr;   c                   F   ^  \ rS rSrS\SS4U 4S jjrS rS rS rS	r	U =r
$ )
r   iJ  r   r2   Nc                   > [         TU ]  5         Xl        UR                  R	                  5       U l        [
        R                  " [        U R                   Vs1 s H  o"R                  R                  iM     snS9SU4S9U l
        U R                  R                  S S9  [
        R                  " U R                  5      U l        g s  snf )N)at_least_one_ofzenabled rules)keyc                     [        U R                  5      [        U R                  5      U R                  R
                  4$ rJ   )rk  r   r  r   r   r@   )r   s    r9   <lambda>'RuleStrategy.__init__.<locals>.<lambda>]  s,    t||$DNN#&&r;   )r   r   r   r   r   r   sharedr)   r   r@   enabled_rules_strategysortsampled_fromrules_strategy)rM   r   rr   s      r9   r   RuleStrategy.__init__K  s    ]]'')
&(ii$**,U*QZZ-@-@*,UV '*'
# 	

 	 	
 !oodjj9% -Vs   Cc                 v    U R                   R                   SU R                  R                   R                   S3$ )Nz	(machine=z({...})))r   r@   r   r  s    r9   r  RuleStrategy.__repr__e  s2    ..))*)DLL4J4J4S4S3TT^__r;   c                   ^ ^ [        U 4S jT R                   5       5      (       d^  SR                  T R                   Vs/ s H  o"R                  R                  PM     sn5      nST R
                  < SU 3n[        U5      S eUR                  T R                  5      mUU 4S jnUR                  T R                  R                  U5      5      n0 nUR                  R                  5        H  u  px UR                  U5      Xg'   M     X&4$ s  snf ! [         a3  n	UR                  R                  n
[        U	SU< SU< SU
 35        e S n	A	ff = f)	Nc              3   F   >#    U  H  nTR                  U5      v   M     g 7frJ   )is_valid)rs   r   rM   s     r9   ru   'RuleStrategy.do_draw.<locals>.<genexpr>i  s     >:44==&&:s   !r   z#No progress can be made from state z<, because no available rule had a True precondition. rules: c                 ~   > TR                  U 5      =(       a%    TR                  U R                  R                  5      $ rJ   )r	  
is_enabledr   r@   )r  feature_flagsrM   s    r9   rule_is_enabled-RuleStrategy.do_draw.<locals>.rule_is_enableds  s.     ==#U(@(@ATAT(UUr;   zwhile generating z from z
 for rule )anyr   r   r   r@   r   r   r   r  r  filterrf  r   	Exceptionr   )rM   r   r   r   r  r  r   r   stratr   rnamer  s   `          @r9   r  RuleStrategy.do_drawh  s7   >4::>>>II$**M*$}}55*MNE5dll5E FBBGJ  $C(d2		$"="=>	V yy,,33ODE	11779HA#yy/	 :   9 N0  .. 1!fUIZPUwWXs    D3D
E.E

Ec                    UR                    H/  nU R                  R                  UR                  5      (       a  M/    g   U R                  R                  nU R                  R
                  R                   SUR                  R                   S3nUR                   H?  nU" U R                  5      nU S[        U5       3nX7   R                  US9  U(       a  M?    g   g)NFz, rule ,z precondition )	conditionT)r   r   r  r   r|   r   rB   r   r@   rI  r#   update_count)rM   r   b
predicatesdescpredmeets_precondwheres           r9   r	  RuleStrategy.is_valid  s    A<<&&qvv..  \\;;
,,((556gdmm>T>T=UUVW&&D .MfN+J4+P*QRE**]*C = ' r;   )r  r   r   r  )r@   rA   rB   rC   rz   r   r  r  r	  rE   r   r   s   @r9   r   r   J  s-    : 5 :$ :4`!@ r;   r   )qrD   r   rr  r  collections.abcr   r   r   r   r   	functoolsr   ior	   timer
   typingr   r   r   r   unittestr   r   r   r   hypothesis._settingsr   r   r   r   hypothesis.controlr   r   hypothesis.corer   r   hypothesis.errorsr   r   r   hypothesis.internal.compatr   r   %hypothesis.internal.conjecture.enginer   )hypothesis.internal.conjecture.junkdrawerr   $hypothesis.internal.conjecture.utilsr   hypothesis.internal.healthcheckr    !hypothesis.internal.observabilityr!   hypothesis.internal.reflectionr"   r#   r$   r%   hypothesis.internal.validationr&   hypothesis.reportingr'   r(   ,hypothesis.strategies._internal.featureflagsr)   *hypothesis.strategies._internal.strategiesr*   r+   r,   r-   hypothesis.utils.deprecationr.   hypothesis.vendor.prettyr/   r0   r   objectr8   r:   r=   rG   r   r   rK   r   r   rz   r   runnerr  rl  ra  rm  r  r   r   r  r  r  r  r  	_RuleType_RuleWrapperr\  r  r   r  rq   r  r   r#  r   r?   r;   r9   <module>r<     s      8 8 (    3 3  ' M M L + 
 9 = H E = C  6 : H  : :CL./KL 0v 0$ 0% %

7 
7 (,Wt BFRS 6	0t 	0 d#  $U$&6 U$p e$-! -! %-!` 		$n $*C+^B C+L4VBZ 4
"VBZ "N2$6 "$ d#!hrl ! $!!A !/!, !"$J )> : 2  S/"-223	22672c 2c 2F 
 fRj!  	
 " 
 
7:bz$4FT" 
 
  #  	
 x	"#Xi%889 
 8: $@fRj!$44@ 2J@ 	@
 "(9"5!68K!KLL@H 
 fRj!  	
 " 
 
7:bz$4FT" 
 
  #  	
 x	"#Xi%889 
 8: $:fRj!$44: 2J: 	:
 "(9"5!68K!KLL:z d#  $;(C5$;/ ;HhZ=Q4R ;| d#0 0 $0 ,1 /D /Xxj(>R5S /dL> Lr;   