
    eO4                    d   d Z ddlm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j2                        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+ d,e)      Z* G d- d.e)      Z+ G d/ d0e(      Z, G d1 d2e      Z-y)3z%Callback actions for various options.    )annotationsN)CallableSequence)Path)TYPE_CHECKINGAny)
exceptions
extensions
interfacesutils)_HelpFormatter)PyLinter)Runc                  L    e Zd ZdZej
                  	 d	 	 	 	 	 	 	 	 	 dd       Zy)_CallbackActionzCustom callback action.Nc                    t         NNotImplementedErrorselfparser	namespacevaluesoption_strings        @/usr/lib/python3/dist-packages/pylint/config/callback_actions.py__call__z_CallbackAction.__call__   
     "!    r   
r   argparse.ArgumentParserr   argparse.Namespacer   str | Sequence[Any] | Noner   
str | NonereturnNone)__name__
__module____qualname____doc__abcabstractmethodr    r   r   r   r      sR    ! %)"'" &" +	"
 "" 
" "r   r   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_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.
    Nc                     y r   r-   r   s        r   r   z_DoNothingAction.__call__/   s     r   r   r    r'   r(   r)   r*   r   r-   r   r   r/   r/   (   sA     %)' & +	
 " 
r   r/   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.c                J    |d   | _         t        | 	  ||d||||||	|

       y )Nr   r   runsuper__init__r   option_stringsdestnargsconstdefaulttypechoicesrequiredhelpmetavarkwargs	__class__s               r   r8   z_AccessRunObjectAction.__init__<   s;     %=	
r   c                    t         r   r   r   s        r   r   z_AccessRunObjectAction.__call__Y   r   r   NNNNNF rH   r:   Sequence[str]r;   strr<   r&   r=   r&   r>   r&   r?   r&   r@   r&   rA   boolrB   rK   rC   rK   rD   r   r%   r&   r   r    	r'   r(   r)   r*   r8   r+   r,   r   __classcell__rE   s   @r   r3   r3   9   s    3 
%
 
 	

 
 
 
 
 
 
 
 
 

: 	 %)"'" &" +	"
 "" 
" "r   r3   c                       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.c                J    |d   | _         t        | 	  ||d||||||	|

       y )Nr   +r5   r9   s               r   r8   z_MessageHelpAction.__init__g   s;     %=	
r   c                "   t        |t        t        f      sJ g }|D ],  }t        |t              sJ |t	        j
                  |      z  }. | j                  j                  j                  j                  |       t        j                  d       y Nr   )
isinstancelisttuplerK   r   
_check_csvr6   linter
msgs_storehelp_messagesysexit)r   r   r   r   r   values_to_printmsgs          r   r   z_MessageHelpAction.__call__   sz     &4-000%' 	5Cc3'''u//44O	5 	""//@r   rG   rI   )z
--help-msg)
r   r!   r   r"   r   zstr | Sequence[str] | Noner   r$   r%   r&   )r'   r(   r)   r*   r8   r   rN   rO   s   @r   rQ   rQ   d   s    0 
%
 
 	

 
 
 
 
 
 
 
 
 

B %1' & +	
 " 
r   rQ   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_ListMessagesActionzDisplay all available messages.c                    | j                   j                  j                  j                          t	        j
                  d       y rU   )r6   rZ   r[   list_messagesr]   r^   r   s        r   r   z_ListMessagesAction.__call__   s)     	""002r   N)z--list-enabledr    r1   r-   r   r   rb   rb      s?    ) %5' & +	
 " 
r   rb   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_ListMessagesEnabledActionzDisplay all enabled messages.c                v    | j                   j                  j                          t        j                  d       y rU   )r6   rZ   list_messages_enabledr]   r^   r   s        r   r   z#_ListMessagesEnabledAction.__call__   s#     	--/r   N)z--list-msgs-enabledr    r1   r-   r   r   rf   rf      s?    ' %:' & +	
 " 
