
    cM7                       d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
mZ ddlmZmZ ddlmZmZmZmZ erddlmZ dd	lmZ dd
lmZ  G d dej                  Z G d de          Z G d dej                  Z G d de          Z G d de          Z  G d de          Z! G d de          Z" G d de          Z# G d de          Z$ G d de          Z% G d d e          Z& G d! d"e          Z' G d# d$e          Z( G d% d&e          Z) G d' d(e          Z* G d) d*e          Z+ G d+ d,e+          Z, G d- d.e,          Z- G d/ d0e,          Z. G d1 d2e+          Z/ G d3 d4e          Z0dS )5z%Callback actions for various options.    )annotationsN)CallableSequence)Path)TYPE_CHECKINGAny)
exceptions
extensions
interfacesutils)_HelpFormatter)PyLinter)Runc                  8    e Zd ZdZej        	 ddd            ZdS )_CallbackActionzCustom callback action.Nparserargparse.ArgumentParser	namespaceargparse.Namespacevaluesstr | Sequence[Any] | Noneoption_string
str | NonereturnNonec                    t           NNotImplementedErrorselfr   r   r   r   s        >lib/python3.11/site-packages/pylint/config/callback_actions.py__call__z_CallbackAction.__call__   
     "!    r   
r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname____doc__abcabstractmethodr#    r%   r"   r   r      sF        !! %)" " " " " " "r%   r   c                      e Zd ZdZ	 dddZdS )_DoNothingActionzAction that just passes.

    This action is used to allow pre-processing of certain options
    without erroring when they are then processed again by argparse.
    Nr   r   r   r   r   r   r   r   r   r   c                    d S r   r-   r    s        r"   r#   z_DoNothingAction.__call__0   s	     tr%   r   r&   r'   r(   r)   r*   r#   r-   r%   r"   r/   r/   )   s<          %)      r%   r/   c                      e Zd ZdZ	 dddZdS )_ExtendActionzAction that adds the value to a pre-existing list.

    It is directly copied from the stdlib implementation which is only available
    on 3.8+.
    Nr   r   r   r   r   r   r   r   r   r   c                    t          |t          t          f          sJ t          || j        g           }t          |t                    sJ |                    |           t          || j        |           d S r   )
isinstancetuplelistgetattrdestextendsetattr)r!   r   r   r   r   currents         r"   r#   z_ExtendAction.__call__A   ss     &5$-00000)TY33'4(((((v	49g.....r%   r   r&   r1   r-   r%   r"   r3   r3   :   s<          %)/ / / / / / /r%   r3   c                  \     e Zd ZdZ	 	 	 	 	 	 	 	 d d! fdZej        	 d"d#d            Z xZS )$_AccessRunObjectActionz)Action that has access to the Run object.NF option_stringsSequence[str]r9   strnargsr   constdefaulttypechoicesrequiredboolhelpmetavarkwargsr   r   c                v    |d         | _         t                                          ||d||||||	|

  
         d S )Nr   r   runsuper__init__r!   r@   r9   rC   rD   rE   rF   rG   rH   rJ   rK   rL   	__class__s               r"   rQ   z_AccessRunObjectAction.__init__R   sT     %=	
 	
 	
 	
 	
r%   r   r   r   r   r   r   r   r   c                    t           r   r   r    s        r"   r#   z_AccessRunObjectAction.__call__o   r$   r%   NNNNNFr?   r?   r@   rA   r9   rB   rC   r   rD   r   rE   r   rF   r   rG   r   rH   rI   rJ   rB   rK   rB   rL   r   r   r   r   r&   	r'   r(   r)   r*   rQ   r+   r,   r#   __classcell__rS   s   @r"   r>   r>   O   s        33 
 
 
 
 
 
 
: 	 %)" " " " " " " " "r%   r>   c                  B     e Zd ZdZ	 	 	 	 	 	 	 	 d!d" fdZ	 d#d$d Z xZS )%_MessageHelpActionz&Display the help message of a message.NFr?   r@   rA   r9   rB   rC   r   rD   rE   rF   rG   rH   rI   rJ   rK   rL   r   r   c                v    |d         | _         t                                          ||d||||||	|

  
         d S )Nr   +rN   rR   s               r"   rQ   z_MessageHelpAction.__init__}   sT     %=	
 	
 	
 	
 	
