
    yIf-                        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 ddlm	Z	 ddlm
Z
 ddlmZ ddlmZ  ej        e          Z ej        d	d
          ZdddddZ G d d          Z G d d          ZdS )z,Option handling and Option management logic.    )annotationsN)Any)Callable)Sequence)utils)Plugins_ARGNOFcomma_separated_listnormalize_pathsvaluestrargsr   boolr   returnstr | list[str]c                   | }|r)t          |t                    rt          j        |           }|r:t          |t                    rt          j        |g|R  }nt          j        |g|R  }|S N)
isinstancer   r   parse_comma_separated_listnormalize_pathr   )r   r   r   r   rets        J/var/www/piapp/venv/lib/python3.11/site-packages/flake8/options/manager.py_flake8_normalizer      s     !C 6
3 4 4 6.u55 4c3 	4&s2T222CC'3d333CJ    c                      e Zd ZdZej        ej        ej        ej        ej        ej        ej        ej        ej        ej        ej        ej        dddfd(dZed)d            Zd*d Z	d+d$Z
d,d&Zd'S )-Optionz@Our wrapper around an argparse argument parsers to add features.Fshort_option_name
str | _ARGlong_option_nameaction"str | type[argparse.Action] | _ARGdefault
Any | _ARGtypeCallable[..., Any] | _ARGdestnargsint | str | _ARGconstchoicesSequence[Any] | _ARGhelpmetavarrequiredbool | _ARGparse_from_configr   r   r   r   Nonec                   |t           j        u r1|t           j        ur#|                    d          rt           j        |}}|s|rt          j        t
          ||          }|| _        || _        d ||fD             | _        || _	        || _
        || _        || _        || _        || _        |	| _        |
| _        || _        || _        | j	        | j
        | j        | j        | j        | j        | j        | j        | j        | j        d
| _        || _        || _        || _        d| _        |r@|t           j        u rt1          d          |dd                             dd	          | _        d| _        dS )
a  Initialize an Option instance.

        The following are all passed directly through to argparse.

        :param short_option_name:
            The short name of the option (e.g., ``-x``). This will be the
            first argument passed to ``ArgumentParser.add_argument``
        :param long_option_name:
            The long name of the option (e.g., ``--xtra-long-option``). This
            will be the second argument passed to
            ``ArgumentParser.add_argument``
        :param default:
            Default value of the option.
        :param dest:
            Attribute name to store parsed option value as.
        :param nargs:
            Number of arguments to parse for this option.
        :param const:
            Constant value to store on a common destination. Usually used in
            conjunction with ``action="store_const"``.
        :param choices:
            Possible values for the option.
        :param help:
            Help text displayed in the usage information.
        :param metavar:
            Name to use instead of the long option name for help text.
        :param required:
            Whether this option is required or not.

        The following options may be passed directly through to :mod:`argparse`
        but may need some massaging.

        :param type:
            A callable to normalize the type (as is the case in
            :mod:`argparse`).
        :param action:
            Any action allowed by :mod:`argparse`.

        The following parameters are for Flake8's option handling alone.

        :param parse_from_config:
            Whether or not this option should be parsed out of config files.
        :param comma_separated_list:
            Whether the option is a comma separated list when parsing from a
            config file.
        :param normalize_paths:
            Whether the option is expecting a path or list of paths and should
            attempt to normalize the paths to absolute paths.
        z--r   c                .    g | ]}|t           j        u|S  r	   r
   ).0xs     r   
<listcomp>z#Option.__init__.<locals>.<listcomp>   s/     
 
 
 r   )
r"   r$   r&   r(   r)   r+   r,   r.   r/   r0   NzRWhen specifying parse_from_config=True, a long_option_name must also be specified.   -_)r	   r
   
startswith	functoolspartialr   r   r!   option_argsr"   r$   r&   r(   r)   r+   r,   r.   r/   r0   option_kwargsr2   r   r   config_name
ValueErrorreplace_opt)selfr   r!   r"   r$   r&   r(   r)   r+   r,   r.   r/   r0   r2   r   r   s                   r   __init__zOption.__init__,   s   L ''!00!,,T22 1 37';L/   	? 	$!%9 /  D "3 0
 
')9:
 
 

 		

	 k|IIZZ|I|5
 5
 "3$8!.'+ 	F47** A    03;;CEED			r   dict[str, Any]c                H    d | j                                         D             S )z(Return any actually-specified arguments.c                6    i | ]\  }}|t           j        u||S r6   r7   )r8   kvs      r   
<dictcomp>z1Option.filtered_option_kwargs.<locals>.<dictcomp>   s1     
 
 
Q1DG;K;KAq;K;K;Kr   )rB   itemsrG   s    r   filtered_option_kwargszOption.filtered_option_kwargs   s2    
 
!/5577
 
 
 	
