Your IP : 18.224.38.170


Current Path : /opt/alt/python312/lib64/python3.12/lib2to3/fixes/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/lib2to3/fixes/__pycache__/fix_tuple_params.cpython-312.pyc

�

�Q�f����dZddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZd�Z
Gd�dej�Zd	�Zd
�Zgdfd�Zd
�Zy)a:Fixer for function definitions with tuple parameters.

def func(((a, b), c), d):
    ...

    ->

def func(x, d):
    ((a, b), c) = x
    ...

It will also support lambdas:

    lambda (x, y): x + y -> lambda t: t[0] + t[1]

    # The parens are a syntax error in Python 3
    lambda (x): x + y -> lambda x: x + y
�)�pytree)�token)�
fixer_base)�Assign�Name�Newline�Number�	Subscript�symsc��t|tj�xr*|jdjt
jk(S)N�)�
isinstancer�Node�children�typer�STRING)�stmts �E/opt/alt/python312/lib64/python3.12/lib2to3/fixes/fix_tuple_params.py�is_docstringrs5���d�F�K�K�(�1��=�=��� � �E�L�L�0�1�c�$�eZdZdZdZdZd�Zd�Zy)�FixTupleParams�Ta
              funcdef< 'def' any parameters< '(' args=any ')' >
                       ['->' any] ':' suite=any+ >
              |
              lambda=
              lambdef< 'lambda' args=vfpdef< '(' inner=any ')' >
                       ':' body=any
              >
              c�����
�d|vr�j||�Sg�
|d}|d}|djdjtjk(r)d}|djdj
}t
��n(d}d}tjtjd��d��
�fd	�	}|jtjk(r	||�ne|jtjk(rHt|j�D]0\}}	|	jtjk(s�$||	|dkD�
��2�
sy�
D]}
|d|
_
�|}|dk(rd�
d_n*t|dj|�r|�
d_|dz}�
D]}
|d|
_
��
|dj||t!|dz|t#�
�zdz�D]}||dj|_�|dj%�y)
N�lambda�suite�argsr
�rz; �c�T��t�j��}|j�}d|_t	||j��}|rd|_|j|��j
tjtj|�j�g��y)Nr� )r�new_name�clone�prefixr�replace�appendrrr�simple_stmt)�	tuple_arg�
add_prefix�n�argr�end�	new_lines�selfs     ���r�handle_tuplez.FixTupleParams.transform.<locals>.handle_tupleCs����T�]�]�_�%�A��/�/�#�C��C�J��#�q�w�w�y�)�D��������a� ����V�[�[��)9�)9�*.��	�	��)<�>�
?r)r)r!)F)�transform_lambdarrr�INDENT�valuerr�Leafr�tfpdef�
typedargslist�	enumerate�parentr$r�range�len�changed)r.�node�resultsrr�start�indentr/�ir+�line�afterr,r-s`           @@r�	transformzFixTupleParams.transform.s�����w���(�(��w�7�7��	��� ���v�����8���Q��$�$����4��E��1�X�&�&�q�)�/�/�F��)�C��E��F��+�+�e�l�l�B�/�C�
		?��9�9����#����
�Y�Y�$�,�,�
,�#�D�M�M�2���3��8�8�t�{�{�*�!��!�a�%�9�	3����D���(�D�K�����A�:�"%�I�a�L��
�%��(�+�+�E�2�
3�"(�I�a�L���A�I�E��D���(�D�K��)2��a����%��&��u�Q�w��c�)�n� 4�Q� 6�7�A�*0�E�!�H���a� �'�8�
�a����rc�
�|d}|d}t|d�}|jtjk(r)|j	�}d|_|j
|�yt|�}t|�}|jt|��}t|d��}	|j
|	j	��|j�D]�}
|
jtjk(s�!|
j|vs�0||
jD�cgc]}|j	���}}tjt j"|	j	�g|z�}
|
j
|
_|
j
|
���ycc}w)Nr�body�innerr!)r$)�
simplify_argsrr�NAMEr#r$r%�find_params�map_to_indexr"�
tuple_namer�
post_orderr2rrr�power)r.r;r<rrDrE�params�to_index�tup_name�	new_paramr*�c�
subscripts�news              rr0zFixTupleParams.transform_lambdans-���v����v����g�g�.�/���:�:����#��K�K�M�E��E�L��L�L�����T�"����'���=�=��F�!3�4����#�.�	����Y�_�_�&�'����"�A��v�v����#����8�(;�19�!�'�'�1B�C�1B�A�a�g�g�i�1B�
�C��k�k�$�*�*�#,�?�?�#4�"5�
�"B�D���X�X��
��	�	�#��
#��Cs�FN)�__name__�
__module__�__qualname__�	run_order�
BM_compatible�PATTERNrBr0�rrrrs���I��M��G�>�@rrc�L�|jtjtjfvr|S|jtj
k(rL|jtj
k(r-|jd}|jtj
k(r�-|Std|z��)NrzReceived unexpected node %s)rr�vfplistrrG�vfpdefr�RuntimeError)r;s rrFrF�sx���y�y�T�\�\�5�:�:�.�.���	
���d�k�k�	!��i�i�4�;�;�&��=�=��#�D��i�i�4�;�;�&���
�4�t�;�
<�<rc�J�|jtjk(rt|jd�S|jt
jk(r|jS|jD�cgc]+}|jt
jk7s�!t|���-c}Scc}w)Nr)	rrr]rHrrrGr2�COMMA)r;rQs  rrHrH�so���y�y�D�K�K���4�=�=��+�,�,�	
���e�j�j�	 ��z�z��$(�M�M�K�M�q�Q�V�V�u�{�{�5J�K��N�M�K�K��Ks�-"B �
B Nc��|�i}t|�D]J\}}ttt|���g}t	|t
�rt
|||���C||z||<�L|S)N)�d)r6r
r	�strr�listrI)�
param_listr$rbr?�obj�trailers      rrIrI�s_���y����J�'���3��V�C��F�^�,�-���c�4� ���g��+��g�%�A�c�F�(�
�Hrc��g}|D]>}t|t�r|jt|���.|j|��@dj	|�S)N�_)rrdr&rJ�join)re�lrfs   rrJrJ�sF��
�A����c�4� �
�H�H�Z��_�%�
�H�H�S�M�	�
�8�8�A�;�r)�__doc__rr�pgen2rr�
fixer_utilrrrr	r
rr�BaseFixrrFrHrIrJrZrr�<module>rpsQ���*���G�G�1�g�Z�'�'�g�X	=�L�%'�$�	
�r

?>