Ë
    =OUj�C  ã                   óX  — U d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZ  G d„ de j8                  ¬	«      Z G d
„ de«      Z G d„ de«      ZdZ ee!df   e"d<   ejF                  dd dk(  r
e dz  Z e dz  Z ddede$fd„Z%y)é    N)ÚModule)ÚIterableÚIteratorÚListÚOptionalÚTupleÚAnyÚcasté   )ÚLineNumbers)ÚAstNodeÚTokenÚ	TokenInfoÚmatch_tokenÚis_non_coding_tokenÚpatched_generate_tokensÚ	last_stmtÚannotate_fstring_nodesÚgenerate_tokensÚ	is_moduleÚis_stmtc                   ó¦   — e Zd Zdededdfd„Zej                  dedede	e	e
e
f   e	e
e
f   f   fd„«       Zddedede	e
e
f   fd	„Zddededefd
„Zy)ÚASTTextBaseÚsource_textÚfilenameÚreturnNc                 óV   — || _         t        |«      }|| _        t        |«      | _        y ©N)Ú	_filenameÚstrÚ_textr   Ú_line_numbers)Úselfr   r   s      úd/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/asttokens/asttokens.pyÚ__init__zASTTextBase.__init__   s)   € Ø€D„Nô
 �kÓ"€Kà€D„JÜ$ [Ó1€DÕó    ÚnodeÚpaddedc                 ó   — t         ‚)áÎ  
    Returns two ``(lineno, col_offset)`` tuples for the start and end of the given node.
    If the positions can't be determined, or the nodes don't correspond to any particular text,
    returns ``(1, 0)`` for both.

    ``padded`` corresponds to the ``padded`` argument to ``ast.get_source_segment()``.
    This means that if ``padded`` is True, the start position will be adjusted to include
    leading whitespace if ``node`` is a multiline statement.
    )ÚNotImplementedError©r#   r'   r(   s      r$   Úget_text_positionszASTTextBase.get_text_positions*   s
   € ô Ðr&   c                 ó�   — | j                  ||«      \  }} | j                  j                  |Ž  | j                  j                  |Ž fS )a  
    Returns the (startpos, endpos) positions in source text corresponding to the given node.
    Returns (0, 0) for nodes (like `Load`) that don't correspond to any particular text.

    See ``get_text_positions()`` for details on the ``padded`` argument.
    )r-   r"   Úline_to_offset©r#   r'   r(   ÚstartÚends        r$   Úget_text_rangezASTTextBase.get_text_range9   sP   € ð ×(Ñ(¨¨vÓ6�J€Eˆ3à'€d×Ñ×'Ñ'¨Ð/Ø'€d×Ñ×'Ñ'¨Ð-ðð r&   c                 óJ   — | j                  ||«      \  }}| j                  || S )zÚ
    Returns the text corresponding to the given node.
    Returns '' for nodes (like `Load`) that don't correspond to any particular text.

    See ``get_text_positions()`` for details on the ``padded`` argument.
    )r3   r!   r0   s        r$   Úget_textzASTTextBase.get_textF   s+   € ð ×$Ñ$ T¨6Ó2�J€Eˆ3Ø�:‰:�e˜SÐ!Ð!r&   )T)Ú__name__Ú
__module__Ú__qualname__r    r%   ÚabcÚabstractmethodr   Úboolr   Úintr-   r3   r5   © r&   r$   r   r      s¤   „ ð	2 #ð 	2°ð 	2¸ó 	2ð ×ÑðØðØ!%ðàˆU�3˜�8‰_˜e C¨ H™oÐ-Ñ.òó ðñ ð °$ð À%ÈÈSÈÁ/ó ñ"˜7ð "¨Dð "¸Cô "r&   r   )Ú	metaclassc                   óâ  ‡ — e Zd ZdZ	 	 	 	 d(dededee   dedee	e
      ddfˆ fd	„Zd
