o
    gH                     @   s6   d dl Z d dlmZ d dlmZmZ G dd dZdS )    N)nodes)MSG_STATE_SCOPE_MODULEWarningScopec                   @   sJ   e Zd ZdZdddZdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )	FileStatez;Hold internal state specific to the currently analyzed fileNc                 C   s.   || _ i | _i | _tt| _i | _d | _d S N)		base_name_module_msgs_state_raw_module_msgs_statecollectionsdefaultdictset_ignored_msgs_suppression_mapping_effective_max_line_number)selfmodname r   U/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/utils/file_state.py__init__   s   
zFileState.__init__c                 C   sR   | j  D ]\}}| | j|< q| j  }i | _ i | _|j| _| ||| dS )z9Walk the AST to collect block level options line numbers.N)r   itemscopyr	   r   tolinenor   _collect_block_lines)r   
msgs_storemodule_nodemsglines
orig_stater   r   r   collect_block_lines   s   
zFileState.collect_block_linesc                 C   sb  |  D ]	}| ||| q|j}|j}t|tjtjtjfr)|j	r)|j	d j}n|}|
 D ]\}}	t|	
 D ]t\}
}|
}||
ksG||
k rHq9||}|D ]}|jtjkre|
|kr]d}||
\}}qO|
}|}qOt||d D ]8}|| j|dv r}qq||	v r|	| }|}|s|| j||f< z	|| j| |< W qq ty   ||i| j|< Y qqw |	|
= q9q/dS )z`Recursively walk (depth first) AST to collect block level options
        line numbers.
        r   T   r   N)get_childrenr   
fromlinenor   
isinstancer   ModuleClassDefFunctionDefbodyr   listget_message_definitionsscoper   NODEblock_rangeranger   getr   KeyError)r   r   node	msg_statechildfirstlastfirstchildlinenomsgidr   linenostateoriginal_linenomessage_definitionsmessage_definitionfirst_last_liner   r   r   r       sN   
zFileState._collect_block_linesc                 C   sH   |dksJ z|| j |j |< W dS  ty#   ||i| j |j< Y dS w )z@Set status (enabled/disable) for a given message at a given liner   N)r   r5   r.   )r   r   r=   statusr   r   r   set_msg_status]   s   zFileState.set_msg_statusc                 C   sJ   |t kr#z| j||f }| j||f | W dS  ty"   Y dS w dS )a  Report an ignored message.

        state_scope is either MSG_STATE_SCOPE_MODULE or MSG_STATE_SCOPE_CONFIG,
        depending on whether the message was disabled locally in the module,
        or globally. The other arguments are the same as for add_message.
        N)r   r   r   addr.   )r   state_scoper5   r=   r/   args
confidence	orig_liner   r   r   handle_ignored_messagee   s   	z FileState.handle_ignored_messagec                 c   s    | j  D ]$\}}| D ]\}}|s)||f| jvr)|dkr)d|||ffV  qqt| j D ]\\}}}|D ]}d||||ffV  q:q2d S )NR0401zuseless-suppressionzsuppressed-message)r	   r   r   get_msg_display_stringr'   )r   r   warningr   r=   enablefrom_r   r   r   "iter_spurious_suppression_messagesu   s$   	
z,FileState.iter_spurious_suppression_messagesc                 C   s   | j S r   )r   )r   r   r   r   get_effective_max_line_number   s   z'FileState.get_effective_max_line_numberr   )__name__
__module____qualname____doc__r   r   r   r?   rE   rK   rL   r   r   r   r   r      s    

=r   )r
   astroidr   pylint.constantsr   r   r   r   r   r   r   <module>   s   