
    e                    r    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
 erd dlmZ  G d de      Zdd	Zy
)    )annotations)TYPE_CHECKING)nodes)BaseChecker)only_required_for_messages
safe_infer)PyLinterc                  J    e Zd ZdZdZ ed      ZddiZ ed      d	d       Z	y)
ThreadingCheckerzChecks for threading module.

    - useless with lock - locking used in wrong way that has no effect (with threading.Lock():)
    	threading)zthreading.Lockzthreading.RLockzthreading.Conditionzthreading.Semaphorezthreading.BoundedSemaphoreW2101)z/'%s()' directly created in 'with' has no effectuseless-with-lockzUsed when a new lock instance is created by using with statement which has no effect. Instead, an existing instance should be used to acquire lock.r   c                   d |j                   D        }|D ]h  }t        |t        j                        st	        |j
                        }|6|j                         }|| j                  v sU| j                  d||       j y )Nc              3  \   K   | ]$  \  }}t        |t        j                        s!| & y wN)
isinstancer   Call).0c_s      C/usr/lib/python3/dist-packages/pylint/checkers/threading_checker.py	<genexpr>z.ThreadingChecker.visit_with.<locals>.<genexpr>/   s!     R$!Q
1ejj8QARs   ",,r   )nodeargs)	itemsr   r   r   r   funcqnameLOCKSadd_message)selfr   context_managerscontext_managerinfered_functionr   s         r   
visit_withzThreadingChecker.visit_with-   sz    R$**R/ 	QO/5::6#-o.B.B#C #+(..0DJJ&$$%8t%$P	Q    N)r   z
nodes.WithreturnNone)
__name__
__module____qualname____doc__name	frozensetr   msgsr   r$    r%   r   r   r      sJ    
 D	
E 	 
D   34	Q 5	Qr%   r   c                8    | j                  t        |              y r   )register_checkerr   )linters    r   registerr3   :   s    
,V45r%   N)r2   r	   r&   r'   )
__future__r   typingr   astroidr   pylint.checkersr   pylint.checkers.utilsr   r   pylint.lintr	   r   r3   r/   r%   r   <module>r:      s0   
 #    ' H$%Q{ %QP6r%   