eddfd„Zde	e
   dee   fd„Zedefd„«       Zedee   fd„«       Zedee   fd„«       Zedefd„«       Zdedefd„Zdededefd„Zdededefd„Zd)dededefd„Zd)dededefd„Z	 d*dededee   dedef
d „Z	 d)d!ed"ededee   fd#„Zd)d$ededee   fd%„Zd$ed&ede e eef   e eef   f   fd'„Z!ˆ xZ"S )+Ú	ASTTokensaš  
  ASTTokens maintains the text of Python code in several forms: as a string, as line numbers, and
  as tokens, and is used to mark and access token and position information.

  ``source_text`` must be a unicode or UTF8-encoded string. If you pass in UTF8 bytes, remember
  that all offsets you'll get are to the unicode text, which is available as the ``.text``
  property.

  If ``parse`` is set, the ``source_text`` will be parsed with ``ast.parse()``, and the resulting
  tree marked with token info and made available as the ``.tree`` property.

  If ``tree`` is given, it will be marked and made available as the ``.tree`` property. In
  addition to the trees produced by the ``ast`` module, ASTTokens will also mark trees produced
  using ``astroid`` library <https://www.astroid.org>.

  If only ``source_text`` is given, you may use ``.mark_tokens(tree)`` to mark the nodes of an AST
  tree created separately.
  Nr   ÚparseÚtreer   Útokensr   c                 ó|  •— t         ‰| �  ||«       |rt        j                  ||«      n|| _        |€t        | j                  «      }t        | j                  |«      «      | _	        | j                  D �cg c]  }|j                  ‘Œ c}| _        | j                  r| j                  | j                  «       y y c c}w r   )Úsuperr%   ÚastrA   Ú_treer   r!   ÚlistÚ_translate_tokensÚ_tokensÚstartposÚ_token_offsetsÚmark_tokens)r#   r   rA   rB   r   rC   ÚtokÚ	__class__s          €r$   r%   zASTTokens.__init__e   s›   ø€ ô 
�GÑ�[ (Ô+á5:”—‘˜;¨Ô1À€D„Jð €~Ü˜tŸz™zÓ*€fÜ˜×.Ñ.¨vÓ6Ó7€D„Lð 48·<²<Ó@±<¨C˜3Ÿ<›<°<Ñ@€DÔà‡z‚zØ
×Ñ�t—z‘zÕ"ð ùò As   Á5B9Ú	root_nodec                 ó>   — ddl m}  || «      j                  |«       y)aq  
    Given the root of the AST or Astroid tree produced from source_text, visits all nodes marking
    them with token and position information by adding ``.first_token`` and
    ``.last_token`` attributes. This is done automatically in the constructor when ``parse`` or
    ``tree`` arguments are set, but may be used manually with a separate AST or Astroid tree.
    r   )Ú
MarkTokensN)rM   rR   Ú
visit_tree)r#   rP   rR   s      r$   rM   zASTTokens.mark_tokens|   s   € õ (ÙˆtÓ×Ñ 	Õ*r&   Úoriginal_tokensc              #   óü   K  — t        t        |«      «      D ]a  \  }}|\  }}}}}t        ||||||| j                  j	                  |d   |d   «      | j                  j	                  |d   |d   «      «      –— Œc y­w)zS
    Translates the given standard library tokens into our own representation.
    r   r   N)Ú	enumerater   r   r"   r/   )	r#   rT   ÚindexrN   Útok_typeÚtok_strr1   r2   Úlines	            r$   rI   zASTTokens._translate_tokens‡   s‰   è ø€ ô  Ô 7¸Ó HÖI‰
