VL i-dZddlmZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl m Z ddlmZej eZej&d d Zd d d  dd ZGddZGddZy)z,Option handling and Option management logic.) annotationsN)Sequence)Any)Callable)utils)Plugins_ARGNOFcomma_separated_listnormalize_pathsc|}|r%t|trtj|}|r>t|trtj|g|}|Stj |g|}|SN) isinstancestrrparse_comma_separated_listnormalize_pathr )valuer r argsrets \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/flake8/options/manager.py_flake8_normalizersj !C 3 4..u5 c3 &&s2T2C J''3d3C JceZdZdZej ej ej ej ej ej ej ej ej ej ej ej dddf d dZed dZd dZ d dZ d dZ y)Optionz@Our wrapper around an argparse argument parsers to add features.Fc z|tjur5|tjur#|jdrtj|}}|s|rtjt ||}||_||_||fDcgc]}|tjur|c}|_||_ ||_ ||_ ||_ ||_ ||_| |_| |_| |_| |_|j|j|j|j|j|j|j|j |j"|j$d |_| |_||_||_d|_| r7|tjur t1d|ddj3dd|_d|_ycc}w) aInitialize 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 ) actiondefaulttypedestnargsconstchoiceshelpmetavarrequiredNzRWhen specifying parse_from_config=True, a long_option_name must also be specified.-_)r r startswith functoolspartialrshort_option_namelong_option_name option_argsrrrr r!r"r#r$r%r& option_kwargsparse_from_configr r config_name ValueErrorreplace_opt)selfr-r.rrrr r!r"r#r$r%r&r1r r xs r__init__zOption.__init__,sL  '!0!,,T226'';L/  ?$$!%9 /D "3 0()9:               kk||IIIIZZZZ||II||  5 "3$8!.'+ 477* A 03;;CED  U s<F8c|jjDcic]\}}|tjus||c}}Scc}}w)z(Return any actually-specified arguments.)r0itemsr r )r6kvs rfiltered_option_kwargszOption.filtered_option_kwargssC"//557 Q1DGG;KAqD   s AAcg}|jD]}|j||jjD]\}}|j|d|ddj |dS)N=zOption(z, ))r/appendr=r:join)r6partsargr;r<s r__repr__zOption.__repr__sy## C LL  //557 'DAq LLA3au & '5)*!,,rc|jr%t|trtj|}|j r>t|t rtj |g|}|Stj|g|}|S)z6Normalize the value based on the option configuration.)r rrrrr listr)r6rnormalize_argss r normalizezOption.normalizeso  $ $E3)?44U;E   %&--eEnE ,,UD^D rc2|j|jfS)z?Convert a Flake8 Option to argparse ``add_argument`` arguments.)r/r=)r6s r to_argparsezOption.to_argparses!BrcLidfd }|jD]}t|jdd}|r$||jj||jj j dk(sdj|jgd_ y)z(Register the plugin options (if needed).c |_y#t$r*jj|}|x_|<YywxYwr)rmKeyErrorrfadd_argument_group)namegroupgroupsr6s r _set_groupz2OptionManager.register_plugins.._set_groupsH ;&,Tl# ; 66t<5::#fTl ;s 0AA add_optionsNzflake8.extension)rsrrOrP) all_pluginsgetattrobjpluginpackage entry_pointrtextend_default_select entry_namerm)r6pluginsrvloadedrwrus` @rregister_pluginszOptionManager.register_pluginss57 ;))+ @F!&**mTBK6==001D!}}((..2DD**F,=,=+>? @#rct|i|}|j\}}|j|jj|i|n|jj|i||j j ||jr>|j}|J||j|<||j|jdd<tjd|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(zRegistered option "%s".) rrKrmrgrfrjrAr1r2rir4LOGdebug)r6rkwargsoptionr/r0rss r add_optionzOptionManager.add_option s((%+%7%7%9" ]    * ,D   , ,k K] K $DKK $ $k C] C F#  # #%%D# ##-3D $ $T *?ED $ $T\\#s%; < +V4rcftjd||jj|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)rrrkextendr6 error_codess rextend_default_ignorez#OptionManager.extend_default_ignore$' 9;G $$++K8rcftjd||jj|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)rrrlrrs rr~z#OptionManager.extend_default_select.rrNc|r%|jjdit||jj|S)z6Proxy to calling the OptionParser's parse_args method.rV)rf set_defaultsvars parse_args)r6rvaluess rrzOptionManager.parse_args8s7  $DKK $ $ 4tF| 4{{%%d++r) r_rrnrr]zlist[argparse.ArgumentParser]rcz list[str]rOrP)rrrOrP)rrrrrOrP)rz Sequence[str]rOrP)NN)rzSequence[str] | Nonerzargparse.Namespace | NonerOzargparse.Namespace) rQrRrSrTr8rrrr~rrVrrrXrXsGCC C / C # C CD#.5299&*,0,",*,  ,rrX) rrrrr rNr rNrOzstr | list[str])rT __future__rrdenumr+loggingcollections.abcrtypingrrrZrflake8.plugins.finderr getLoggerrQrEnumr rrrXrVrrrs2" $)g!tyy "'!      &c=c=Lq,q,r