Viewing File: /opt/alt/python312/lib64/python3.12/lib2to3/fixes/__pycache__/fix_filter.cpython-312.pyc
�
<��i�
� �r � d Z ddlmZ ddlmZ ddlmZ ddlm Z m
Z
mZmZm
Z
G d� dej � Zy) a� Fixer that changes filter(F, X) into list(filter(F, X)).
We avoid the transformation if the filter() call is directly contained
in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or
for V in <>:.
NOTE: This is still not correct if the original code was depending on
filter(F, X) to return a string if X is a string and a tuple if X is a
tuple. That would require type inference, which we don't do. Let
Python 2.6 figure it out.
� )�
fixer_base)�Node)�python_symbols)�Name�ArgList�ListComp�in_special_context�parenthesizec � � e Zd ZdZdZdZd� Zy)� FixFilterTaV
filter_lambda=power<
'filter'
trailer<
'('
arglist<
lambdef< 'lambda'
(fp=NAME | vfpdef< '(' fp=NAME ')'> ) ':' xp=any
>
','
it=any
>
')'
>
[extra_trailers=trailer*]
>
|
power<
'filter'
trailer< '(' arglist< none='None' ',' seq=any > ')' >
[extra_trailers=trailer*]
>
|
power<
'filter'
args=trailer< '(' [any] ')' >
[extra_trailers=trailer*]
>
zfuture_builtins.filterc � � | j |� ry g }d|v r)|d D ]! }|j |j � � �# d|v r�|j d� j � }|j t
j k( rd|_ t |� }t |j d� j � |j d� j � |j d� j � |� }t t
j |g|z d�� }n�d|v r[t t d � t d � |d
j � t d � � }t t
j |g|z d�� }nt |� ry |d j � }t t
j t d� |gd�� }t t
j t d
� t |g� g|z � }d|_ |j |_ |S )N�extra_trailers�
filter_lambda�xp� �fp�it)�prefix�none�_f�seq�args�filter�list)�should_skip�append�clone�get�type�syms�testr r
r r �powerr r r )�self�node�results�trailers�tr �newr s �?/opt/alt/python312/lib64/python3.12/lib2to3/fixes/fix_filter.py� transformzFixFilter.transform: s� � ����D�!�����w�&��-�.�������� �*� /� �g�%����T�"�(�(�*�B��w�w�$�)�)�#��� �!�"�%���7�;�;�t�,�2�2�4�"�;�;�t�,�2�2�4�"�;�;�t�,�2�2�4�b�:�C� �t�z�z�C�5�8�#3�B�?�C�
�w�
��4��:���:�"�5�>�/�/�1���:�'�C� �t�z�z�C�5�8�#3�B�?�C� "�$�'���6�?�(�(�*�D��t�z�z�D��N�D�#9�"�E�C��t�z�z�D��L�'�3�%�.�#A�H�#L�M�C��C�J��[�[��
��
� N)�__name__�
__module__�__qualname__�
BM_compatible�PATTERN�skip_onr* � r+ r) r r s � ��M��G�<