r%   
--help-msgr   r   r   r   r   str | Sequence[str] | Noner   r   c                   t          |t          t          f          sJ g }|D ]0}t          |t                    sJ |t	          j        |          z  }1| j        j        j        	                    |           t          j        d           d S Nr   )r5   r7   r6   rB   r   
_check_csvrO   linter
msgs_storehelp_messagesysexit)r!   r   r   r   r   values_to_printmsgs          r"   r#   z_MessageHelpAction.__call__   s     &4-00000%' 	5 	5Cc3'''''u/444OO"//@@@r%   rU   rV   )r^   )
r   r   r   r   r   r_   r   r   r   r   )r'   r(   r)   r*   rQ   r#   rX   rY   s   @r"   r[   r[   z   s        00 
 
 
 
 
 
 
B %1        r%   r[   c                      e Zd ZdZ	 dddZdS )_ListMessagesActionzDisplay all available messages.--list-enabledr   r   r   r   r   r   r   r   r   r   c                t    | j         j        j                                         t	          j        d           d S ra   )rO   rc   rd   list_messagesrf   rg   r    s        r"   r#   z_ListMessagesAction.__call__   s.     	"00222r%   N)rl   r&   r1   r-   r%   r"   rk   rk      s8        )) %5      r%   rk   c                      e Zd ZdZ	 dddZdS )_ListMessagesEnabledActionzDisplay all enabled messages.--list-msgs-enabledr   r   r   r   r   r   r   r   r   r   c                j    | j         j                                         t          j        d           d S ra   )rO   rc   list_messages_enabledrf   rg   r    s        r"   r#   z#_ListMessagesEnabledAction.__call__   s+     	--///r%   N)rq   r&   r1   r-   r%   r"   rp   rp      s8        '' %:      r%   rp   c                      e Zd ZdZ	 dddZdS )_ListCheckGroupsActionz5Display all the check groups that pylint knows about.--list-groupsr   r   r   r   r   r   r   r   r   r   c                    | j         j                                        D ]}t          |           t	          j        d           d S ra   )rO   rc   get_checker_namesprintrf   rg   )r!   r   r   r   r   checks         r"   r#   z_ListCheckGroupsAction.__call__   sA     X_6688 	 	E%LLLLr%   N)rv   r&   r1   r-   r%   r"   ru   ru      s8        ?? %4	 	 	 	 	 	 	r%   ru   c                      e Zd ZdZ	 dddZdS )_ListConfidenceLevelsActionz:Display all the confidence levels that pylint knows about.--list-conf-levelsr   r   r   r   r   r   r   r   r   r   c                p    t           j        D ]}t          d|            t          j        d           d S )Nz%-18s: r   )r   CONFIDENCE_LEVELSry   rf   rg   )r!   r   r   r   r   levels         r"   r#   z$_ListConfidenceLevelsAction.__call__   sA      1 	% 	%E#E##$$$$r%   N)r}   r&   r1   r-   r%   r"   r|   r|      s8        DD %9	 	 	 	 	 	 	r%   r|   c                      e Zd ZdZ	 dddZdS )_ListExtensionsActionz/Display all extensions under pylint.extensions.--list-extensionsr   r   r   r   r   r   r   r   r   r   c                >   t          t          j                  j                                        D ]W}|j        dk    rJ|j                            d          s0|j                            d          \  }}}t          d|            Xt          j        d           d S )Nz.py_.zpylint.extensions.r   )r   r
   __file__parentiterdirsuffixstem