ˆˆsØ,/Ñ)€h�˜  TÜ�(˜G U¨C°°uØ×$Ñ$×3Ñ3°E¸!±H¸eÀA¹hÓGØ×$Ñ$×3Ñ3°C¸±F¸CÀ¹FÓCóEó Eñ Jùs   ‚A:A<c                 ó   — | j                   S )z,The source code passed into the constructor.)r!   ©r#   s    r$   ÚtextzASTTokens.text‘   ó   € ð �:‰:Ðr&   c                 ó   — | j                   S )zIThe list of tokens corresponding to the source code from the constructor.)rJ   r\   s    r$   rC   zASTTokens.tokens–   s   € ð �<‰<Ðr&   c                 ó   — | j                   S )zTThe root of the AST tree passed into the constructor or parsed from the source code.)rG   r\   s    r$   rB   zASTTokens.tree›   r^   r&   c                 ó   — | j                   S )zThe filename that was parsed)r   r\   s    r$   r   zASTTokens.filename    s   € ð �>‰>Ðr&   Úoffsetc                 ób   — | j                   t        j                  | j                  |«      dz
     S )z£
    Returns the token containing the given character offset (0-based position in source text),
    or the preceeding token if the position is between tokens.
    r   )rJ   ÚbisectrL   )r#   rb   s     r$   Úget_token_from_offsetzASTTokens.get_token_from_offset¥   s)   € ð
 �<‰<œŸ™ d×&9Ñ&9¸6ÓBÀQÑFÑGÐGr&   ÚlinenoÚ
col_offsetc                 óX   — | j                  | j                  j                  ||«      «      S )zŽ
    Returns the token containing the given (lineno, col_offset) position, or the preceeding token
    if the position is between tokens.
    )re   r"   r/   ©r#   rf   rg   s      r$   Ú	get_tokenzASTTokens.get_token¬   s)   € ð ×%Ñ% d×&8Ñ&8×&GÑ&GÈÐPZÓ&[Ó\Ð\r&   c                 óZ   — | j                  || j                  j                  ||«      «      S )zd
    Same as get_token(), but interprets col_offset as a UTF8 offset, which is what `ast` uses.
    )rj   r"   Úfrom_utf8_colri   s      r$   Úget_token_from_utf8zASTTokens.get_token_from_utf8¶   s(   € ð �>‰>˜& $×"4Ñ"4×"BÑ"BÀ6È:Ó"VÓWÐWr&   rN   Úinclude_extrac                 óÖ   — |j                   dz   }|sJt        | j                  |   j                  «      r(|dz  }t        | j                  |   j                  «      rŒ(| j                  |   S )z 
    Returns the next token after the given one. If include_extra is True, includes non-coding
    tokens from the tokenize module, such as NL and COMMENT.
    r   ©rW   r   rJ   Útype©r#   rN   rn   Úis       r$   Ú
next_tokenzASTTokens.next_token¼   óY   € ð
 	�	‰	�A‰€AÙÜ §¡¨Q¡× 4Ñ 4Ô5Ø	ˆQ‰ˆô   §¡¨Q¡× 4Ñ 4Õ5à�<‰<˜‰?Ðr&   c                 óÖ   — |j                   dz
  }|sJt        | j                  |   j                  «      r(|dz  }t        | j                  |   j                  «      rŒ(| j                  |   S )z¥
    Returns the previous token before the given one. If include_extra is True, includes non-coding
    tokens from the tokenize module, such as NL and COMMENT.
    r   rp   rr   s       r$   Ú
prev_tokenzASTTokens.prev_tokenÇ   ru   r&   Ústart_tokenrX   rY   Úreversec                 ó  — |}|r| j                   n| j                  }t        |||«      sVt        j                  |j
                  «      s7 ||d¬«      }t        |||«      s t        j                  |j
                  «      sŒ7|S )z÷
    Looks for the first token, starting at start_token, that matches tok_type and, if given, the
    token string. Searches backwards if reverse is True. Returns ENDMARKER token if not found (you
    can check it with `token.ISEOF(t.type)`).
    T©rn   )rw   rt   r   ÚtokenÚISEOFrq   )r#   rx   rX   rY   ry   ÚtÚadvances          r$   Ú
