o
    b	                     @   s   d Z ddlmZ dd Zdd Zdd Zd	d
 Zdd Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS ) zTests for loopvar-in-closure.    )print_functionc                  C   s    g } t dD ]}| | qdS )No problems here.
   Nrangeappendlsti r   k/var/www/secure340b-portal/env/lib/python3.10/site-packages/pylint/test/functional/cellvar_escaping_loop.py	good_case   s   r   c                   C      dd t dD S )r   c                 S   s   g | ]}|qS r   r   .0r
   r   r   r   
<listcomp>   s    zgood_case2.<locals>.<listcomp>r   r   r   r   r   r   
good_case2      r   c                  C   s(   g } t dD ]}| |fdd qdS )r   r   c                 S      | S Nr   r
   r   r   r   <lambda>       zgood_case3.<locals>.<lambda>Nr   r   r   r   r   
good_case3   s   r   c                  C   s,   g } t dD ]}t| | dd  qdS )r   r   c                 S   r   r   r   r   r   r   r   r      r   zgood_case4.<locals>.<lambda>Nr   printr   r   r   r   r   
good_case4   s
   r   c                   C   r   )r   c                 s   s    | ]}|V  qd S r   r   r   r   r   r   	<genexpr>"   s    zgood_case5.<locals>.<genexpr>r   r   r   r   r   r   
good_case5    r   r   c                      s.   t dD ]  dkr fdd  S qdd S )z)Accept use of the variable inside return.r      c                          S r   r   r   r   r   r   r   )   r   zgood_case6.<locals>.<lambda>c                   S   s   dS )Nr   r   r   r   r   r   *   r   r   r   r   r   r   
good_case6%   s
   r#   c                      s&   t dD ] t fddd qdS )z"Lambda defined and called in loop.r   c                    s    |  S r   r   )xr   r   r   r   0   s    zgood_case7.<locals>.<lambda>   N)r   r   r   r   r   r   
good_case7-   s   r&   c                  C   s,   g } t dD ]}|fdd}| | q| S )z+Another eager binding of the cell variable.r   c                 S   r   )zIgnore.r   )Zbound_ir   r   r   func7   s   zgood_case8.<locals>.funcr   )Zfunsr
   r'   r   r   r   
good_case83   
   r(   c                     s0   g } t dD ] t  |  fdd qdS )Closing over a loop variable.r   c                      r!   r   r   r   r   r   r   r   C   r   zbad_case.<locals>.<lambda>Nr   )r	   r   r   r   bad_case>   s
   r+   c                   C   r   )r*   c                    s   g | ]  fd dqS )c                      r!   r   r   r   r   r   r   r   H   r   z&bad_case2.<locals>.<listcomp>.<lambda>r   r   r   r   r   r   H   s    zbad_case2.<locals>.<listcomp>r   r   r   r   r   r   	bad_case2F   r   r-   c                     s0   g } t dD ]}||  |  fdd q| S )&Closing over variable defined in loop.r   c                      r!   r   r   r   jr   r   r   P   r   zbad_case3.<locals>.<lambda>r   r   r   r/   r   	bad_case3K   s
   r1   c                     s,   g } t dD ]  fdd}| | q| S )r.   r   c                      s    d S )zNested function.   r   r   r   r   r   nestedX   s   zbad_case4.<locals>.nestedr   )r	   r3   r   r   r   	bad_case4T   r)   r4   c                   C   r   )a  Problematic case.

    If this function is used as

    >>> [x() for x in bad_case5()]

    it behaves 'as expected', i.e. the result is range(10).

    If it's used with

    >>> lst = list(bad_case5())
    >>> [x() for x in lst]

    the result is [9] * 10 again.
    c                 3   s    | ]	  fd dV  qdS )c                      r!   r   r   r   r   r   r   r   o   r   z%bad_case5.<locals>.<genexpr>.<lambda>Nr   r,   r   r   r   r   o   s    zbad_case5.<locals>.<genexpr>r   r   r   r   r   r   	bad_case5_   s   r5   c                     s@   g } t tdtddD ]\ }t| |  fdd q| S )r.   r      c                      r!   r   r   r   r   r   r   r   w   r   zbad_case6.<locals>.<lambda>)zipr   r   r   )r	   r0   r   r   r   	bad_case6r   s
   r8   N)__doc__
__future__r   r   r   r   r   r   r#   r&   r(   r+   r-   r1   r4   r5   r8   r   r   r   r   <module>   s    	