ó
    áÅŸgøL  ã                   ó^  • S r SSKrSSK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JrJrJrJrJrJr  SSKJrJr  S\\   S	\\\\4      4S
 jrS\\\4   S	\4S jrS\\\\4      S\S	\\\\4      4S jrS\\\\4      S\S\S	\\\\4      4S jrS\S\\\\4      S	S4S jr S\S	\4S jr! " S S\S   5      r"S\S\#\   S	S4S jr$S\S	S4S jr%S\\   S\S	S4S jr&S\S	\4S jr'S \	\\\   4   S	\#\   4S! jr(\ " S" S#5      5       r)S\S\S	\\)   4S$ jr*S%\S&\\)   S'\S	\4S( jr+g))z?Functions related to Black's formatting by line ranges feature.é    N)Ú
CollectionÚIteratorÚSequence)Ú	dataclass)ÚUnion)	ÚLNÚSTANDALONE_COMMENTÚLeafÚNodeÚVisitorÚ
first_leafÚ furthest_ancestor_with_last_leafÚ	last_leafÚsyms)ÚASYNCÚNEWLINEÚline_rangesÚreturnc                 ó  • / nU  Ha  nUR                  S5      n[        U5      S:w  a  [        SU< 35      e [        US   5      n[        US   5      nUR	                  XE45        Mc     U$ ! [         a    [        SU< 35      S ef = f)NÚ-é   z:Incorrect --line-ranges format, expect 'START-END', found r   é   z<Incorrect --line-ranges value, expect integer ranges, found )ÚsplitÚlenÚ
ValueErrorÚintÚappend)r   ÚlinesÚ	lines_strÚpartsÚstartÚends         ÚM/var/www/blue/EV-Temp_rev04/venv/lib/python3.13/site-packages/black/ranges.pyÚparse_line_rangesr$      s®   € Ø#%€EÛ ˆ	Ø—‘ Ó$ˆÜˆu‹:˜‹?ÜðØ‘=ð"óð ð		'Ü˜˜a™“MˆEÜ�e˜A‘h“-ˆCð �L‰L˜%˜Ö&ñ! !ð" €Løô ó 	ÜðØ‘=ð"óð ðð	ús   ¸A,Á,Br   c                 ó4   • U (       + =(       d    U S   U S   :*  $ )z(Returns whether the line range is valid.r   r   © )r   s    r#   Úis_valid_line_ranger'   ,   s   € àŒ9×,˜˜a™ E¨!¡HÑ,Ð,ó    Úsrc_contentsc                 óø   • U(       d  / $ / nUR                  S5      nUR                  S5      (       d  US-  nU  H<  u  pEXC:”  a  M  [        US5      nXT:  a  M  [        XS5      nUR	                  XE45        M>     U$ )a  Returns the valid line ranges for the given source.

This removes ranges that are entirely outside the valid lines.

Other ranges are normalized so that the start values are at least 1 and the
end values are at most the (1-based) index of the last source line.
Ú
r   )ÚcountÚendswithÚmaxÚminr   )r   r)   Ú
good_linesÚsrc_line_countr!   r"   s         r#   Úsanitized_linesr2   1   s†   € ö Øˆ	Ø€JØ!×'Ñ'¨Ó-€NØ× Ñ  ×&Ñ&Ø˜!ÑˆÛ‰
ˆØÓ!Ùä�E˜1“ˆØ‹;ÙÜ�#Ó&ˆØ×Ñ˜5˜,Ö'ñ ð Ðr(   Úoriginal_sourceÚmodified_sourcec                 ó  • [        X5      n/ nSn[        U 5       Há  u  pg[        UUU5      n[        UUU5      n	UnU[        U5      :¼  d  U	[        U5      :¼  a  MA  X8   n
X9   nU
R                  (       a  U
R
                  nOXjR                  -
  U
R
                  -   nUR                  (       a  UR                  nOX{R                  -
  UR
                  -   nXÍ4n[        U5      (       d  MÐ  UR                  U5        Mã     U$ )aN  Returns the adjusted line ranges based on edits from the original code.

This computes the new line ranges by diffing original_source and
modified_source, and adjust each range based on how the range overlaps with
the diffs.

Note the diff can contain lines outside of the original line ranges. This can
happen when the formatting has to be done in adjacent to maintain consistent
local results. For example:

1. def my_func(arg1, arg2,
2.             arg3,):
3.   pass

If it restricts to line 2-2, it can't simply reformat line 2, it also has
to reformat line 1:

1. def my_func(
2.     arg1,
3.     arg2,
4.     arg3,
5. ):
6.   pass

In this case, we will expand the line ranges to also include the whole diff
block.

Args:
  lines: a collection of line ranges.
  original_source: the original source.
  modified_source: the modified source.
r   )
Ú_calculate_lines_mappingsÚsortedÚ_find_lines_mapping_indexr   Úis_changed_blockÚmodified_startÚoriginal_startÚmodified_endr'   r   )r   r3   r4   Úlines_mappingsÚ	new_linesÚcurrent_mapping_indexr!   r"   Ústart_mapping_indexÚend_mapping_indexÚstart_mappingÚend_mappingÚ	new_startÚnew_endÚ	new_ranges                  r#   Úadjusted_linesrG   M   s  € ôJ /¨ÓP€Nà€Ið ÐÜ˜U–m‰
ˆÜ7ØØØ!ó
Ðô
 6ØØØó
Ðð
 !4ÐØ¤# nÓ"5Ó5Ð9JÌcØóO
ó :
ñ Ø&Ñ;ˆØ$Ñ7ˆØ×)×)à%×4Ñ4‰Ið ×4Ñ4Ñ4°}×7SÑ7SÑSð ð ×'×'à!×.Ñ.‰Gà×6Ñ6Ñ6¸×9SÑ9SÑSˆGØÐ(ˆ	Ü˜y×)Ó)Ø×Ñ˜YÖ'ñC $ðD Ðr(   Úsrc_nodec                 óÈ   • [        5       nU H"  u  p4UR                  [        X4S-   5      5        M$     [        U5      n[	        UR                  U 5      5      n[        X5        g)aò  Converts unchanged lines to STANDALONE_COMMENT.

    The idea is similar to how `# fmt: on/off` is implemented. It also converts the
    nodes between those markers as a single `STANDALONE_COMMENT` leaf node with
    the unformatted code as its value. `STANDALONE_COMMENT` is a "fake" token
    that will be formatted as-is with its prefix normalized.

    Here we perform two passes:

    1. Visit the top-level statements, and convert them to a single
       `STANDALONE_COMMENT` when unchanged. This speeds up formatting when some
       of the top-level statements aren't changed.
    2. Convert unchanged "unwrapped lines" to `STANDALONE_COMMENT` nodes line by
       line. "unwrapped lines" are divided by the `NEWLINE` token. e.g. a
       multi-line statement is *one* "unwrapped line" that ends with `NEWLINE`,
       even though this statement itself can span multiple lines, and the
       tokenizer only sees the last '