find_tokenzASTTokens.find_tokenÒ   sc   € ð 	€AÙ!(ˆd�oŠo¨d¯o©o€GÜ˜!˜X wÔ/¼¿¹ÀAÇFÁFÔ8KÙ
�! 4Ô
(€aô ˜!˜X wÔ/¼¿¹ÀAÇFÁFÕ8Kà€Hr&   Úfirst_tokenÚ
last_tokenc              #   óÈ   K  — t        |j                  |j                  dz   «      D ]8  }|s#t        | j                  |   j                  «      rŒ(| j                  |   –— Œ: y­w)z²
    Yields all tokens in order from first_token through and including last_token. If
    include_extra is True, includes non-coding tokens such as tokenize.NL and .COMMENT.
    r   N)ÚrangerW   r   rJ   rq   )r#   r�   r‚   rn   rs   s        r$   Útoken_rangezASTTokens.token_rangeà   sQ   è ø€ ô �;×$Ñ$ j×&6Ñ&6¸Ñ&:Ö;ˆÙ	Ô1°$·,±,¸q±/×2FÑ2FÕGØ�l‰l˜1‰oÓñ <ùs   ‚AA"ÁA"r'   c                 óR   — | j                  |j                  |j                  |¬«      S )z�
    Yields all tokens making up the given node. If include_extra is True, includes non-coding
    tokens such as tokenize.NL and .COMMENT.
    r{   )r…   r�   r‚   )r#   r'   rn   s      r$   Ú
get_tokenszASTTokens.get_tokensî   s&   € ð
 ×Ñ˜D×,Ñ,¨d¯o©oÈ]ÐÓ[Ð[r&   r(   c                 óÐ   — t        |d«      sy|j                  j                  }|j                  j                  }|r(t        d„ | j                  |«      D «       «      r|d   df}||fS )r*   r�   ©©r   r   rŠ   c              3   óP   K  — | ]  }t        |t        j                  «      –— Œ  y ­wr   )r   r|   ÚNEWLINE)Ú.0r~   s     r$   Ú	<genexpr>z/ASTTokens.get_text_positions.<locals>.<genexpr>  s   è ø€ ÐSÑ=R¸”k !¤U§]¡]×3Ñ=Rùs   ‚$&r   )Úhasattrr�   r1   r‚   r2   Úanyr‡   r0   s        r$   r-   zASTTokens.get_text_positionsõ   sa   € ô �4˜Ô'Øà×Ñ×"Ñ"€EØ
�/‰/×
Ñ
€CÙ”#ÑS¸T¿_¹_ÈTÔ=RÓSÔSà�Q‰x˜ˆm€eà�#ˆ:Ðr&   )FNú	<unknown>N)F)NF)#r6   r7   r8   Ú__doc__r	   r;   r   r   r    r   r   r%   rM   r   r   rI   Úpropertyr]   r   rC   rB   r   r<   re   rj   rm   rt   rw   r€   r…   r   r‡   r   r-   Ú__classcell__©rO   s   @r$   r@   r@   Q   sZ  ø„ ñð, Ø!ØØ,0ñ#àð#ð ð#ð �6Ñ
ð	#ð
 ð#ð �X˜iÑ(Ñ)ð#ð õ#ð.	+ 6ð 	+¨dó 	+ðE¨x¸	Ñ/Bð EÀxÐPUÁó Eð ð�Cò ó ðð ð�d˜5‘kò ó ðð ð�H˜VÑ$ò ó ðð ð˜ò ó ððH¨#ð H°%ó Hð]˜cð ]¨sð ]°uó ]ðX¨ð X¸ð XÀó Xñ	˜Eð 	°$ð 	À5ó 	ñ	˜Eð 	°$ð 	À5ó 	ð ]bñØðØ(+ðØ6>¸s±mðØUYðàóð$  ñ	àðð ðð ð	ð
 ��óñ\˜Wð \°Tð \ÀhÈuÁoó \ð Wð °dð ¸uÀUÈ3ÐPSÈ8Á_ÐV[Ð\_ÐadÐ\dÑVeÐEeÑ?f÷ r&   r@   c            
       óÌ   ‡ — e Zd ZdZddedee   deddfˆ fd„Ze	defd„«       Z
e	defd	„«       Zd
ededeeeef   eeef   f   fd„Zd
ededeeeef   eeef   f   fd„Zˆ xZS )ÚASTTextaF  
  Supports the same ``get_text*`` methods as ``ASTTokens``,
  but uses the AST to determine the text positions instead of tokens.
  This is faster than ``ASTTokens`` as it requires less setup work.

  It also (sometimes) supports nodes inside f-strings, which ``ASTTokens`` doesn't.

  Some node types and/or Python versions are not supported.
  In these cases the ``get_text*`` methods will fall back to using ``ASTTokens``
  which incurs the usual setup cost the first time.
  If you want to avoid this, check ``supports_tokenless(node)`` before calling ``get_text*`` methods.
  Nr   rB   r   r   c                 ó„   •— t         ‰| �  ||«       || _        | j                  �t        | j                  «       d | _        y r   )rE   r%   rG   r   Ú
