
    g-                       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y)z,Option handling and Option management logic.    )annotationsN)Any)Callable)Sequence)utils)Plugins_ARGNOFcomma_separated_listnormalize_pathsc                   | }|r%t        |t              rt        j                  |       }|r>t        |t              rt        j                  |g| }|S t        j
                  |g| }|S N)
isinstancestrr   parse_comma_separated_listnormalize_pathr   )valuer   r   argsrets        Y/var/www/html/brdwt/brdwt/brdwtenv/lib/python3.12/site-packages/flake8/options/manager.py_flake8_normalizer      sj     !C
3 4..u5c3&&s2T2C J ''3d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y)Optionz@Our wrapper around an argparse argument parsers to add features.Fc                z   |t         j                  u r5|t         j                  ur#|j                  d      rt         j                  |}}|s|rt        j                  t
        ||      }|| _        || _        ||fD cg c]  }|t         j                  ur| c}| _        || _	        || _
        || _        || _        || _        || _        |	| _        |
| _        || _        || _        | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                   | j"                  | j$                  d
| _        || _        || _        || _        d| _        |r7|t         j                  u rt1        d      |dd j3                  dd      | _        d| _        yc c}w )	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   )
actiondefaulttypedestnargsconstchoiceshelpmetavarrequiredNzRWhen specifying parse_from_config=True, a long_option_name must also be specified.   -_)r	   r
   
startswith	functoolspartialr   short_option_namelong_option_nameoption_argsr   r   r   r    r!   r"   r#   r$   r%   r&   option_kwargsparse_from_configr   r   config_name
ValueErrorreplace_opt)selfr-   r.   r   r   r   r    r!   r"   r#   r$   r%   r&   r1   r   r   xs                    r   __init__zOption.__init__,   s   L '!0!,,T226'';L/  ?$$!%9 /D "3 0 ()9:
 

 		

	 kk||IIIIZZZZ||II||5
 "3$8!.'+477* A   03;;CED	U
s   <F8c                    | j                   j                         D ci c]  \  }}|t        j                  us|| c}}S c c}}w )z(Return any actually-specified arguments.)r0   itemsr	   r
   )r6   kvs      r   filtered_option_kwargszOption.filtered_option_kwargs   sC     "//557
Q1DGG;KAqD
 	
 
s
   AAc                    g }| j                   D ]  }|j                  |        | j                  j                         D ]  \  }}|j                  | d|        ddj	                  |       dS )N=zOption(z, ))r/   appendr=   r:   join)r6   partsargr;   r<   s        r   __repr__zOption.__repr__   sy    ## 	CLL	//557 	'DAqLLA3au&	'5)*!,,r   c                    | j                   r%t        |t              rt        j                  |      }| j
                  r>t        |t              rt        j
                  |g| }|S t        j                  |g| }|S )z6Normalize the value based on the option configuration.)r   r   r   r   r   r   listr   )r6   r   normalize_argss      r   	normalizezOption.normalize   so    $$E3)?44U;E%&--eEnE  ,,UD^Dr   c                2    | j                   | j                  fS )z?Convert a Flake8 Option to argparse ``add_argument`` arguments.)r/   r=   )r6   s    r   to_argparsezOption.to_argparse   s    !<!<<<r   N) r-   
str | _ARGr.   rL   r   z"str | type[argparse.Action] | _ARGr   
Any | _ARGr   zCallable[..., Any] | _ARGr    rL   r!   zint | str | _ARGr"   rM   r#   zSequence[Any] | _ARGr$   rL   r%   rL   r&   zbool | _ARGr1   boolr   rN   r   rN   returnNone)rO   zdict[str, Any])rO   r   )r   r   rH   r   rO   r   )rO   z tuple[list[str], dict[str, Any]])__name__
__module____qualname____doc__r	   r
   r8   propertyr=   rE   rI   rK    r   r   r   r   )   s<   J )-'+ww59WW"gg*.''77"&'' GG(,77"gg $"'%* %%@%@ %@
 3@ @ (@ @  @ @ &@ @ @ @   !@" ##@$ %@& 
'@D 
 
-=r   r   c                  d    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	y)OptionManagerz=Manage Options and OptionParser while adding post-processing.c          
     F   || _         t        j                  dd|d|       | _        | j                  j	                  dd| d| dt        j                          	       | j                  j	                  d
