+
    S_yiC                     2  a R* tR0 t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
Ht ^ RIHt ^ RIHtHtHtHtHtHtHtHtHtHtHtHt ]'       d)   ^RIHt  ! R R]4      t]]]3,          t]P>                  tR	 t  ! R
 R]PB                  ! RR4      4      t"R+R lt#R+R lt$R t%R t&R t'R,R lt(]PR                  PU                  4        U Uu0 uF`  w  r]+! V],4      '       g   K  ]-! V]P\                  ]P^                  ]P`                  ]Pb                  ]Pd                  34      '       g   K^  VkKb  	  upp t3R,R lt4]PR                  PU                  4        U Uu0 uF3  w  r]+! V],4      '       g   K  ]-! V]Pj                  4      '       g   K1  V kK5  	  upp t6]PR                  PU                  4        U Uu0 uF3  w  r]+! V],4      '       g   K  ]-! V]P                  4      '       g   K1  V kK5  	  upp 0 R-m,          t7R t8R t9R t:R t;R t<]Pz                  3t>] ^ k  ^ RI?H@t@ ]>]@3,          t>R tBR tCR tDR tER tF]G! 4       tHR tIR,R  ltJR! tK ! R" R#4      tLR$ tMR% tNR& tO]! RR'7      R( 4       tPR) tQR# u upp i u upp i u upp i   ]A d     Lci ; i).    N)ABCMeta)ModuleexprAST)	lru_cache)CallableDictIterableIteratorListOptionalTupleUnioncastAnyTYPE_CHECKINGType)NodeNGc                   *    ] tR t^,tRtRt^ t^ t^ tRt	R# )EnhancedASTN )
__name__
__module____qualname____firstlineno__first_token
last_tokenlineno
end_linenoend_col_offset__static_attributes__r       0/usr/lib/python3/dist-packages/asttokens/util.pyr   r   ,   s    KJFJNr"   r   c                n    \         P                  V ,          : R\        V4      P                  R4      : 2# )zRReturns a human-friendly representation of a token with the given type and string.:u)tokentok_namereprlstrip)tok_typestrings   &&r#   
token_reprr-   9   s*     NN8,,d6l.A.A#.F	GGr"   c                   *   a  ] tR t^@t o RtR tRtV tR# )Tokenam  
TokenInfo is an 8-tuple containing the same 5 fields as the tokens produced by the tokenize
module, and 3 additional ones useful for this module:

- [0] .type     Token type (see token.py)
- [1] .string   Token (a string)
- [2] .start    Starting (row, column) indices of the token (a 2-tuple of ints)
- [3] .end      Ending (row, column) indices of the token (a 2-tuple of ints)
- [4] .line     Original line (string)
- [5] .index    Index of the token in the list of tokens that it belongs to.
- [6] .startpos Starting character offset into the input text.
- [7] .endpos   Ending character offset into the input text.
c                B    \        V P                  V P                  4      # N)r-   typer,   selfs   &r#   __str__Token.__str__N   s    dii--r"   r   N)r   r   r   r   __doc__r5   r!   __classdictcell____classdict__s   @r#   r/   r/   @   s     . .r"   r/   z0type string start end line index startpos endposc                f    V P                   V8H  ;'       d    VRJ ;'       g    V P                  V8H  # )zVReturns true if token is of the given type and, if a string is given, has that string.N)r2   r,   r'   r+   tok_strs   &&&r#   match_tokenr>   S   s0     
x		P	PW_%O%O8OPr"   c                    \        WV4      '       gW   \        R\        W4      : R\        V 4      : RV P                  ^ ,          : RV P                  ^,          ^,           : 24      hR# )z
Verifies that the given token is of the expected type. If tok_str is given, the token string
is verified too. If the token doesn't match, raises an informative ValueError.
zExpected token z, got z	 on line z col N)r>   
ValueErrorr-   strstartr<   s   &&&r#   expect_tokenrC   Y   sR     
Ug	.	.
#SZkk!nnekk!nq(* + + 
/r"   c                f    V \         P                  \         P                  \         P                  39   # )zO
These are considered non-coding tokens, as they don't affect the syntax tree.
)r'   NLCOMMENTENCODING)
token_types   &r#   is_non_coding_tokenrI   e   s"    
 
%--@	@@r"   c                    \         P                  ! \        \        . \        3,          \
        P                  ! V 4      P                  4      4      # )z7
Generates standard library tokens for the given code.
)tokenizegenerate_tokensr   r   rA   ioStringIOreadline)texts   &r#   rL   rL   m   s4     
	!	!$xC'8"++d:K:T:T"U	VVr"   c                >    \        V R4      '       d   \        # \        # )z