_asttokens)r#   r   rB   r   rO   s       €r$   r%   zASTText.__init__  s6   ø€ Ü	�GÑ�[ (Ô+à€D„JØ‡z�zÐÜ˜TŸZ™ZÔ(à+/€D…Or&   c                 óº   — | j                   €Dt        j                  | j                  | j                  «      | _         t        | j                   «       | j                   S r   )rG   rF   rA   r!   r   r   r\   s    r$   rB   zASTText.tree!  s<   € à‡z�zÐÜ—9‘9˜TŸZ™Z¨¯©Ó8€d„jÜ˜TŸZ™ZÔ(Ø�:‰:Ðr&   c                 ó”   — | j                   €1t        | j                  | j                  | j                  ¬«      | _         | j                   S )N)rB   r   )r™   r@   r!   rB   r   r\   s    r$   Ú	asttokenszASTText.asttokens(  s9   € à‡�ÐÜ!Ø
�*‰*Ø�y‰yØ—>‘>ô€d„oð
 �?‰?Ðr&   r'   r(   c                 óª  — t        |«      r0d| j                  j                  t        | j                  «      «      fS t        |dd«      €y|sJ ‚t        |dg «      }|st        |dd«      }t        |dg «      }|r|d   }n|}|j                  }t        |«      }|r9||j                  k7  s'||j                  k7  rt        |d	d«      rt        |«      rd}n&| j                  j                  ||j                  «      }||f}	t        t        |j                  «      }
t        t        |j                  «      }| j                  j                  |
|«      }|
|f}|	|fS )
zF
    Version of ``get_text_positions()`` that doesn't use tokens.
    rŠ   rf   Nr‰   Údecorator_listÚ
decoratorsÚnodesr   Údoc_node)r   r"   Úoffset_to_lineÚlenr!   Úgetattrrf   r   Ú
end_linenor   rl   rg   r
   r<   Úend_col_offset)r#   r'   r(   rŸ   Údecorators_nodeÚ
start_nodeÚstart_linenoÚend_nodeÚstart_col_offsetr1   r¥   r¦   r2   s                r$   Ú_get_text_positions_tokenlessz%ASTText._get_text_positions_tokenless2  sU  € ô �„ð
 �T×'Ñ'×6Ñ6´s¸4¿:¹:³ÓGÐGÐGäˆt�X˜tÓ$Ð,Øá€Kˆ4ä˜Ð/°Ó4€JÙä  l°DÓ9€oÜ˜?¨G°RÓ8€jÙð ˜a‘=�jà€jà×$Ñ$€LÜ˜‹€Hñ Ø˜Ÿ™Ò'ð ˜DŸO™OÒ+Ü˜˜j¨$Ô/Ü˜”ð Ñà×+Ñ+×9Ñ9¸,È
