
    c                    z    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dS )    )annotations)TYPE_CHECKING)nodes)BaseChecker)only_required_for_messages
safe_infer)PyLinterc                  ^    e Zd ZdZdZ ed          ZddiZ ed          dd            Z	dS )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   node
nodes.WithreturnNonec                    d |j         D             }|D ]h}t          |t          j                  rLt	          |j                  }|3|                                }|| j        v r|                     d||           id S )Nc              3  T   K   | ]#\  }}t          |t          j                  |V  $d S N)
isinstancer   Call).0c_s      Alib/python3.11/site-packages/pylint/checkers/threading_checker.py	<genexpr>z.ThreadingChecker.visit_with.<locals>.<genexpr>/   s7      RR$!Q
1ej8Q8QRARRRRRR    r   )r   args)	itemsr   r   r   r   funcqnameLOCKSadd_message)selfr   context_managerscontext_managerinfered_functionr!   s         r   
visit_withzThreadingChecker.visit_with-   s    RR$*RRR/ 	Q 	QO/5:66 Q#-o.B#C#C # (..00DJ& Q$$%8t%$PPP	Q 	Qr   N)r   r   r   r   )
__name__
__module____qualname____doc__name	frozensetr"   msgsr   r(    r   r   r   r      s         
 DI	
 E 	 
D   344	Q 	Q 	Q 54	Q 	Q 	Qr   r   linterr	   r   r   c                J    |                      t          |                      d S r   )register_checkerr   )r1   s    r   registerr4   :   s%    
,V4455555r   N)r1   r	   r   r   )
__future__r   typingr   astroidr   pylint.checkersr   pylint.checkers.utilsr   r   pylint.lintr	   r   r4   r0   r   r   <module>r;      s   
 # " " " " "                   ' ' ' ' ' ' H H H H H H H H %$$$$$$%Q %Q %Q %Q %Q{ %Q %Q %QP6 6 6 6 6 6r   