Returns a function which yields all direct children of a AST node,
skipping children that are singleton nodes.
The function depends on whether ``node`` is from ``ast`` or from the ``astroid`` module.
get_children)hasattriter_children_astroiditer_children_astnodes   &r#   iter_children_funcrX   x   s     #*$"?"?	VEVVr"   c                 X    V'       g   \        V 4      '       d   . # V P                  4       # r1   )is_joined_strrR   )rW   include_joined_strs   &&r#   rT   rT      s#    	d 3 3I				r"   c              #   b  "   V'       g   \        V 4      '       d   R # \        V \        P                  4      '       d8   \	        V P
                  V P                  4       F  w  r#Ve   Vx  Vx  K  	  R # \        P                  ! V 4       F  pVP                  \        9  g   K  Vx  K   	  R # 5ir1   )
rZ   
isinstanceastr	   zipkeysvaluesiter_child_nodes	__class__
SINGLETONS)rW   r[   keyvaluechilds   &&   r#   rU   rU      s     	d 3 3
chh DIIt{{3		k 4 ##D)e j(k *s   BB/%
B/c                <    V P                   P                  \        9   # )z+Returns whether node is an expression node.)rc   r   expr_class_namesrV   s   &r#   is_exprrj           
	 	 $4	44r"   c                <    V P                   P                  \        9   # )z)Returns whether node is a statement node.)rc   r   stmt_class_namesrV   s   &r#   is_stmtrn      rk   r"   c                4    V P                   P                  R8H  # )z&Returns whether node is a module node.r   rc   r   rV   s   &r#   	is_modulerq      s     
	 	 H	,,r"   c                4    V P                   P                  R8H  # )zFReturns whether node is a JoinedStr node, used to represent f-strings.	JoinedStrrp   rV   s   &r#   rZ   rZ      s    
 
	 	 K	//r"   c                4    V P                   P                  R8H  # )zSReturns whether node is an `Expr` node, which is a statement that is an expression.Exprrp   rV   s   &r#   is_expr_stmtrv      s     
	 	 F	**r"   )Constc                "    \        V \        4      # )z(Returns whether node is a Constant node.)r]   CONSTANT_CLASSESrV   s   &r#   is_constantrz      s     
D*	++r"   c                L    \        V 4      ;'       d    V P                  \        J # )z)Returns whether node is an Ellipsis node.)rz   rf   EllipsisrV   s   &r#   is_ellipsisr}      s      
T		5	5tzzX55r"   c                4    V P                   P                  R8H  # )z2Returns whether node is a starred expression node.Starredrp   rV   s   &r#   
is_starredr      s     
	 	 I	--r"   c           	         V P                   P                  R9   ;'       g]    V P                   P                  R8H  ;'       d<    \        \        \        \        \        P                  V 4      P                  4      4      # )z?Returns whether node represents a slice, e.g. `1:2` in `x[1:2]`r   )SliceExtSlice)	rc   r   anymapis_slicer   r^   r   eltsrV   s   &r#   r   r      sb     nn!66  
..
!
!W
, = =#hSYY 5 : :;<	r"   c                    V P                   P                  R 8H  ;'       dg    \        V \        P                  4      '       * ;'       d@    V P
                  V P                  u;J ;'       d    V P                  u;J ;'       d    RJ # u # )r   N)rc   r   r]   r^   r   loweruppersteprV   s   &r#   is_empty_astroid_slicer      sn     nn( 8 8sww'
'8 8
**


7
7dii
7
74
7 8r"   c                   V'       g   R p\        V 4      p\        4       pRpV R\        3.pV'       d   VP                  4       w  rxp	V	\        J dk   Wt9  g   Q hVP	                  V4       V! Wx4      w  rVP                  WxV34       \        V4      pV! V4       F  pVP                  WV
\        34       K  	  K  V! Wx\        \        \        ,          V	4      4      pK  V# )a  
Scans the tree under the node depth-first using an explicit stack. It avoids implicit recursion
via the function call stack to avoid hitting 'maximum recursion depth exceeded' error.

It calls ``previsit()`` and ``postvisit()`` as follows:

* ``previsit(node, par_value)`` - should return ``(par_value, value)``
      ``par_value`` is as returned from ``previsit()`` of the parent.

* ``postvisit(node, par_value, value)`` - should return ``value``
      ``par_value`` is as returned from ``previsit()`` of the parent, and ``value`` is as
      returned from ``previsit()`` of this node itself. The return ``value`` is ignored except
      the one for the root node, which is returned from the overall ``visit_tree()`` call.

For the initial node, ``par_value`` is None. ``postvisit`` may be None.
c                     R # r1   r   )rW   pvaluerf   s   &&&r#   <lambda>visit_tree.<locals>.<lambda>  s    Dr"   N)rX   set	_PREVISITpopaddappendleninsertr   r   r/   )rW   previsit	postvisititer_childrendoneretstackcurrent	par_valuerf   r   
post_valueinsns   &&&           r#   
visit_treer      s    $ 
0I$T*-	$#$	"
#% %		G	   
hhw#G7fllG
34 JcW%!Sfi01 & g$x*FGc	*r"   c              #    "   \        V 4      p\        4       pV .pV'       d[   VP                  4       pWS9  g   Q hVP                  V4       Vx  \	        V4      pV! WQ4       F  pVP                  Wg4       K  	  Kb  R# 5i)a#  
Recursively yield all descendant nodes in the tree starting at ``node`` (including ``node``
itself), using depth-first pre-order traversal (yieling parents before their children).

This is similar to ``ast.walk()``, but with a different order, and it works for both ``ast`` and
``astroid`` trees. Also, as ``iter_children()``, it skips singleton nodes generated by ``ast``.

By default, ``JoinedStr`` (f-string) nodes and their contents are skipped
because they previously couldn't be handled. Set ``include_joined_str`` to True to include them.
N)rX   r   r   r   r   r   )rW   r[   r   r   r   r   r   cs   &&      r#   walkr   )  su      %T*-	$&%iikGHHW
M e*C77ll3 8 	s    A?AA?c                    ^ p. p\        V4       F,  w  rEpVP                  WV 4       VP                  V4       TpK.  	  VP                  WR 4       RP                  V4      # )a\  
Replaces multiple slices of text with new values. This is a convenience method for making code
modifications of ranges e.g. as identified by ``ASTTokens.get_text_range(node)``. Replacements is
an iterable of ``(start, end, new_text)`` tuples.

For example, ``replace("this is a test", [(0, 4, "X"), (8, 9, "THE")])`` produces
``"X is THE test"``.
N )sortedr   join)rP   replacementsppartsrB   endnew_texts   &&     r#   replacer   F  sc     !
% &| 4u8	LL	LLA !5 ,,tBx	r"   c                   0   a  ] tR tRt o RtR tR tRtV tR# )NodeMethodsiZ  zW
Helper to get `visit_{node_type}` methods given a node's class and cache the results.
c                    / V n         R # r1   _cacher3   s   &r#   __init__NodeMethods.__init__^  s	    DKr"   c                    V P                   P                  V4      pV'       gF   RVP                  P                  4       ,           p\	        WVP
                  4      pW0P                   V&   V# )z
