o
    b4                     @   s   d Z ddlZddlmZ dZG dd deZG dd deZG d	d
 d
eZG dd deZ	d(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*test for Python 3 string formatting error
    N)Missing   c                   @      e Zd ZdZdd ZdS )Customz Has a __getattr__ c                 C      | S N )self_r   r   g/var/www/secure340b-portal/env/lib/python3.10/site-packages/pylint/test/functional/string_formatting.py__getattr__      zCustom.__getattr__N)__name__
__module____qualname____doc__r   r   r   r   r   r   	       r   c                   @   s&   e Zd ZdZe Zdddg dgZdS )Testz test format attribute access r         )         N)r   r   r   r   r   Zcustomidsr   r   r   r   r      s    r   c                   @   r   )Getitemz' test custom getitem for lookup access c                 C   s   dS )N*   r   )r	   indexr   r   r   __getitem__   r   zGetitem.__getitem__N)r   r   r   r   r   r   r   r   r   r      r   r   c                   @   s   e Zd ZdZe ZdS )	ReturnYesz can't be properly infered N)r   r   r   r   r   missingr   r   r   r   r      s    
r   errorc                 C   r   )z Test r   )messageZmessage_typer   r   r   log   s   r"   c                   C   s  d dd d d d d dj dd d	j t d
 td d d t  d t  dj t d dj dggd d dddii dj t d dj g d dj t d dj t d dj t gd d dg dj ddg  dj di ddd dj t d dS )z Good format strings {0} {1}r   r   z{0!r:20}ZHelloz{!r:20}z{a!r:20}az{pid})pid{}z{0.missing.length}z{1.missing.length}z{a.ids[3][1]}z	{a[0][0]}{[0][0]}r   z{a.test}z{a.__len__}z{a.ids.__len__}{a[0]}test{a} {b}r%   bz{a}Nr   )	formatosgetpidstrr   r   r   r   r   r   r   r   r   
print_good    s(   

r2   c                   C   s@  d d d   d   d dd dj ddd d	 dd d
 d d
 ddd d   d
j ddd d dd d ddd dj t d dj t d dj t d d dg d d dj dd dj td td dd d d d dd d ddd dj d d d! d g d! d gd"d# d$S )%zTest string format z{{}}r   z{} {z{} }z{0} {}r   r+   )r%   cz{} {a}z{} {}r   z{a} {b} {c}r,   z{0} {1} {a}z{a.ids.__len__.length}r$   z{a.ids[3][400]}z{a.ids[3]['string']}z{[0][1]}r%   r(   )r   z{b[0]}   r)   r'   infoz{0.missing}z{0} {1} {2}r#   z{0} {a}r   z{[0]} {}r   r   N)r.   r   objectr"   r   r   r   r   
pprint_bad8   s4   



r7   c                  O   s   d |  d | dS )z@ Test that using kwargs does not emit a false
    positive.
    zHello John Doe {0[0]}zHello {0[name]}Nr.   )argskwargsr   r   r   good_issue288Z   s   
r;   c                  C   s.   d} ddi}d|d< |d  | |d< || fS )z Test that the string format checker skips
    format nodes which don't have a string as a parent
    (but a subscript, name etc).
    Zqwertycomment z$MySQL grant {0} is set to be revokedr8   )nameretr   r   r   good_issue287a   s
   r@   c                   C   s^   d dd dj dddgd d dd d d d ddd	 d
 d dj ddd dS )z Test nested format fields. z{0:>{1}}r      z{0:{a[1]}} {a}r   r   r$   z{:>{}}6   z
{0:{a[1]}}z	{0:{a.x}}Nr8   r   r   r   r   nested_issue294l   s   

rC   c                   C   s   d dd d d dS )z> Test a regression using duplicate manual position arguments. z{0} {1} {0}r   r   Nr8   r   r   r   r   issue310v   s   rD   c                   C   s0   d dddi d dddid d d dS )za Test a regression using mixed manual position arguments
    and attribute access arguments.
    z{0}{1[FOO]}{   ZFOOi  iA  Nr8   r   r   r   r   issue322{   s   rF   c                  C   s&   ddl m}  G dd d| dd}|S )z
    Check that using a namedtuple subclass doesn't crash when
    trying to infer EmptyNodes (resulted after mocking the
    members of namedtuples).
    r   )
namedtuplec                   @   r   )zissue338.<locals>.Crashzd Looking for attributes in __str__ will crash,
        because EmptyNodes can't be infered.
        c                 S   s
   d | S )Nz{0.foo}: {0.bar}r8   r	   r   r   r   __str__      
zissue338.<locals>.Crash.__str__N)r   r   r   r   rI   r   r   r   r   Crash   s    rK   Czfoo bar)collectionsrG   )rG   rK   r   r   r   issue338   s   rN   c                  C   s(   dj } | d | dd | ddd dS )zI
    Check that the format method can be assigned to a variable, ie:
    z
test {} {}Zarg1Zarg2Zarg3Nr8   )fmtr   r   r   issue351   s   
rP   c                  C   s   G dd dt } | S )z4
    Ignore any object coming from an argument.
    c                   @   s*   e Zd ZdZd	ddZdd Zdd ZdS )
zissue373.<locals>.SomeClassz empty docstring. Nc                 S   s
   || _ d S r   )opts)r	   rQ   r   r   r   __init__   rJ   z$issue373.<locals>.SomeClass.__init__c                 S   s   d || jS )zDon't try to analyze this.zA{0}{1}r.   rQ   )r	   argr   r   r   dunc   s   z issue373.<locals>.SomeClass.duncc                 S   s   d | jS )z*Don't try to analyze the following string.zAAA{0[iface]}BBB{0[port]}rS   rH   r   r   r   func   s   z issue373.<locals>.SomeClass.funcr   )r   r   r   r   rR   rU   rV   r   r   r   r   	SomeClass   s
    
rW   )r6   )rW   r   r   r   issue373   s   rX   c                  C   s   d d} d dg}| |fS )zl
    Mix positional arguments, `{0}`, with positional
    arguments with attribute access, `{0.__x__}`.
    z{0.__class__.__name__}: {0}r   z{0[0]}: {0}r   r8   )dataZdata2r   r   r   	issue_463   s   
rZ   c                   C   s
   d dS )z0The following string is invalid, avoid crashing.z%There are {.:2f} undiscovered errors.r   r8   r   r   r   r   avoid_empty_attribute   s   
r[   )r    )r   r/   r   r   Z__revision__r6   r   r   r   r   r"   r2   r7   r;   r@   rC   rD   rF   rN   rP   rX   rZ   r[   r   r   r   r   <module>   s*    
"
	