' as the `NEWLINE` token.

    NOTE: During pass (2), comment prefixes and indentations are ALWAYS
    normalized even when the lines aren't changed. This is fixable by moving
    more formatting to pass (1). However, it's hard to get it correct when
    incorrect indentations are used. So we defer this to future optimizations.
    r   N)ÚsetÚupdateÚrangeÚ_TopLevelStatementsVisitorÚlistÚvisitÚ_convert_unchanged_line_by_line)rH   r   Ú	lines_setr!   r"   ÚvisitorÚ_s          r#   Úconvert_unchanged_linesrT   �   sS   € ô0 ›%€IÛ‰
ˆØ×Ñœ˜u¨A¡gÓ.Ö/ñ ä(¨Ó3€GÜˆW�]‰]˜8Ó$Ó%€AÜ# HÕ8r(   Únodec                 óž   • [        U [        5      (       a  U R                  [        :H  $ U R                   H  n[        U5      (       d  M    g   g)NTF)Ú
isinstancer
   Útyper	   ÚchildrenÚ_contains_standalone_comment)rU   Úchilds     r#   rZ   rZ   ½   s@   € Ü�$œ×ÑØ�y‰yÔ.Ñ.Ð.à—]”]ˆEÜ+¨E×2Ó2Ùñ #ð r(   c                   ó\   • \ rS rSrSrS\\   4S jrS\S\	S   4S jr