dd       i | _        g | _        g | _	        g | _
        d| _        y)z+Initialize an instance of an OptionManager.flake8z %(prog)s [options] file file ...zInstalled plugins: )progusageparentsepilogz	--versionversionz (z) )r   r_   	filenames*filename)r!   r%   N)formatter_namesargparseArgumentParserparseradd_argumentr   get_python_versionconfig_options_dictoptionsextended_default_ignoreextended_default_select_current_group)r6   r_   plugin_versionsr]   rc   s        r   r8   zOptionManager.__init__   s      /--4((9:	
 	  )2o.b++-.0	 	! 	
 	  C L68 %'24$24$>Br   c                L    i d fd}|j                         D ]  }t        |j                  dd      }|r$ ||j                  j                          |        |j                  j
                  j                  dk(  sd j                  |j                  g        d _	        y)z(Register the plugin options (if needed).c                    	 |    _         y # t        $ r* j                  j                  |       }|x_         | <   Y y w xY wr   )rm   KeyErrorrf   add_argument_group)namegroupgroupsr6   s     r   
_set_groupz2OptionManager.register_plugins.<locals>._set_group   sH    ;&,Tl# ;66t<5::#fTl;s   
 0A Aadd_optionsNzflake8.extension)rs   r   rO   rP   )
all_pluginsgetattrobjpluginpackageentry_pointrt   extend_default_select
entry_namerm   )r6   pluginsrv   loadedrw   ru   s   `    @r   register_pluginszOptionManager.register_plugins   s    57	; ))+ 	@F!&**mTBK6==001D!}}((..2DD**F,=,=+>?	@ #r   c                   t        |i |}|j                         \  }}| j                   | j                  j                  |i | n | j                  j                  |i | | j
                  j                  |       |j                  r>|j                  }|J || j                  |<   || j                  |j                  dd      <   t        j                  d|       y)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   rK   rm   rg   rf   rj   rA   r1   r2   ri   r4   LOGdebug)r6   r   kwargsoptionr/   r0   rs   s          r   
add_optionzOptionManager.add_option  s     ((%+%7%7%9"]*,D,,kK]K$DKK$$kC]CF###%%D###-3D$$T*?ED$$T\\#s%;<		+V4r   c                f    t         j                  d|       | j                  j                  |       y)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   rk   extendr6   error_codess     r   extend_default_ignorez#OptionManager.extend_default_ignore$  '     			9;G$$++K8r   c                f    t         j                  d|       | j                  j                  |       y)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   rl   r   r   s     r   r~   z#OptionManager.extend_default_select.  r   r   Nc                    |r% | j                   j                  di t        |       | j                   j                  |      S )z6Proxy to calling the OptionParser's parse_args method.rV   )rf   set_defaultsvars
parse_args)r6   r   valuess      r   r   zOptionManager.parse_args8  s7     $DKK$$4tF|4{{%%d++r   )
r_   r   rn   r   r]   zlist[argparse.ArgumentParser]rc   z	list[str]rO   rP   )r   r   rO   rP   )r   r   r   r   rO   rP   )r   zSequence[str]rO   rP   )NN)r   zSequence[str] | Noner   zargparse.Namespace | NonerO   zargparse.Namespace)
rQ   rR   rS   rT   r8   r   r   r   r~   r   rV   r   r   rX   rX      s    GC C 	C
 /C #C 
CD#.5299 &*,0,", *, 
	,r   rX   )
r   r   r   r   r   rN   r   rN   rO   zstr | list[str])rT   
__future__r   rd   enumr+   loggingtypingr   r   r   rZ   r   flake8.plugins.finderr   	getLoggerrQ   r   Enumr	   r   r   rX   rV   r   r   <module>r      s    2 "         )g! tyy "'!	  	
 &c= c=Lq, q,r   