Using the lowercase name of the class as node_type, returns `obj.visit_{node_type}`,
or `obj.visit_default` if the type-specific method is not found.
visit_)r   getr   r   getattrvisit_default)r4   objclsmethodnames   &&&  r#   r   NodeMethods.getb  sS     [[__S!F**,,ds#"3"34fkk#Mr"   r   N)	r   r   r   r   r7   r   r   r!   r8   r9   s   @r#   r   r   Z  s      r"   r   c              #  ~  "   . pV  F  pVP                   \        P                  \        P                  \        P                  39   d>   V'       d#   VR,          P
                  VP                  8X  d   VP                  V4       K~  \        V4       F  pVx  K	  	  . pVx  K  	  \        V4       F  pVx  K	  	  R# 5i)a  
Fixes tokens yielded by `tokenize.generate_tokens` to handle more non-ASCII characters in identifiers.
Workaround for https://github.com/python/cpython/issues/68382.
Should only be used when tokenizing a string that is known to be valid syntax,
because it assumes that error tokens are not actually errors.
Combines groups of consecutive NAME, NUMBER, and/or ERRORTOKEN tokens into a single NAME token.
N)	r2   rK   NAME
ERRORTOKENNUMBERr   rB   r   combine_tokens)original_tokensgrouptokcombined_tokens   &   r#   patched_generate_tokensr   p  s      E
((x}}h&9&98??K
KE"IMMSYY6S,U3N
 4	  )/ 0s   AB=A-B=c                    \         ;QJ d    R  V  4       F  '       g   K   RM	  RM! R  V  4       4      '       d*   \        V  Uu0 uF  qP                  kK  	  up4      ^8w  d   V # \        P                  ! \        P
                  RP                  R V  4       4      V ^ ,          P                  V R,          P                  V ^ ,          P                  R7      .# u upi )c              3   Z   "   T F!  qP                   \        P                  8H  x  K#  	  R # 5ir1   )r2   rK   r   ).0r   s   & r#   	<genexpr>!combine_tokens.<locals>.<genexpr>  s     @%3xx8...%s   )+TFr   c              3   8   "   T F  qP                   x  K  	  R # 5ir1   )r,   )r   ts   & r#   r   r     s     /Axxs   )r2   r,   rB   r   liner   )	r   r   r   rK   	TokenInfor   r   rB   r   )r   r   s   & r#   r   r     s    3@%@333@%@@@C]bHc]bVY]bHcDdhiDil]]ww///Ahnn"IMM1X]]  Ids   Cc                    \        V 4      ! V 4       Uu. uF2  p\        V4      '       g   \        V4      P                  R9   g   K0  VNK4  	  ppV'       d   \	        VR,          4      # V # u upi )zk