r   r   c                    g }| j         D ]}|                    |           | j                                        D ]\  }}|                    | d|            dd                    |           dS )N=zOption(z, ))rA   appendrQ   rO   join)rG   partsargrL   rM   s        r   __repr__zOption.__repr__   s    # 	 	CLL/5577 	' 	'DAqLLA&&&&,5)),,,,r   r   r   normalize_argsc                    | j         r)t          |t                    rt          j        |          }| j        r:t          |t                    rt          j        |g|R  }nt          j        |g|R  }|S )z6Normalize the value based on the option configuration.)r   r   r   r   r   r   listr   )rG   r   rZ   s      r   	normalizezOption.normalize   s    $ 	<E3)?)? 	<4U;;E 	E%&& E-eEnEEE,UD^DDDr    tuple[list[str], dict[str, Any]]c                    | j         | j        fS )z?Convert a Flake8 Option to argparse ``add_argument`` arguments.)rA   rQ   rP   s    r   to_argparsezOption.to_argparse   s    !<<<r   N) r   r    r!   r    r"   r#   r$   r%   r&   r'   r(   r    r)   r*   r+   r%   r,   r-   r.   r    r/   r    r0   r1   r2   r   r   r   r   r   r   r3   )r   rI   )r   r   )r   r   rZ   r   r   r   )r   r^   )__name__
__module____qualname____doc__r	   r
   rH   propertyrQ   rY   r]   r`   r6   r   r   r   r   )   s        JJ )-'+w59W"g*.'7"&' G(,7"g $"'%* %%@ @ @ @ @D 
 
 
 X
- - - -   = = = = = =r   r   c                  H    e Zd ZdZddZddZddZd dZd dZ	 	 d!d"dZ	dS )#OptionManagerz=Manage Options and OptionParser while adding post-processing.versionr   plugin_versionsparentslist[argparse.ArgumentParser]formatter_names	list[str]r   r3   c          
     @   || _         t          j        dd|d|           | _        | j                            dd| d| dt          j                     	           | j                            d
dd           i | _        g | _        g | _	        g | _
        d| _        dS )z+Initialize an instance of an OptionManager.flake8z %(prog)s [options] file file ...zInstalled plugins: )progusagerj   epilogz	--versionrh   z (z) )r"   rh   	filenames*filename)r)   r/   N)rl   argparseArgumentParserparseradd_argumentr   get_python_versionconfig_options_dictoptionsextended_default_ignoreextended_default_select_current_group)rG   rh   ri   rj   rl   s        r   rH   zOptionManager.__init__   s      /-4:::	
 
 
 	   0 0o 0 0+--0 0	 	! 	
 	
 	
 	  C LLL68 %'24$24$>Br   pluginsr   c                (    i d	 fd}|                                 D ]j}t          |j        dd          }|r  ||j        j                    |            |j        j        j        dk    r                     |j        g           kd _	        dS )
z(Register the plugin options (if needed).namer   r   r3   c                    	 |          _         d S # t          $ r* j                            |           }|x_         | <   Y d S w xY wr   )r   KeyErrorrx   add_argument_group)r   groupgroupsrG   s     r   
_set_groupz2OptionManager.register_plugins.<locals>._set_group   sa    ;&,Tl### ; ; ;66t<<5::#fTllll;s    0AAadd_optionsNzflake8.extension)r   r   r   r3   )
all_pluginsgetattrobjpluginpackageentry_pointr   extend_default_select
entry_namer   )rG   r   r   loadedr   r   s   `    @r   register_pluginszOptionManager.register_plugins   s    57	; 	; 	; 	; 	; 	; 	; ))++ 	@ 	@F!&*mTBBK "
6=0111D!!!}(.2DDD**F,=+>??? #r   r   r   kwargsc                   t          |i |}|                                \  }}| j         | j        j        |i | n | j        j        |i | | j                            |           |j        r3|j        }|J || j	        |<   || j	        |
                    dd          <   t                              d|           dS )a<  Create and register a new option.

        See parameters for :class:`~flake8.options.manager.Option` for
        acceptable arguments to this method.

        .. note::

            ``short_option_name`` and ``long_option_name`` may be specified
            positionally as they are with argparse normally.
        Nr=   r<   zRegistered option "%s".)r   r`   r   ry   rx   r|   rU   r2   rC   r{   rE   LOGdebug)rG   r   r   optionrA   rB   r   s          r   
add_optionzOptionManager.add_option  s     (((%+%7%7%9%9"]*,D,kK]KKKK$DK$kC]CCCF#### 	F%D###-3D$T*?ED$T\\#s%;%;<		+V44444r   error_codesSequence[str]c                p    t                               d|           | j                            |           dS )zExtend the default ignore list with the error codes provided.

        :param error_codes:
            List of strings that are the error/warning codes with which to
            extend the default ignore list.
        z%Extending default ignore list with %rN)r   r   r}   extendrG   r   s     r   extend_default_ignorez#OptionManager.extend_default_ignore$  6     			9;GGG$++K88888r   c                p    t                               d|           | j                            |           dS )zExtend the default select list with the error codes provided.

        :param error_codes:
            List of strings that are the error/warning codes with which
            to extend the default select list.
        z%Extending default select list with %rN)r   r   r~   r   r   s     r   r   z#OptionManager.extend_default_select.  r   r   NSequence[str] | Nonevaluesargparse.Namespace | Noneargparse.Namespacec                x    |r | j         j        di t          |           | j                             |          S )z6Proxy to calling the OptionParser's parse_args method.r6   )rx   set_defaultsvars
parse_args)rG   r   r   s      r   r   zOptionManager.parse_args8  sC      	5$DK$44tF||444{%%d+++r   )
rh   r   ri   r   rj   rk   rl   rm   r   r3   )r   r   r   r3   )r   r   r   r   r   r3   )r   r   r   r3   )NN)r   r   r   r   r   r   )
ra   rb   rc   rd   rH   r   r   r   r   r   r6   r   r   rg   rg      s        GGC C C CD# # # #.5 5 5 529 9 9 99 9 9 9 &*,0, , , , , , ,r   rg   )
r   r   r   r   r   r   r   r   r   r   )rd   
__future__r   rv   enumr?   loggingtypingr   r   r   ro   r   flake8.plugins.finderr   	getLoggerra   r   Enumr	   r   r   rg   r6   r   r   <module>r      sX   2 2 " " " " " "                                ) ) ) ) ) )g!! ty "'!	     &c= c= c= c= c= c= c= c=Lq, q, q, q, q, q, q, q, q, q,r   