HXjUdZddlZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZejeZejddZeeeeeejedZeeeeeeffed<Gddej Z!ddddedede"de"deee eff dZ#GddZ$Gdd Z%dS)!z,Option handling and Option management logic.N)Any)Callable)Dict)List)Mapping)Optional)Sequence)Tuple)Type)Union)utils)Plugins_ARGNO)intlongstringfloatcomplexchoicestr_optparse_callable_mapc eZdZdZddddededefdeed eee efd ed df fd Z dd e j de j deeee e fdee d df dZxZS)_CallbackActionz)Shim for optparse-style callback actions.N) callback_argscallback_kwargsargscallback.rrkwargsreturnch||_||_|pi|_tj|i|dSN) _callback_callback_args_callback_kwargssuper__init__)selfrrrrr __class__s /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/flake8/options/manager.pyr(z_CallbackAction.__init__*sC"+ / 52$)&)))))parser namespacevalues option_stringc|sd}n7t|tr"t|dkrt|}|j||||g|jRi|jdS)N) isinstancelistlentupler$r%r&)r)r-r.r/r0s r+__call__z_CallbackAction.__call__7s #FF  % % ##f++//6]]F          #      r,r#)__name__ __module__ __qualname____doc__rrr rrrr(argparseArgumentParser Namespacer r7 __classcell__)r*s@r+rr's33 (*48 * * * *38$ * } * "$sCx.1 *  *  * * * * * *$(,   ' % x}c123   }           r,rFcomma_separated_listnormalize_pathsvaluerrArBr!c|}|r)t|trtj|}|r:t|trtj|g|R}ntj|g|R}|Sr#)r3rr parse_comma_separated_listnormalize_pathrB)rCrArBrrets r+_flake8_normalizerHLs "'C6 3 4 46.u554 c3   4&s2T222CC'3d333C Jr,c'eZdZdZejejejejejejejejejejejejejejejdddfdeeefdeeefdeeee j efdee efdeee de fefd eeefd ee eefd ee efd eee efd eeefdeeefdee de fefdeee efdeeee fefdeeefdedededdf&dZedeee ffdZdefdZde dede fdZdeeeeee fffdZdS)Optionz@Our wrapper around an argparse argument parsers to add features.Fshort_option_namelong_option_nameactiondefaulttype.destnargsconstchoiceshelpmetavarrrrrequiredparse_from_configrArBr!Nc|tjur1|tjur#|drtj|}}| tjur5d| vr1td|| dd} |dkr2td|t }|tjurd}t|tr(td|t|}|s|rtj t|| }||_ ||_d ||fD|_||_||_||_||_||_||_| |_| |_| |_||_| |_| |_||_|j|j|j|j|j|j|j|j|j|j|j|j|jd |_||_||_||_ d |_!|r@|tjurtEd |dd dd|_!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`). Deprecated: you can also pass through type strings such as ``'int'`` which are handled by :mod:`optparse`. :param action: Any action allowed by :mod:`argparse`. Deprecated: this also understands the ``action='callback'`` action from :mod:`optparse`. :param callback: Callback used if the action is ``"callback"``. Deprecated: please use ``action=`` instead. :param callback_args: Additional positional arguments to the callback callable. Deprecated: please use ``action=`` instead (probably with ``functools.partial``). :param callback_kwargs: Keyword arguments to the callback callable. Deprecated: please use ``action=`` instead (probably with ``functools.partial``). 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--z%defaultzuoption %s: please update `help=` text to use %%(default)s instead of %%default -- this will be an error in the futurez %(default)srz|option %s: please update from optparse `action='callback'` to argparse action classes -- this will be an error in the futurerzyoption %s: please update from optparse string `type=` to argparse callable `type=` -- this will be an error in the futurer@c.g|]}|tju|Srrr).0xs r+ z#Option.__init__..s/    r,) rMrNrOrPrQrRrSrrrrTrUrVNzRWhen specifying parse_from_config=True, a long_option_name must also be specified.-_)$rr startswithLOGwarningreplacerr3rr functoolspartialrHrKrL option_argsrMrNrOrPrQrRrSrrrrTrUrV option_kwargsrWrArB config_name ValueError_opt)r)rKrLrMrNrOrPrQrRrSrTrUrrrrVrWrArBs r+r(zOption.__init__bsn  ' '!00!,,T22137';L/  tw  :#5#5 KKN     << M::D Z   KK!     %Ftw dC  0 KK!     *$/D  ? $!%9 /D "3 0  ')9:             *.    k|IIZZ| !/#3I| ; ; ""3$8!.*.  F47** A 03;;CEED  r,cHd|jDS)z(Return any actually-specified arguments.c6i|]\}}|tju||SrrZ)r[kvs r+ z1Option.filtered_option_kwargs..s1   Q1DG;K;KAq;K;K;Kr,)rhitemsr)s r+filtered_option_kwargszOption.filtered_option_kwargss2  !/5577    r,cg}|jD]}|||jD]\}}||d| dd|dS)N=zOption(z, ))rgappendrsrqjoin)r)partsargrnros r+__repr__zOption.__repr__!s#  C LL    /5577 ' 'DAq LLA & & & &,5)),,,,r,rCnormalize_argsc|jr)t|trtj|}|jr:t|t rtj|g|R}ntj|g|R}|S)z6Normalize the value based on the option configuration.)rAr3rr rErBr4rF)r)rCr|s r+ normalizezOption.normalize)s  $ <E3)?)? <4U;;E   E%&& E-eEnEEE,UD^DDD r,c|j|jfS)z?Convert a Flake8 Option to argparse ``add_argument`` arguments.)rgrsrrs r+ to_argparsezOption.to_argparse6s!<<'$(G59W!%'+w"&'.2g!%$(G48G48G:>'&*g"'%* %/vv d+v T *v c40$67 v sDy! vC#s(+T12vCIvS#t^$vS$Yvx}d*+vCIvsDy!vc*D01v Xc]D01!v"wsCx0$67#v&d #'v* +v,#-v./v0 1vvvvp S#X   X -#---- s S S    =U49d38n#<=======r,rJceZdZdZdededeejddfdZde ddfd Z d e d e ddfd Z d e eddfdZd e eddfdZ dd ee edeejdejfdZdS) OptionManagerz=Manage Options and OptionParser while adding post-processing.versionplugin_versionsparentsr!Nc 2tjdd|d||_|jdd|d|dt j |jd d d i|_g|_g|_g|_ d|_ dS)aInitialize an instance of an OptionManager. :param prog: Name of the actual program (e.g., flake8). :param version: Version string for the program. :param usage: Basic usage string used by the OptionParser. :param parents: A list of ArgumentParser objects whose arguments should also be included. flake8z %(prog)s [options] file file ...zInstalled plugins: )progusagerepilogz --versionrz (z) )rMr filenames*filename)rQrUN) r<r=r- add_argumentr get_python_versionconfig_options_dictoptionsextended_default_ignoreextended_default_select_current_group)r)rrrs r+r(zOptionManager.__init__>s&-4:::       00o00+--00 !      C LLL68 %' 24$24$AEr,pluginsc:idtddffd }|D]j}t|jdd}|r ||jj||jjjdkr|j gkd_ dS)z(Register the plugin options (if needed).namer!Nc |_dS#t$r*j|}|x_|<YdSwxYwr#)rKeyErrorr-add_argument_group)rgroupgroupsr)s r+ _set_groupz2OptionManager.register_plugins.._set_groupmsa ;&,Tl### ; ; ; 66t<<5::#fTllll ;s 0AA add_optionszflake8.extension) r all_pluginsgetattrobjpluginpackage entry_pointrextend_default_select entry_namer)r)rrloadedrrs` @r+register_pluginszOptionManager.register_pluginsis57 ;S ;T ; ; ; ; ; ; ;))++ @ @F!&*mTBBK " 6=0111 D!!!}(.2DDD**F,=+>???#r,rr ct|i|}|\}}|j|jj|i|n|jj|i||j||jr3|j}|J||j |<||j | dd<t d|dS)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".) rJrrrr-rrwrWrirrdrbdebug)r)rr optionrgrhrs r+ add_optionzOptionManager.add_options(((%+%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%;%; < +V44444r, error_codescptd||j|dS)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)rbrrextendr)rs r+extend_default_ignorez#OptionManager.extend_default_ignore6 9;GGG $++K88888r,cptd||j|dS)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)rbrrrrs r+rz#OptionManager.extend_default_selectrr,r/cx|r|jjdit||j|S)z6Proxy to calling the OptionParser's parse_args method.r)r- set_defaultsvars parse_args)r)rr/s r+rzOptionManager.parse_argssC  5 $DK $ 4 4tF|| 4 4 4{%%d+++r,)NN)r8r9r:r;rrr<r=r(rrrrr rrrr>rrr,r+rr;sOGG(F(F (F h-. (F  (F(F(F(FV##D####.55s5t555529#9499999#949999)-/3,,x}%,+,,   ,,,,,,r,r)&r;r<enumreloggingtypingrrrrrrr r r r rr flake8.plugins.finderr getLoggerr8rbEnumrrrrrrr__annotations__rrrrHrJrrr,r+rs}222 ))))))g!!ty   g  = =S%S 4"889   " " " " " ho" " " P"'!      3S > &Y=Y=Y=Y=Y=Y=Y=Y=xz,z,z,z,z,z,z,z,z,z,r,