r   rf   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_ListCheckGroupsActionz5Display all the check groups that pylint knows about.c                    | j                   j                  j                         D ]  }t        |        t	        j
                  d       y rU   )r6   rZ   get_checker_namesprintr]   r^   )r   r   r   r   r   checks         r   r   z_ListCheckGroupsAction.__call__   s6     XX__668 	E%L	r   N)z--list-groupsr    r1   r-   r   r   rj   rj      s?    ? %4	'	 &	 +		
 "	 
	r   rj   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_ListConfidenceLevelsActionz:Display all the confidence levels that pylint knows about.c                t    t         j                  D ]  }t        d|         t        j                  d       y )Nz%-18s: r   )r   CONFIDENCE_LEVELSrm   r]   r^   )r   r   r   r   r   levels         r   r   z$_ListConfidenceLevelsAction.__call__   s3      11 	%EGE7#$	%r   N)z--list-conf-levelsr    r1   r-   r   r   rp   rp      s?    D %9	'	 &	 +		
 "	 
	r   rp   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_ListExtensionsActionz/Display all extensions under pylint.extensions.c                L   t        t        j                        j                  j	                         D ][  }|j
                  dk(  s|j                  j                  d      r/|j                  j                  d      \  }}}t        d|        ] t        j                  d       y )Nz.py_.zpylint.extensions.r   )r   r
   __file__parentiterdirsuffixstem
startswith	partitionrm   r]   r^   )r   r   r   r   r   filenameextension_namerw   s           r   r   z_ListExtensionsAction.__call__   s     Z00188@@B 	=H%'0H0H0M'/}}'>'>s'C$1*>*:;<	= 	r   N)z--list-extensionsr    r1   r-   r   r   ru   ru      s?    9 %8' & +	
 " 
r   ru   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_FullDocumentationActionzDisplay the full documentation.c                    t        j                  | j                  j                         t	        j
                  d       y rU   )r   print_full_documentationr6   rZ   r]   r^   r   s        r   r   z!_FullDocumentationAction.__call__   s%     	&&txx7r   N)z--full-documentationr    r1   r-   r   r   r   r      s?    ) %;' & +	
 " 
r   r   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_GenerateRCFileActionzGenerate a pylintrc file.c                z    | j                   j                  j                  d       t        j                  d       y )N)Commands)skipsectionsr   )r6   rZ   _generate_configr]   r^   r   s        r   r   z_GenerateRCFileAction.__call__   s(     	((m(Dr   N)z--generate-rcfiler    r1   r-   r   r   r   r      s?    # %8
'
 &
 +	

 "
 

r   r   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_GenerateConfigFileActionz+Generate a .toml format configuration file.c                    t        | j                  j                  j                                t	        j
                  d       y rU   )rm   r6   rZ   _generate_config_filer]   r^   r   s        r   r   z"_GenerateConfigFileAction.__call__   s(     	dhhoo3356r   N)z--generate-toml-configr    r1   r-   r   r   r   r      s?    5 %=' & +	
 " 
r   r   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_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
    c                :    d| j                   j                  _        y )NT)r6   rZ   _error_moder   s        r   r   z_ErrorsOnlyModeAction.__call__  s     '+#r   N)z--errors-onlyr    r1   r-   r   r   r   r   
  sA     %4+'+ &+ +	+
 "+ 
+r   r   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_LongHelpActionzDisplay the long help message.c                J   | j                   j                  j                  j                         }|j	                         | j                   j                  j                  _        t        | j                   j                  j                                t        j                  d       y rU   )
r6   rZ   _arg_parser_get_formatterget_long_descriptionepilogrm   rB   r]   r^   )r   r   r   r   r   	formatters         r   r   z_LongHelpAction.__call__"  se     %)HHOO$?$?$N$N$P	 .7-K-K-M##*dhhoo""$%r   N)z--long-helpr    r1   r-   r   r   r   r     s?    ( %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.c                J    |d   | _         t        | 	  ||d||||||	|

       y )NrZ      )rZ   r7   r8   r9   s               r   r8   z"_AccessLinterObjectAction.__init__5  <     X&	
