
    ^hh                     t   S SK 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  S SKJrJr  S=rrS rS r " S	 S
\5      r " S S\5      r " S S\S9r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S  S!\5      rg)"    N)Enum)AnyDictListOptionalSet)Symbol)flow)ExternalCallHandler
HasGetitemc                      g)z
Just a marker decorator to indicate that the handler is used for functions / methods
named differently from the decorated function / method
N )_methodss    Y/home/james-whalen/.local/lib/python3.13/site-packages/ipyflow/annotations/annotations.pyhandler_forr      s    
 	    c                      g)z
Just a marker decorator indicating that the class / function belongs to the
module indicated in the parameter, as opposed to the one indicated by the file name
of the containing .pyi file.
Nr   )_moduless    r   moduler      s     	r   c                       \ rS rSrSrSrg)UpsertSymbol   z@
Stub for indicating that a value is upserted as a side effect.
r   N__name__
__module____qualname____firstlineno____doc____static_attributes__r   r   r   r   r      s    r   r   c                       \ rS rSrSrSrg)Mutate%   z?
Stub for indicating that a value is mutated as a side effect.
r   Nr   r   r   r   r!   r!   %   s     	r   r!   c                   L    \ rS rSrSrS\SS4S jrS\S\\	\\
4      4S jrS	rg)
SymbolMatcher-   z1
Indicates that the annotation matches a symbol.
	bind_namereturnNc                     Xl         g Nr&   )selfr&   s     r   __init__SymbolMatcher.__init__2   s    "r   symc                     U R                   U0$ )z
:param sym: the symbol against which the matcher is being tested
:return: if `sym` matches, a dictionary (possibly empty) of any additional bindings; otherwise, None.
r*   r+   r.   s     r   matchesSymbolMatcher.matches5   s    
 $$r   r*   )r   r   r   r   r   strr,   r	   r   r   r   r1   r   r   r   r   r$   r$   -   s:    ## #$ #%6 %htCH~&> %r   r$   )	metaclassc                   V   ^  \ rS rSrS\SS4U 4S jjrS\S\\\\	4      4S jr
SrU =r$ )	Ref=   r&   r'   Nc                 2   > [         TU ]  U5        0 U l        g r)   )superr,   existing_bindings)r+   r&   	__class__s     r   r,   Ref.__init__>   s    #!#r   r.   c                 X    U R                   R                  U R                  5      UL a  0 $ g r)   )r:   getr&   r0   s     r   r1   Ref.matchesB   s'    !!%%dnn5<Ir   )r:   )r   r   r   r   r3   r,   r	   r   r   r   r1   r   __classcell__r;   s   @r   r6   r6   =   s;    $# $$ $6 htCH~&>  r   r6   c                   d   ^  \ rS rSrSrS\S\\   SS4U 4S jjrS\	S\
\\\4      4S	 jrS
rU =r$ )AllOfI   z9
Indicates all of the subscripted matchers should match.
r&   matchersr'   Nc                 0   > [         TU ]  U5        X l        g r)   r9   r,   rE   r+   r&   rE   r;   s      r   r,   AllOf.__init__N       # r   r.   c                     0 nU R                    H*  nUR                  U5      nUc    g UR                  U5        M,     XU R                  '   U$ r)   rE   r1   updater&   r+   r.   bindingsmatchermatcher_bindingss        r   r1   AllOf.matchesR   sM    }}G&s3' 01 % $' r   rE   r   r   r   r   r   r3   r   r$   r,   r	   r   r   r   r1   r   r@   rA   s   @r   rC   rC   I   sL    !# !m1D ! !	6 	htCH~&> 	 	r   rC   c                   d   ^  \ rS rSrSrS\S\\   SS4U 4S jjrS\	S\
\\\4      4S	 jrS
rU =r$ )AnyOf^   zj
Indicates that at least one of the subscripted matchers should match.
If multiple match, the first wins.
r&   rE   r'   Nc                 0   > [         TU ]  U5        X l        g r)   rG   rH   s      r   r,   AnyOf.__init__d   rJ   r   r.   c                     S nU R                    H5  nUR                  U5      nUc  M  U=(       d    0 nUR                  U5        M7     XU R                  '   U$ r)   rL   rN   s        r   r1   AnyOf.matchesh   sS    }}G&s3+#>r 01	 %
 $' r   rS   rT   rA   s   @r   rV   rV   ^   sL    
!# !m1D ! !6 htCH~&>  r   rV   c                   H   ^  \ rS rSrSrS\S\\\\	4      4U 4S jjr
SrU =r$ )Displays   zR
Stub for referencing that a value represents stdout / stderr / display contents.
r.   r'   c                 R   > [        5       R                  UL a  [        TU ]  U5      $ g r)   )r
   display_symr9   r1   )r+   r.   r;   s     r   r1   Display.matchesx   s%    6$7?3''r   r   )r   r   r   r   r   r	   r   r   r3   r   r1   r   r@   rA   s   @r   r]   r]   s   s-    6 htCH~&>  r   r]   c                   b   ^  \ rS rSrSrSS\S\SS4U 4S jjjrS\S\	\