If the given AST node contains multiple statements, return the last one.
Otherwise, just return the node.
)excepthandlerExceptHandler
match_case	MatchCase	TryExcept
TryFinallyr   )rX   rn   r2   r   	last_stmt)rW   rg   child_stmtss   &  r#   r   r     sm     *$/5
5eu~~e-- 2  
E5  
 [_%%	+
s   -A*A*)maxsizec                   a Ro\         P                  ! S4      p \         P                  ! V 4       Uu. uF'  p\        V\         P                  4      '       g   K%  VNK)  	  ppV Uu. uF  qP
                  VP                  3NK  	  pp\        \        V4      4      \        V4      8H  p\        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      pT;'       d    T# u upi u upi )a  
The positions attached to nodes inside f-string FormattedValues have some bugs
that were fixed in Python 3.9.7 in https://github.com/python/cpython/pull/27729.
This checks for those bugs more concretely without relying on the Python version.
Specifically this checks:
 - Values with a format spec or conversion
 - Repeated (i.e. identical-looking) expressions
 - f-strings implicitly concatenated over multiple lines.
 - Multiline, triple-quoted f-strings.
z(
    f"a {b}{b} c {d!r} e {f:g} h {i:{j}} k {l:{m:n}}"
    f"a {b}{b} c {d!r} e {f:g} h {i:{j}} k {l:{m:n}}"
    f"{x + y + z} {x} {y} {z} {z} {z!a} {z:z}"
    f'''
    {s} {t}
    {u} {v}
    '''
  )c              3   l   <"   T F)  p\         P                  ! SV4      VP                  8H  x  K+  	  R # 5ir1   )r^   get_source_segmentid)r   rW   sources   & r#   r   )fstring_positions_work.<locals>.<genexpr>  s.        64(DGG3s   14FT)
r^   parser   r]   Namer   
col_offsetr   r   all)treerW   
name_nodesname_positionspositions_are_uniquecorrect_source_segmentsr   s         @r#   fstring_positions_workr     s    & 
6	$!$$N:dCHH3M*N?IJzt[[$//2z.JS01S5HHC   CCC     
	9	9"99 OJs   "C-C-% C2c                   \         P                  R8  d   R# \        V RR7       F  p\        V\        P
                  4      '       g   K%  VP                   F  p\        VRR4       \        V\        P                  4      '       g   K2  \        4       '       g*   \        VP                  4       F  p\        VRR4       K  	  VP                  '       g   K  \        VP                  RR4       K  	  K  	  R# )zs
Add a special attribute `_broken_positions` to nodes inside f-strings
if the lineno/col_offset cannot be trusted.
NT)r[   _broken_positions)      )sysversion_infor   r]   r^   rs   ra   setattrFormattedValuer   rf   format_spec)r   	joinedstrpartrg   s   &   r#   annotate_fstring_nodesr     s     	  6ii//  d'.	D#,,	-	-%''DJJ'eE.5 ( 
$""$7
> ! 7r"   c                Z    V ^8  d   Qh/ ^ \         9   d   \        \        R3,          ;R&   # )   .ry   )__conditional_annotations__r   r   )formats   "r#   __annotate__r     s#    

v 5 4%c	" 4w r"   r1   )F>   rw   DelAttrDelName
AssignAttr
AssignName)Sr   r^   collectionsrM   r   r'   rK   abcr   r   r   r   	functoolsr   typingr   r	   r
   r   r   r   r   r   r   r   r   r   astroid_compatr   r   AstNoder   r-   
namedtupler/   r>   rC   rI   rL   rX   rT   __dict__itemsr]   r2   
issubclassexpr_contextboolopoperatorunaryopcmpoprd   rU   stmtrm   ri   rj   rn   rq   rZ   rv   Constantry   astroid.nodesrw   ImportErrorrz   r}   r   r   r   objectr   r   r   r   r   r   r   r   r   r   r  )r   r   r   s   00@r#   <module>r     s   
  	 
    ! !     $C  +v%&'  )H.K""7,^_ .&Q	+AWW  LL..0 c0DAJq$4GaS--szz3<<VYV_V_`a a0 c
, #&,,"4"4"6 H"6$!!!T* /9!SXX/F A"6 H #&<<#5#5#7 H#741!!T* /9!SXX/F Q#7 HOP 5
5
-
0+ '*ll_  4!uh
,6. H	(V:( ,2. 4: :>?K
c4HHP  sI   I:-AI:5I:!J 9J J ;JJ.J"J JJ