startswith	partitionry   rf   rg   )r!   r   r   r   r   filenameextension_namer   s           r"   r#   z_ListExtensionsAction.__call__   s     Z0118@@BB 	= 	=H%' =0H0H0M0M ='/}'>'>s'C'C$1;>;;<<<r%   N)r   r&   r1   r-   r%   r"   r   r      s8        99 %8      r%   r   c                      e Zd ZdZ	 dddZdS )_FullDocumentationActionzDisplay the full documentation.--full-documentationr   r   r   r   r   r   r   r   r   r   c                j    t          j        | j        j                   t	          j        d           d S ra   )r   print_full_documentationrO   rc   rf   rg   r    s        r"   r#   z!_FullDocumentationAction.__call__   s*     	&tx777r%   N)r   r&   r1   r-   r%   r"   r   r      s8        )) %;      r%   r   c                      e Zd ZdZ	 dddZdS )_GenerateRCFileActionzGenerate a pylintrc file.--generate-rcfiler   r   r   r   r   r   r   r   r   r   c                    t          j                    5  t          j        dt                     | j        j                            d           d d d            n# 1 swxY w Y   t          j        d           d S )Nignore)category)Commands)skipsectionsr   )	warningscatch_warningsfilterwarningsDeprecationWarningrO   rc   generate_configrf   rg   r    s        r"   r#   z_GenerateRCFileAction.__call__  s     $&& 	H 	H#H7IJJJJHO+++GGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	s   <AA #A N)r   r&   r1   r-   r%   r"   r   r     s8        ## %8      r%   r   c                      e Zd ZdZ	 dddZdS )_GenerateConfigFileActionz+Generate a .toml format configuration file.--generate-toml-configr   r   r   r   r   r   r   r   r   r   c                    t          | j        j                                                   t	          j        d           d S ra   )ry   rO   rc   _generate_config_filerf   rg   r    s        r"   r#   z"_GenerateConfigFileAction.__call__  s3     	dho3355666r%   N)r   r&   r1   r-   r%   r"   r   r     s8        55 %=      r%   r   c                      e Zd ZdZ	 dddZdS )_ErrorsOnlyModeActionzTurn on errors-only mode.

    Error mode:
        * disable all but error messages
        * disable the 'miscellaneous' checker which can be safely deactivated in
          debug
        * disable reports
        * do not save execution information
    --errors-onlyr   r   r   r   r   r   r   r   r   r   c                (    d| j         j        _        d S )NT)rO   rc   _error_moder    s        r"   r#   z_ErrorsOnlyModeAction.__call__-  s     '+###r%   N)r   r&   r1   r-   r%   r"   r   r   "  s<          %4+ + + + + + +r%   r   c                      e Zd ZdZ	 dddZdS )_LongHelpActionzDisplay the long help message.--long-helpr   r   r   r   r   r   r   r   r   r   c                   | j         j        j                                        }|                                | j         j        j        _        t          | j         j                                                   t          j	        d           d S ra   )
rO   rc   _arg_parser_get_formatterget_long_descriptionepilogry   rJ   rf   rg   )r!   r   r   r   r   	formatters         r"   r#   z_LongHelpAction.__call__:  sh     %)HO$?$N$N$P$P	 .7-K-K-M-M#*dho""$$%%%r%   N)r   r&   r1   r-   r%   r"   r   r   7  s8        (( %2      r%   r   c                  \     e Zd ZdZ	 	 	 	 	 	 	 	 d d! fdZej        	 d"d#d            Z xZS )$_AccessLinterObjectActionz,Action that has access to the Linter object.NFr?   r@   rA   r9   rB   rC   r   rD   rE   rF   rG   rH   rI   rJ   rK   rL   r   r   c                v    |d         | _         t                                          ||d||||||	|

  
         d S )Nrc      )rc   rP   rQ   rR   s               r"   rQ   z"_AccessLinterObjectAction.__init__M  U     X&	
 	
 	
 	
 	
r%   r   r   r   r   r   r   r   r   c                    t           r   r   r    s        r"   r#   z"_AccessLinterObjectAction.__call__j  r$   r%   rU   )r@   rA   r9   rB   rC   r   rD   r   rE   r   rF   r   rG   r   rH   rI   rJ   rB   rK   rB   rL   r   r   r   r   r&   rW   rY   s   @r"   r   r   J  s        66 
 
 
 
 
 
 
: 	 %)" " " " " " " " "r%   r   c                  @    e Zd ZdZdd
Zej        	 ddd            ZdS )_XableActionz4Callback action for enabling or disabling a message.xabling_functionCallable[[str], None]r   r   r   r   r   r   c                   t          |t          t          f          sJ t          j        |d                   D ]}	  ||           # t
          j        t
          j        f$ rJ}| j        j	        | j        j
        df                             |t          |          f           Y d }~od }~wt
          j        $ r6 | j        j	        | j        j
        df                             ||f           Y w xY wd S )Nr   zuseless-option-valuezunknown-option-value)r5   r6   r7   r   rb   r	   DeletedMessageErrorMessageBecameExtensionErrorrc   _stashed_messagescurrent_nameappendrB   UnknownMessageError)r!   r   r   r   msgides         r"   _callz_XableAction._callx  s    &5$-00000%fQi00 	1 	1E1  ''''.6 2 2 2 -[-/EF&-Q0111111111 1 1 1-[-/EF&-/000001	1 	1s   AC0#A B((AC0/C0	--disabler   r   r   r   c                    t           r   r   r    s        r"   r#   z_XableAction.__call__  r$   r%   N)r   r   r   r   r   r   r   r   r   r&   )r'   r(   r)   r*   r   r+   r,   r#   r-   r%   r"   r   r   u  s\        >>1 1 1 1, 	 %0" " " " " " "r%   r   c                      e Zd ZdZ	 dddZdS )_DisableActionz(Callback action for disabling a message.r   r   r   r   r   r   r   r   r   r   r   c                H    |                      | j        j        ||           d S r   )r   rc   disabler    s        r"   r#   z_DisableAction.__call__  s%     	