\\4      4S	 jrS
rU =r$ )
FileSystem   zD
Stub for referencing that a value represents file system contents.
r&   
is_literalr'   Nc                 0   > [         TU ]  U5        X l        g r)   )r9   r,   re   )r+   r&   re   r;   s      r   r,   FileSystem.__init__   s    #$r   r.   c                 H   UR                   [        5       R                  La  g U R                  (       aX  [        R
                  R                  UR                  5      [        R
                  R                  U R                  5      :X  a  0 $ S $ U R                  UR                  0$ r)   )
containing_namespacer
   fsre   ospathabspathnamer&   objr0   s     r   r1   FileSystem.matches   su    ##46994?? 77??388,0OO   NNCGG,,r   )re   )F)r   r   r   r   r   r3   boolr,   r	   r   r   r   r1   r   r@   rA   s   @r   rc   rc      sL    %# %4 %D % %
-6 
-htCH~&> 
- 
-r   rc   c                       \ rS rSrSrSrSrg)MatcherRelation   childrenparentsr   N)r   r   r   r   CHILDRENPARENTSr   r   r   r   rs   rs      s    HGr   rs   c            
          ^  \ rS rSrSrS\S\S\\   S\	SS4
U 4S	 jjr
S
\S\\\\4      4S jrS\S\\\\4      4S jrSrU =r$ )	_Relation   z`
Matcher for indicating a dependency relationship between the symbol and the subscripted values
r&   relationrE   exactr'   Nc                 V   > [         TU ]  U5        X l        X0l        X@l        S U l        g r)   )r9   r,   r|   rE   r}   _remaining_symbols)r+   r&   r|   rE   r}   r;   s        r   r,   _Relation.__init__   s)     	#  
9=r   idxc                 b   U[        U R                  5      :X  a  0 $ U R                  U   n[        U R                  5       Hl  nUR	                  U5      nUc  M  U R                  R                  U5        U R                  US-   5      nU R                  R                  U5        Uc  Mh  XE-  s  $    g )N   )lenrE   listr   r1   discard_matches_helperadd)r+   r   rP   r.   rO   rest_bindingss         r   r   _Relation._matches_helper   s    #dmm$$I--$//0Cs+H##++C0 00q9M##'',(// 1 r   r.   c                 h   U R                   [        R                  :X  aC  UR                  R	                  5        Vs1 s H  o"R
                  (       a  M  UiM     snU l        OyU R                   [        R                  :X  aC  UR                  R	                  5        Vs1 s H  o3R
                  (       a  M  UiM     snU l        O[        SU R                   -  5      eU R                  (       a-  [        U R                  5      [        U R                  5      :w  a  g U R                  S5      $ s  snf s  snf )Nz%not implemented for relation type: %sr   )r|   rs   rx   rv   keysis_anonymousr   rw   childen
ValueErrorr}   r   rE   r   )r+   r.   parchds       r   r1   _Relation.matches   s    ==O333"{{//1'19I9I1'D# ]]o666"{{//1'19I9I1'D# Dt}}TUU::#d556#dmm:LL##A&&''s   D*D*D/4D/)r   r}   rE   r|   )r   r   r   r   r   r3   rs   r   r$   rq   r,   intr   r   r   r   r	   r1   r   r@   rA   s   @r   rz   rz      s    >> "> }%	>
 > 
>3 8DcN+C  '6 'htCH~&> ' 'r   rz   c                   B   ^  \ rS rSrS\S\\   S\SS4U 4S jjrSr	U =r
$ )	Children   r&   rE   r}   r'   Nc                 D   > [         TU ]  U[        R                  X#5        g r)   )r9   r,   rs   rw   r+   r&   rE   r}   r;   s       r   r,   Children.__init__   s     	O$<$<hNr   r   r   r   r   r   r3   r   r$   rq   r,   r   r@   rA   s   @r   r   r      s8    OO(,](;ODHO	O Or   r   c                   B   ^  \ rS rSrS\S\\   S\SS4U 4S jjrSr	U =r
$ )	Parents   r&   rE   r}   r'   Nc                 D   > [         TU ]  U[        R                  X#5        g r)   )r9   r,   rs   rx   r   s       r   r,   Parents.__init__   s     	O$;$;XMr   r   r   rA   s   @r   r   r      s8    NN(,](;NDHN	N Nr   r   ) rk   enumr   typingr   r   r   r   r   ipyflow.data_model.symbolr	   ipyflow.singletonsr
   ,ipyflow.tracing.external_calls.base_handlersr   r   r+   r   r   r   r   r!   r$   r6   rC   rV   r]   rc   rs   rz   r   r   r   r   r   <module>r      s    	  1 1 , # X  z		& 	  	%j % 	- 	M *M *	m 	- -,d 
/' /'dOy ONi Nr   