×H]ÑH]Ó^ÐàÐ+Ð,€Eô
 ”c˜8×.Ñ.Ó/€JÜœ#˜x×6Ñ6Ó7€NØ×'Ñ'×5Ñ5°jÀ.ÓQ€NØ�~Ð
&€Cà�#ˆ:Ðr&   c                 ó�   — t        |dd«      ryt        |«      r| j                  ||«      S | j                  j	                  ||«      S )r*   Ú_broken_positionsNr‰   )r¤   Úsupports_tokenlessr¬   rœ   r-   r,   s      r$   r-   zASTText.get_text_positionsu  sF   € ô ˆtÐ(¨$Ô/àä˜$ÔØ×/Ñ/°°fÓ=Ð=à�>‰>×,Ñ,¨T°6Ó:Ð:r&   )Nr‘   )r6   r7   r8   r’   r	   r   r   r    r%   r“   rB   r@   rœ   r   r;   r   r<   r¬   r-   r”   r•   s   @r$   r—   r—     sÜ   ø„ ññ0 #ð 0¨X°fÑ-=ð 0ÐPSð 0Ðfjõ 0ð ð�Fò ó ðð ð˜ò ó ððAØðAØ!%ðAàˆU�3˜�8‰_˜e C¨ H™oÐ-Ñ.óAðF; Wð ;°dð ;¸uÀUÈ3ÐPSÈ8Á_ÐV[Ð\_ÐadÐ\dÑVeÐEeÑ?f÷ ;r&   r—   )Ú	argumentsÚ	ArgumentsÚwithitem.Ú_unsupported_tokenless_typesé   )é   é   )ÚargÚStarred)ÚSliceÚExtSliceÚIndexÚkeywordr'   r   c                 ó>  — t        | «      j                  t        vxr� t        | t        j
                  «       xrA | duxr; t        | «      j                  dk(  xr! t        | j                  «      j                  dv  xr  dt        j                  j                  «       vS )av  
  Returns True if the Python version and the node (if given) are supported by
  the ``get_text*`` methods of ``ASTText`` without falling back to ``ASTTokens``.
  See ``ASTText`` for why this matters.

  The following cases are not supported:

    - PyPy
    - ``ast.arguments`` / ``astroid.Arguments``
    - ``ast.withitem``
    - ``astroid.Comprehension``
    - ``astroid.AssignName`` inside ``astroid.Arguments`` or ``astroid.ExceptHandler``
    - The following nodes in Python 3.8 only:
      - ``ast.arg``
      - ``ast.Starred``
      - ``ast.Slice``
      - ``ast.ExtSlice``
      - ``ast.Index``
      - ``ast.keyword``
  NÚ
AssignName)r±   ÚExceptHandlerÚpypy)
rq   r6   r³   Ú
isinstancerF   ÚASTÚparentÚsysÚversionÚlower)r'   s    r$   r¯   r¯   “  s–   € ô, ˆ4ƒj×ÑÔ!=Ð=ò ,ô �tœSŸW™WÓ%Ð%ò 	
¨$°dÐ*:ò 	
Ü�‹J×Ñ <Ñ/ò MÜ�T—[‘[Ó!×*Ñ*Ð.LÐLð	ò,ð œŸ™×)Ñ)Ó+Ð
+ð
r&   r   )&r9   rF   rd   rÄ   r|   r   Útypingr   r   r   r   r   r	   r
   Úline_numbersr   Úutilr   r   r   r   r   r   r   r   r   r   r   ÚABCMetar   r@   r—   r³   r    Ú__annotations__Úversion_infor;   r¯   r=   r&   r$   Ú<module>rÍ      s¾   ðô Û 
Û Û 
Û Ý ß G× GÑ Gå %÷÷ ÷ ñ ô0"˜CŸK™Kõ 0"ôfw�ô wôt{;ˆkô {;ð@ 1WÐ ˜e C¨ H™oÓ VØ×Ñ�B�QÐ˜6Ò!àÐ"4Ñ4ÐàÐ"KÑKÐñ˜Sð ¨Dô r&   