
    c                    .   U d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl	m
Z
mZ d dl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 	 d dlZn# e$ r dZY nw xY w	 d dlmZ n# e$ r dZY nw xY we
rd dlmZ daded<   	 d#d$dZ d%dZ!d&dZ"	 d#d'd"Z#dS )(    )annotationsN)defaultdict)IterableSequence)TYPE_CHECKINGAny)	reporters)_patch_sys_path)Message)FileItem)LinterStatsmerge_stats)ProcessPoolExecutor)PyLinterzPyLinter | None_worker_linterlinterbytes	argumentsNone | str | Sequence[str]returnNonec                    t          j        |           at          sJ t                              t	          j                               t                                           t          |pd           dS )zFunction called to initialize a worker for a Process within a concurrent Pool.

    :param linter: A linter-class (PyLinter) instance pickled with dill
    :param arguments: File or module name(s) to lint and to be added to sys.path
     N)dillloadsr   set_reporterr	   CollectingReporteropenr
   )r   r   s     4lib/python3.11/site-packages/pylint/lint/parallel.py_worker_initializer    '   sj     Z''N 	 < > >??? IO$$$$$    	file_itemr   etuple[int, str | None, str, str | None, list[Message], LinterStats, int, defaultdict[str, list[Any]]]c                
   t           st          d          t                                            t                               |            t	          t
                    }t                                           D ]8}|                                }| ||j                 	                    |           9t           j
        j        }t          t           j
        t          j                  sJ t           j
                                         t           j        t#          j        dt&                     t)          t+          j                              t           j        | j        t           j        j        |t           j        t           j        |fS )Nz!Worker linter not yet initialisedzIn pylint 3.0 the current_name attribute of the linter object should be a string. If unknown it should be initialized as an empty string.)r   RuntimeErrorr   check_single_file_itemr   listget_checkersget_map_datanameappendreportermessages
isinstancer	   r   resetcurrent_namewarningswarnDeprecationWarningidmultiprocessingcurrent_processfilepath
file_state	base_namestats
msg_status)r"   mapreduce_datacheckerdatamsgss        r   _worker_check_single_filer@   <   sL     @>???)))444 &&N!..00 6 6##%% 	67<(//555"+Dn-y/KLLLLL!!###" 
J 	
 	
 	
 	?*,,--#!+!	 	r!   r   all_mapreduce_data3defaultdict[int, list[defaultdict[str, list[Any]]]]c                V   t          t                    }|                                D ]<}|D ]7}|                                D ] \  }}||                             |           !8=|                                 }|D ],}|j        |v r!|                    | ||j                            -dS )zJMerges map/reduce data across workers, invoking relevant APIs on checkers.N)r   r'   valuesitemsextendr(   r*   reduce_map_data)	r   rA   collated_map_reduce_datalinter_datarun_datachecker_namer>   original_checkersr=   s	            r   _merge_mapreduce_datarM   i   s     =H<M<M)0022 D D# 	D 	DH&.nn&6&6 D D"d(6==dCCCCD	D
 ++--$ T T<33 	T ##F,DW\,RSSS	T Tr!   jobsintfilesIterable[FileItem]c           
        t          j        t          |          }t          ||t	          j        |           f          5 }|                                  g }t          t                    }|	                    t          |          D ]\  }}	}
}}}}}|| j        _        d| j        _        |                     |	|
           |D ]}| j                            |           |                    |           ||                             |           | xj        |z  c_        	 ddd           n# 1 swxY w Y   t'          | |           t)          | j        g|z             | _        dS )a  Use the given linter to lint the files with given amount of workers (jobs).

    This splits the work filestream-by-filestream. If you need to do work across
    multiple files, as in the similarity-checker, then implement the map/reduce mixin functionality.
    )r   )max_workersinitializerinitargsFN)	functoolspartialr    r   r   dumpsr   r   r'   mapr@   r8   r9   _is_base_filestateset_current_moduler,   handle_messager+   r;   rM   r   r:   )r   rN   rP   r   rT   executor	all_statsrA   
worker_idxmodule	file_pathr9   r-   r:   r;   r<   msgs                    r   check_parallelrc      s    #$6)LLLK	kTZ=O=O<Q
 
 
 ,		  	  \\3U;;	, 	, 	
*3F'38F0%%fi888 4 4..s3333U###z*11.AAA+#	,, , , , , , , , , , , , , , ,> &"4555~	9::FLLLs   CD--D14D1)N)r   r   r   r   r   r   )r"   r   r   r#   )r   r   rA   rB   r   r   )
r   r   rN   rO   rP   rQ   r   r   r   r   )$
__future__r   rV   r1   collectionsr   collections.abcr   r   typingr   r   r   pylintr	   pylint.lint.utilsr
   pylint.messager   pylint.typingr   pylint.utilsr   r   r5   ImportErrorconcurrent.futuresr   pylint.lintr   r   __annotations__r    r@   rM   rc   r   r!   r   <module>rq      s  
 # " " " " " "      # # # # # # . . . . . . . . % % % % % % % %        - - - - - - " " " " " " " " " " " " 1 1 1 1 1 1 1 1   OOO6666666     %$$$$$$ #' & & & & <@% % % % %** * * *ZT T T T8 -1	/; /; /; /; /; /; /;s$   A AAA% %A/.A/