B
    Ç S]Ë  ã               @   s6   d Z ddlmZ ddlmZmZ G dd„ dejƒZdS )zuFixer that addes parentheses where they are required

This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``.é   )Ú
fixer_base)ÚLParenÚRParenc               @   s   e Zd ZdZdZdd„ ZdS )ÚFixParenTa  
        atom< ('[' | '(')
            (listmaker< any
                comp_for<
                    'for' NAME 'in'
                    target=testlist_safe< any (',' any)+ [',']
                     >
                    [any]
                >
            >
            |
            testlist_gexp< any
                comp_for<
                    'for' NAME 'in'
                    target=testlist_safe< any (',' any)+ [',']
                     >
                    [any]
                >
            >)
        (']' | ')') >
    c             C   s8   |d }t ƒ }|j|_d|_| d|¡ | tƒ ¡ d S )NÚtargetÚ é    )r   ÚprefixZinsert_childZappend_childr   )ÚselfZnodeZresultsr   Zlparen© r   ú(lib/python3.7/lib2to3/fixes/fix_paren.pyÚ	transform%   s    zFixParen.transformN)Ú__name__Ú
__module__Ú__qualname__ZBM_compatibleZPATTERNr   r   r   r   r   r      s   r   N)Ú__doc__r   r   Z
fixer_utilr   r   ZBaseFixr   r   r   r   r   Ú<module>   s   