r   c                    t         r   r   r   s        r   r   z"_AccessLinterObjectAction.__call__R  r   r   rG   )r:   rJ   r;   rK   r<   r&   r=   r&   r>   r&   r?   r&   r@   r&   rA   rL   rB   rK   rC   rK   rD   r   r%   r&   r   r    rM   rO   s   @r   r   r   2  s    6 
%
 
 	

 
 
 
 
 
 
 
 
 

: 	 %)"'" &" +	"
 "" 
" "r   r   c                  d    e Zd ZdZ	 	 	 	 	 	 	 	 ddZej                  	 d	 	 	 	 	 	 	 	 	 dd       Zy)_XableActionz4Callback action for enabling or disabling a message.c                   t        |t        t        f      sJ t        j                  |d         D ]  }	  ||        y # t
        j                  t
        j                  f$ rS}| j                  j                  | j                  j                  df   j                  |t        |      f       Y d }~d }~wt
        j                  $ rC | j                  j                  | j                  j                  df   j                  ||f       Y w xY w)Nr   zuseless-option-valuezunknown-option-value)rV   rX   rW   r   rY   r	   DeletedMessageErrorMessageBecameExtensionErrorrZ   _stashed_messagescurrent_nameappendrK   UnknownMessageError)r   xabling_functionr   r   msgides         r   _callz_XableAction._call`  s     &5$-000%%fQi0 	1E1 '	1 ..66 2 --[[--/EF&-Q01111 1--[[--/EF&-/01s   A  #D
#A	B11AD
	D
c                    t         r   r   r   s        r   r   z_XableAction.__call__v  r   r   N)r   zCallable[[str], None]r   r#   r   r$   r%   r&   z	--disabler    )r'   r(   r)   r*   r   r+   r,   r   r-   r   r   r   r   ]  s    >1/1 +1 "	1
 
1, 	 %0"'" &" +	"
 "" 
" "r   r   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_DisableActionz(Callback action for disabling a message.c                R    | j                  | j                  j                  ||       y r   )r   rZ   disabler   s        r   r   z_DisableAction.__call__  s     	

4;;&&>r   Nr   r    r1   r-   r   r   r   r     s?    2 %0?'? &? +	?
 "? 
?r   r   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_EnableActionz'Callback action for enabling a message.c                R    | j                  | j                  j                  ||       y r   )r   rZ   enabler   s        r   r   z_EnableAction.__call__  s     	

4;;%%v}=r   Nz--enabler    r1   r-   r   r   r   r     s?    1 %/>'> &> +	>
 "> 
>r   r   c                  .    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZy)_OutputFormatActionz.Callback action for setting the output format.c                    t        |t        t        f      sJ t        |d   t              sJ d       | j                  j                  |d          y )Nr   z?'output-format' should be a comma separated string of reporters)rV   rX   rW   rK   rZ   _load_reportersr   s        r   r   z_OutputFormatAction.__call__  sU     &5$-0001Is
 	ML	M 
 	##F1I.r   Nr   r    r1   r-   r   r   r   r     s?    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.c                J    |d   | _         t        | 	  ||d||||||	|

       y )Nr   r   )r   r7   r8   r9   s               r   r8   z_AccessParserAction.__init__  r   r   c                    t         r   r   r   s        r   r   z_AccessParserAction.__call__  r   r   rG   )r:   rJ   r;   rK   r<   r&   r=   r&   r>   r&   r?   r&   r@   r&   rA   rL   rB   rK   rC   rK   rD   r!   r%   r&   r   r    rM   rO   s   @r   r   r     s    > 
%
 
 	

 
 
 
 
 
 
 
 *
 

: 	 %)"'" &" +	"
 "" 
" "r   r   ).r*   
__future__r   r+   argparser]   collections.abcr   r   pathlibr   typingr   r   pylintr	   r
   r   r   pylint.config.help_formatterr   pylint.lintr   pylint.lint.runr   Actionr   r/   r3   rQ   rb   rf   rj   rp   ru   r   r   r   r   r   r   r   r   r   r   r   r-   r   r   <module>r      s5   , " 
  
 .  % < <;$#"hoo " "("_ ("V, ,^0 !7 3 "8 2 "5 2   6 +2 +*, &(" ("V!", !"H
?\ 
?
>L 
>/3 /"("/ ("r   