4;&>>>>>r%   Nr   r&   r1   r-   r%   r"   r   r     s8        22 %0? ? ? ? ? ? ?r%   r   c                      e Zd ZdZ	 dddZdS )_EnableActionz'Callback action for enabling a message.--enabler   r   r   r   r   r   r   r   r   r   c                H    |                      | j        j        ||           d S r   )r   rc   enabler    s        r"   r#   z_EnableAction.__call__  s%     	

4;%v}=====r%   Nr   r&   r1   r-   r%   r"   r   r     s8        11 %/> > > > > > >r%   r   c                      e Zd ZdZ	 dddZdS )_OutputFormatActionz.Callback action for setting the output format.r   r   r   r   r   r   r   r   r   r   r   c                    t          |t          t          f          sJ t          |d         t                    s
J d            | j                            |d                    d S )Nr   z?'output-format' should be a comma separated string of reporters)r5   r6   r7   rB   rc   _load_reportersr    s        r"   r#   z_OutputFormatAction.__call__  sw     &5$-000001Is
 
 	M 	ML	M 	M 	M 	##F1I.....r%   Nr   r&   r1   r-   r%   r"   r   r     s8        88 %// / / / / / /r%   r   c                  \     e Zd ZdZ	 	 	 	 	 	 	 	 dd  fdZej        	 d!d"d            Z xZS )#_AccessParserActionz4Action that has access to the ArgumentParser object.NFr?   r@   rA   r9   rB   rC   r   rD   rE   rF   rG   rH   rI   rJ   rK   rL   r   r   c                v    |d         | _         t                                          ||d||||||	|

  
         d S )Nr   r   )r   rP   rQ   rR   s               r"   rQ   z_AccessParserAction.__init__  r   r%   r   r   r   r   r   r   r   c                    t           r   r   r    s        r"   r#   z_AccessParserAction.__call__  r$   r%   rU   )r@   rA   r9   rB   rC   r   rD   r   rE   r   rF   r   rG   r   rH   rI   rJ   rB   rK   rB   rL   r   r   r   r   r&   rW   rY   s   @r"   r   r     s        >> 
 
 
 
 
 
 
: 	 %)" " " " " " " " "r%   r   )1r*   
__future__r   r+   argparserf   r   collections.abcr   r   pathlibr   typingr   r   pylintr	   r
   r   r   pylint.config.help_formatterr   pylint.lintr   pylint.lint.runr   Actionr   r/   _AppendActionr3   r>   r[   rk   rp   ru   r|   r   r   r   r   r   r   r   r   r   r   r   r   r-   r%   r"   <module>r      sx   , + " " " " " " 



  



  . . . . . . . .       % % % % % % % % < < < < < < < < < < < < $;;;;;;$$$$$$######" " " " "ho " " "       "/ / / / /H* / / /*(" (" (" (" ("_ (" (" ("V, , , , , , , ,^    0       !7       3       "8       2   "    5       2   $     6   + + + + +2 + + +*    ,   &(" (" (" (" (" (" (" ("V!" !" !" !" !", !" !" !"H
? 
? 
? 
? 
?\ 
? 
? 
?
> 
> 
> 
> 
>L 
> 
> 
>/ / / / /3 / / /"(" (" (" (" ("/ (" (" (" (" ("r%   