Your IP : 18.224.38.170
�
�Q�f� � � � d Z ddlmZ ddlmZ ddlmZ ddlmZmZm Z m
Z
mZmZ d� Z
G d� dej � Zd � Zd
� Zg dfd�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 | t j � xr* | j d j t
j k( S )N� )�
isinstancer �Node�children�typer �STRING)�stmts �E/opt/alt/python312/lib64/python3.12/lib2to3/fixes/fix_tuple_params.py�is_docstringr s5 � ��d�F�K�K�(� 1��=�=��� � �E�L�L�0�1� c �$ � e Zd ZdZdZdZd� Zd� Zy)�FixTupleParams� Ta
funcdef< 'def' any parameters< '(' args=any ')' >
['->' any] ':' suite=any+ >
|
lambda=
lambdef< 'lambda' args=vfpdef< '(' inner=any ')' >
':' body=any
>
c �� � ��
� d|v r� j ||� S g �
|d }|d }|d j d j t j k( r)d}|d j d j
}t
� �n(d}d}t j t j d� �d��
� fd � }|j t j k( r ||� ne|j t j k( rHt |j � D ]0 \ }} | j t j k( s�$ || |dkD �
� �2 �
sy �
D ] }
|d |
_
� |}|dk( rd�
d _ n*t |d j | � r|�
d _ |dz }�
D ] }
|d |
_
� �
|d j || t! |dz |t# �
� z dz � D ] }||d j | _ � |d j% � y )
N�lambda�suite�argsr
� r z; � c �T �� t �j � � }| j � }d|_ t ||j � � }|rd|_ | j |� �j
t j t j |�j � g� � y )Nr � )r �new_name�clone�prefixr �replace�appendr r r �simple_stmt)� tuple_arg�
add_prefix�n�argr �end� new_lines�selfs ���r �handle_tuplez.FixTupleParams.transform.<locals>.handle_tupleC s �� ��T�]�]�_�%�A��/�/�#�C��C�J��#�q�w�w�y�)�D��������a� ����V�[�[��)9�)9�*.�� � ��)<�>�
?r )r) r! )F)�transform_lambdar r r �INDENT�valuer r �Leafr �tfpdef�
typedargslist� enumerate�parentr$ r �range�len�changed)r. �node�resultsr r �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����r c �
� |d }|d }t |d � }|j t j k( r)|j � }d|_ |j
|� y t |� }t |� }| j t |� � }t |d�� } |j
| j � � |j � D ]� }
|
j t j k( s�!|
j |v s�0||
j D �cg c] }|j � �� }}t j t j"