S\S\	S   4S	 jrS
rg)rM   éÇ   zê
A node visitor that converts unchanged top-level statements to
STANDALONE_COMMENT.

This is used in addition to _convert_unchanged_line_by_line, to
speed up formatting when there are unchanged top-level
classes/functions/statements.
rQ   c                 ó   • Xl         g ©N©Ú
_lines_set)ÚselfrQ   s     r#   Ú__init__Ú#_TopLevelStatementsVisitor.__init__Ñ   s   € Ø#�r(   rU   r   Nc              #   ó  #   • /  S h  v•N   [        U5      nU(       d  g UR                  [        :X  d   SUR                   35       e[        U5      n[	        U5      R                  U R                  5      (       d  [        U5        g g  N€7f)NzUnexpectedly found leaf.type=)r   rX   r   r   Ú_get_line_rangeÚintersectionra   Ú#_convert_node_to_standalone_comment)rb   rU   Únewline_leafÚancestors       r#   Úvisit_simple_stmtÚ,_TopLevelStatementsVisitor.visit_simple_stmtÔ   s‚   é € ð �ˆÜ  “ˆÞØà×Ñ¤Ó(ð	?à*¨<×+<Ñ+<Ð*=Ð>ó	?Ø(ô
 4°LÓAˆÜ˜xÓ(×5Ñ5°d·o±o×FÑFÜ/°Õ9ð Gñ 	ùs   ‚BˆB	‰BBc              #   óD  #   • /  S h  v•N   [        U5      (       a  g UR                  nUb7  UR                  b*  UR                  R                  [        :X  a  UR                  nUb6  [        U5      R                  U R                  5      (       d  [        U5        g g g  N•7fr_   )	rZ   ÚparentÚprev_siblingrX   r   rf   rg   ra   rh   )rb   rU   Úsemantic_parents      r#   Úvisit_suiteÚ&_TopLevelStatementsVisitor.visit_suiteå   s’   é € Ø�ˆô
 (¨×-Ñ-Øð Ÿ+™+ˆØÑ&à×,Ñ,Ñ8Ø#×0Ñ0×5Ñ5¼Ó>à"1×"8Ñ"8�ØÑ&¬Øó0
ç
‰,�t—‘Ó
'õ0(ô 0°Õ@ð0(Ð&ñ# 	ùs   ‚B ˆB‰BB r`   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rJ   r   rc   r   r   rk   rq   Ú__static_attributes__r&   r(   r#   rM   rM   Ç   sH   † ñð$ # c¡(ô $ð: dð :¨x¸©~ô :ð"A ð A¨°$©÷ Ar(   rM   rQ   c                 óp  • U R                  5        GH¡  nUR                  [        :w  a  M  UR                  (       a�  UR                  R                  [        R
                  :X  ah  / nUR                  nU(       a'  UR                  SU5        UR                  nU(       a  M'  [        U5      R                  U5      (       d  [        X2S9  M¹  M»  UR                  (       Ga9  UR                  R                  [        R                  :X  Ga  UR                  R                  n/ nU(       ac  UR                  [        R                  :X  dE  UR                  SU5        UR                  nU(       a   UR                  [        R                  :X  d  ME  UR                  R                  nUbG  UR                  b:  UR                  R                  [        :X  a  UR                  SUR                  5        [        U5      R                  U5      (       d  [        X2S9  GM  GM  [        U5      nUR                  [        R                  :X  aE  UR                  (       a4  UR                  R                  [        R                  :X  a  UR                  n[        U5      R                  U5      (       a  GM–  [!        U5        GM¤     g)z6Converts unchanged to STANDALONE_COMMENT line by line.r   )ÚnewlineN)ÚleavesrX   r   rn   r   Ú
match_stmtro   Úinsertrf   rg   Ú$_convert_nodes_to_standalone_commentÚsuiter   r   Ú	decoratorÚ
decoratorsrh   )rU   rQ   ÚleafÚnodes_to_ignorero   Úparent_siblingÚgrandparentrj   s           r#   rP   rP   ý   sé  € à—‘—ˆØ�9‰9œÓñ Ø�;�;˜4Ÿ;™;×+Ñ+¬t¯©Ó>ð
 )+ˆOØ×,Ñ,ˆLÞØ×&Ñ& q¨,Ô7Ø+×8Ñ8�÷ �,ô # ?Ó3×@Ñ@À×KÑKÜ4°_ÔSñ Là�[�[ˆ[˜TŸ[™[×-Ñ-´·±Ô;ð "Ÿ[™[×5Ñ5ˆNØ ˆOÞ ¨×)<Ñ)<ÄÇ
Á
Ó)Jà×&Ñ& q¨.Ô9Ø!/×!<Ñ!<�ö !¨×)<Ñ)<ÄÇ
Á
Õ)Jð Ÿ+™+×,Ñ,ˆKàÑ'Ø×,Ñ,Ñ8Ø×,Ñ,×1Ñ1´UÓ:à×&Ñ& q¨+×*BÑ*BÔCÜ" ?Ó3×@Ñ@À×KÑKÜ4°_ÕSò Lô 8¸Ó=ˆHð —‘¤§¡Ó/Ø—O—OØ—O‘O×(Ñ(¬D¯O©OÓ;à#Ÿ?™?�Ü" 8Ó,×9Ñ9¸)×DÔDÜ3°H×=òc r(   c           
      ó*  • U R                   nU(       d  g[        U 5      n[        U 5      nU(       a  U(       d  gX#L a  gUR                  nSUl        U R	                  5       nUb/  [        U 5      SS nUR                  U[        [        UUUS95        gg)z@Convert node to STANDALONE_COMMENT by modifying the tree inline.NÚ éÿÿÿÿ©ÚprefixÚfmt_pass_converted_first_leaf)	rn   r   r   rŠ   ÚremoveÚstrÚinsert_childr
   r	   )rU   rn   ÚfirstÚlastrŠ   ÚindexÚvalues          r#   rh   rh   3  s”   € à�[‰[€FÞØÜ�tÓ€EÜ�T‹?€DÞžØØ‚}ð 	ð
 �\‰\€FØ€E„LØ�K‰K‹M€EØÑô �D“	˜#˜2�ˆØ×ÑØÜÜ"ØØØ.3ñ	õ	
ð	 r(   Únodesrz   c          
      ó´  • U (       d  gU S   R                   n[        U S   5      nU(       a  U(       d  gUR                  nSUl        SR                  S U  5       5      nUR                  (       a  XQR                  -  nSUl        U S   R	                  5       nU SS  H  nUR	                  5         M     Ub!  UR                  U[        [        UUUS95        gg)zAConvert nodes to STANDALONE_COMMENT by modifying the tree inline.Nr   r‡   c              3   ó6   #   • U H  n[        U5      v •  M     g 7fr_   )r�   )Ú.0rU   s     r#   Ú	<genexpr>Ú7_convert_nodes_to_standalone_comment.<locals>.<genexpr>e  s   é € Ð0©% $”C˜—I�Iª%ùs   ‚r   r‰   )rn   r   rŠ   ÚjoinrŒ   rŽ   r
   r	   )r“   rz   rn   r�   rŠ   r’   r‘   rU   s           r#   r~   r~   [  sÂ   € æØØ�1‰X�_‰_€FÜ�u˜Q‘xÓ €EÞžØØ�\‰\€FØ€E„LØ�G‰GÑ0©%Ó0Ó0€Eà‡~‡~Ø—‘ÑˆØˆŒØ�!‰H�O‰OÓ€EØ�a�b“	ˆØ�‰Žñ àÑØ×ÑØÜÜ"ØØØ.3ñ	õ	
ð r(   r‚   c                 ó�   • U R                   [        :X  a  U R                  $ U R                  [        U 5      R	                  S5      -   $ )z5Returns the line number of the leaf node's last line.r+   )rX   r   Úlinenor�   r,   )r‚   s    r#   Ú_leaf_line_endrœ   y  s6   € à‡y�y”GÓØ�{‰{Ðð �{‰{œS ›YŸ_™_¨TÓ2Ñ2Ð2r(   Únode_or_nodesc                 óL  • [        U [        5      (       au  U nU(       d
  [        5       $ [        US   5      n[	        US   5      nU(       a5  U(       a.  UR
                  n[        U5      n[        [        XES-   5      5      $ [        5       $ U n[        U[        5      (       a+  [        [        UR
                  [        U5      S-   5      5      $ [        U5      n[	        U5      nU(       a2  U(       a+  [        [        UR
                  [        U5      S-   5      5      $ [        5       $ )z5Returns the line range of this node or list of nodes.r   rˆ   r   )	rW   rN   rJ   r   r   r›   rœ   rL   r
   )r�   r“   r�   r�   Ú
line_startÚline_endrU   s          r#   rf   rf   ‚  sÞ   € ä�-¤×&Ñ&ØˆÞÜ“5ˆLÜ˜5 ™8Ó$ˆÜ˜˜r™Ó#ˆÞ–TØŸ™ˆJÜ% dÓ+ˆHÜ”u˜Z°A©Ó6Ó7Ð7ä“5ˆLàˆÜ�dœD×!Ñ!Ü”u˜TŸ[™[¬.¸Ó*>ÀÑ*BÓCÓDÐDä˜tÓ$ˆEÜ˜T“?ˆDÞžÜœ5 §¡¬~¸dÓ/CÀaÑ/GÓHÓIÐIä“u�r(   c                   óL   • \ rS rSr% Sr\\S'   \\S'   \\S'   \\S'   \\S'   Srg	)
Ú_LinesMappingi�  zÐ1-based lines mapping from original source to modified source.

Lines [original_start, original_end] from original source
are mapped to [modified_start, modified_end].

The ranges are inclusive on both ends.
r;   Úoriginal_endr:   r<   r9   r&   N)	rs   rt   ru   rv   rw   r   Ú__annotations__Úboolrx   r&   r(   r#   r¢   r¢   �  s'   ‡ ñð ÓØÓØÓØÓàÖr(   r¢   c                 ó.  • [         R                  " SU R                  SS9UR                  SS95      nUR                  5       n/ n[	        U5       GH@  u  pVUS:X  aQ  UR
                  S:w  d  UR                  S:w  a0  UR                  [        SUR
                  SUR                  SS95        OkX5S-
     nUR                  [        UR
                  UR                  -   S-   UR
                  UR                  UR                  -   S-   UR                  SS95        U[        U5      S-
  :  d  MÜ  UR                  [        UR
                  S-   UR
                  UR                  -   UR                  S-   UR                  UR                  -   SS95        GMC     U$ )a{  Returns a sequence of _LinesMapping by diffing the sources.

For example, given the following diff:
    import re
  - def func(arg1,
  -   arg2, arg3):
  + def func(arg1, arg2, arg3):
      pass
It returns the following mappings:
  original -> modified
   (1, 1)  ->  (1, 1), is_changed_block=False (the "import re" line)
   (2, 3)  ->  (2, 2), is_changed_block=True (the diff)
   (4, 4)  ->  (3, 3), is_changed_block=False (the "pass" line)

You can think of this visually as if it brings up a side-by-side diff, and tries
to map the line ranges from the left side to the right side:

  (1, 1)->(1, 1)    1. import re          1. import re
  (2, 3)->(2, 2)    2. def func(arg1,     2. def func(arg1, arg2, arg3):
                    3.   arg2, arg3):
  (4, 4)->(3, 3)    4.   pass             3.   pass

Args:
  original_source: the original source.
  modified_source: the modified source.
NT)Úkeependsr   r   F)r;   r£   r:   r<   r9   )ÚdifflibÚSequenceMatcherÚ
splitlinesÚget_matching_blocksÚ	enumerateÚaÚbr   r¢   Úsizer   )r3   r4   ÚmatcherÚmatching_blocksr=   ÚiÚblockÚprevious_blocks           r#   r6   r6   ¯  s~  € ô< ×%Ò%ØØ×"Ñ"¨DÐ"Ð1Ø×"Ñ"¨DÐ"Ð1ó€Gð
 ×1Ñ1Ó3€OØ*,€Nô ˜o×.‰ˆØ�‹6Ø�w‰w˜!‹|˜uŸw™w¨!›|Ø×%Ñ%Ü!Ø'(Ø%*§W¡WØ'(Ø%*§W¡WØ).ñôøð -°©UÑ3ˆNØ×!Ñ!ÜØ#1×#3Ñ#3°n×6IÑ6IÑ#IÈAÑ#MØ!&§¡Ø#1×#3Ñ#3°n×6IÑ6IÑ#IÈAÑ#MØ!&§¡Ø%)ñôð Œs�?Ó# aÑ'Õ'Ø×!Ñ!ÜØ#(§7¡7¨Q¡;Ø!&§¡¨5¯:©:Ñ!5Ø#(§7¡7¨Q¡;Ø!&§¡¨5¯:©:Ñ!5Ø%*ñ÷ñ1 /ðB Ðr(   Úoriginal_liner=   Ústart_indexc                 ó¦   • UnU[        U5      :  a?  X   nUR                  U s=::  a  UR                  ::  a   U$   US-  nU[        U5      :  a  M?  U$ )zGReturns the original index of the lines mappings for the original line.r   )r   r;   r£   )rµ   r=   r¶   r‘   Úmappings        r#   r8   r8   þ  sa   € ð €EØ
”#�nÓ%Ó
%Ø Ñ'ˆØ×!Ñ! ]ÕJ°g×6JÑ6JÔJØˆLð Kà�‰
ˆð	 ”#�nÓ%Õ
%ð
 €Lr(   ),rw   r¨   Úcollections.abcr   r   r   Údataclassesr   Útypingr   Úblack.nodesr   r	   r
   r   r   r   r   r   r   Úblib2to3.pgen2.tokenr   r   r�   rN   Útupler   r$   r¥   r'   r2   rG   rT   rZ   rM   rJ   rP   rh   r~   rœ   rf   r¢   r6   r8   r&   r(   r#   Ú<module>r¿      s2  ðÙ Eã ß :Ñ :Ý !Ý ÷
÷ 
õ 
÷ 0ð 8¨C¡=ð °T¸%ÀÀSÀ¹/Ñ5Jô ð,-˜u S¨# X™ð -°4ô -ð
Ø�e˜C ˜H‘oÑ&ðØ69ðà��c˜3�h‘Ñ ôð8MØ�e˜C ˜H‘oÑ&ðMàðMð ðMð 
ˆ%��S�‰/Ñô	Mð`9 dð 9°:¸eÀCÈÀH¹oÑ3Nð 9ÐSWô 9ð@ rð ¨dô ô3A ¨¡ô 3Aðl3>¨$ð 3>¸3¸s¹8ð 3>Èô 3>ðl%
¨bð %
°Tô %
ðP
°¸±ð 
È$ð 
ÐSWô 
ð<3˜ð 3 #ô 3ð 5¨¨T°"©X¨Ñ#6ð ¸3¸s¹8ô ð6 ÷ð ó ðð"LØðLàðLð ˆmÑôLð^Øðà˜]Ñ+ðð ðð 	õ	r(   