j7iOddlmZddlZddlmZddlmZddlmZddlZddlZddl m Z ddl m Z ddl m Z dd l m Z d d lmZddlZdd lmZd ZGddZeZe GddZ ddZGddeZGddZGddZGddej:ZGddej>Z GddejBZ"y) ) annotationsN)Callable)Mapping)Sequence)Any)final)Literal)NoReturn) UsageError)check_ispytest file_or_dirceZdZddZy)NotSetcy)Nzselfs b/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/_pytest/config/argparsing.py__repr__zNotSet.__repr__sNreturnstr)__name__ __module__ __qualname__rrrrrrsrrceZdZdZ ddd ddZeddZejddZddZ d dd Z dd Z d dd Z d dd Z d dd Z defdd ddZy)ParserzParser for command line arguments and config-file values. :ivar extra_info: Dict of generic param -> value to display in case there's an error processing the command line arguments. NF _ispytestcht|ddlm}||_i|_t |||j|_|j jd}t|d|d|_ |jg|_ |j jtd}||_ i|_i|_y) Nr)filescompleterzCustom options _anonymousTr *)nargs)r _pytest._argcompleter# _processopt extra_infoPytestArgumentParser optparseradd_argument_group OptionGroupr$_groups add_argument FILE_OR_DIR completer_inidict _ini_aliases)rusage processoptr!r#anonymous_arggroupfile_or_dir_args r__init__zParser.__init__'s y!7%*,-dE4??K!^^>>?OP%  dd ( ..55k5M$2!9; ,.rc.|jjSNr+progrs rr<z Parser.progAs~~"""rc&||j_yr:r;)rvalues rr<z Parser.progEs#rcZ|jr|jr|j|yyyr:)r(dest)roptions r processoptionzParser.processoptionIs*   {{  ( rc|jD]}|j|k(s|cS|jj|xs|}t |||d}d}t |jD]\}}|j|k(sn|jj |dz||jjj |dz|jjj|S)aGet (or create) a named option Group. :param name: Name of the option group. :param description: Long description for --help output. :param after: Name of another group, used for ordering --help output. :returns: The option group. The returned group object has an ``addoption`` method with the same signature as :func:`parser.addoption ` but will be shown in the respective group in the output of ``pytest --help``. Tr rr ) r.namer+r,r- enumerateinsert_action_groupspop)rrD descriptionaftergrouparggroupigrps rgetgroupzParser.getgroupNs\\ EzzT!  >>44[5HDIHdDDA  - FAsxx5   AE5) %%,,QUDNN4Q4Q4U4U4WX rc<|jj|i|y)aRegister a command line option. :param opts: Option names, can be short or long options. :param attrs: Same attributes as the argparse library's :meth:`add_argument() ` function accepts. After command line parsing, options are available on the pytest config object via ``config.option.NAME`` where ``NAME`` is usually set by passing a ``dest`` attribute, for example ``addoption("--long", dest="NAME", ...)``. N)r$ addoption)roptsattrss rrQzParser.addoptionms "!!4151rcddlm}||j|Dcgc]}tj|}}|t j } d|_|jj|||`Scc}w#|`wxYw)zParse the arguments. Unlike ``parse_known_args`` and ``parse_known_and_unknown_args``, raises PrintHelp on `--help` and UsageError on unknown flags :meta private: r)try_argcompleteT namespace) r'rUr+osfspathargparse Namespace_raise_print_helpparse_intermixed_args)rargsrWrUxstrargss rparsez Parser.parse}s{ 9')-.A299Q<..   **,I ,*.I '>>7797U+/+sA8#A==Bc.|j||dS)zbParse the known arguments at this point. :returns: An argparse namespace object. rVr)parse_known_and_unknown_args)rr^rWs rparse_known_argszParser.parse_known_argss000KANNrc|Dcgc]}tj|}}tjdksdtjcxkrdkrgnnd|jj ||\}}|Jt |t}g}|D]&}|jdr|n|j|(||fS|jj||Scc}w)a Parse the known arguments at this point, and also return the remaining unknown flag arguments. :returns: A tuple containing an argparse namespace object for the known arguments, and a list of unknown flag arguments. ) )rf )rfrir -) rXrYsys version_infor+rdgetattrr0 startswithappendparse_known_intermixed_args) rr^rWr_r`unknownr unknown_flagsargs rrcz#Parser.parse_known_and_unknown_argss*..A299Q<..   j (Gs7G7G,T*,T!%!@!@)!T Iw( ((!)[9K')M T"%.."5;NNsS Tm+ +>>==gyQ Q/sCr)aliasesc"|dvsJ|d}|tur t|}|||f|j|<|D][}||jvrtd|d|jj |x}t|d|||j|<]y)aRegister a configuration file option. :param name: Name of the configuration. :param type: Type of the configuration. Can be: * ``string``: a string * ``bool``: a boolean * ``args``: a list of strings, separated as in a shell * ``linelist``: a list of strings, separated by line breaks * ``paths``: a list of :class:`pathlib.Path`, separated as in a shell * ``pathlist``: a list of ``py.path``, separated as in a shell * ``int``: an integer * ``float``: a floating-point number .. versionadded:: 8.4 The ``float`` and ``int`` types. For ``paths`` and ``pathlist`` types, they are considered relative to the config-file. In case the execution is happening without a config-file defined, they will be considered relative to the current working directory (for example with ``--override-ini``). .. versionadded:: 7.0 The ``paths`` variable type. .. versionadded:: 8.1 Use the current working directory to resolve ``paths`` and ``pathlist`` in the absence of a config-file. Defaults to ``string`` if ``None`` or not passed. :param default: Default value if no config-file option exists but is queried. :param aliases: Additional names by which this option can be referenced. Aliases resolve to the canonical name. .. versionadded:: 9.0 The ``aliases`` parameter. The value of configuration keys can be retrieved via a call to :py:func:`config.getini(name) `. ) Nstringpathspathlistr^linelistboolintfloatNrvzalias z- conflicts with existing configuration optionz is already an alias of )NOT_SETget_ini_default_for_typer2 ValueErrorr3get)rrDhelptypedefaultrtaliasalreadys raddiniz Parser.addinisn     <D g .t4G#T73 d ,E % UI%RS ,,0077D E9,DWK!PQQ'+D  e $ ,r)NN)r4 str | Noner5z!Callable[[Argument], None] | Noner!rzrNoner)r>rrr)rAArgumentrr)N)rDrrIrrJrrr-rRrrSrrrr:)r^ Sequence[str | os.PathLike[str]]rWargparse.Namespace | Nonerargparse.Namespace)r^rrWrrz$tuple[argparse.Namespace, list[str]]) rDrrrrzYLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float'] | Nonerrrt Sequence[str]rr)rrr__doc__r8propertyr<setterrBrOrQrardrcr}rrrrrrsz!8</  //6/  /  /4## [[$$) EI&)7A >2&04,.,-,  ,604 O. O- O  O04R.R-R . R@P,"$P,P,P, P,P,P, P,rrc4|dvrgS|dk(ry|dk(ry|dk(ryy) zs Used by addini to get the default value for a given config option type, when default is not supplied. )rwrxr^ryrzFr{rr|grr)rs rr~r~ s3 88   rc eZdZdZddZddZy) ArgumentErrorzURaised if an Argument instance is created with invalid or inconsistent arguments.c2||_t||_yr:)msgr option_id)rrrAs rr8zArgumentError.__init__%sVrcj|jrd|jd|jS|jS)Nzoption : )rrrs r__str__zArgumentError.__str__)s. >>T^^,Btxxj9 988OrN)rrrAzArgument | strrrr)rrrrr8rrrrrr!s%rrc8eZdZdZddZd dZd dZd dZd dZy) rzClass that mimics the necessary behaviour of optparse.Option. It's currently a least effort implementation and ignoring choices and integer prefixes. https://docs.python.org/3/library/optparse.html#optparse-standard-option-types c||_g|_g|_ |d|_ |d|_|j ||jd}|r||_y|jr(|jdddjdd|_y |jdd d|_y#t$rYwxYw#t$rYwxYw#t$r}d |_td ||d}~wwxYw) z5Store params in private vars for use in add_argument.rrr@rNrj_r z???zneed a long or short option) _attrs _short_opts _long_optsrKeyErrorr_set_opt_stringsrr@replace IndexErrorr)rnamesrSr@es rr8zArgument.__init__9s &(%' f DI  +DL e$ 99V, DI __*12.66sC@DI P ,,Q/3         P! #$A4HaO Ps: B% B4 C% B10B14 C?C C% C  C%c4|j|jzSr:)rrrs rrzArgument.namesTs$//11rcddd|jfD]} t|||j|<|jS#t$rY6wxYw)Nrr@r)r@rmrAttributeError)rattrs rrSzArgument.attrsWsX : D $+D$$7 D!  {{"  s< AAcX|D]}t|dkrtd|d|t|dk(r<|ddk(r|ddk7std|d||jj|k|ddd k(r|ddk7std |d ||jj|y ) zhDirectly from optparse. Might not be necessary as this is passed to argparse later on. rzinvalid option string z&: must be at least two characters longrrjr zinvalid short option string z/: must be of the form -x, (x any non-dash char)--zinvalid long option string z*: must start with --, followed by non-dashN)lenrrror)rrRopts rrzArgument._set_opt_strings`s  ,C3x!|#,SG4;; SQA# #a&C-'6sg>HH   '',AaD(SVs]'5cW=CC &&s+- ,rcg}|jr|dt|jzgz }|jr|dt|jzgz }|dt|jzgz }t |dr|dt|j zgz }t |dr|dt|j zgz }djd j|S) Nz _short_opts: z _long_opts: zdest: rztype: rz default: z Argument({}), ) rreprrr@hasattrrrformatjoin)rr^s rrzArgument.__repr__}s    _tD,<,<'==> >D ?? ^d4??&;;< ` function accepts. c3JK|]}|jD]}|ywr:)r).0rrDs r z(OptionGroup.addoption..s-* SYY[* -1D* * s!#z option names z already addedF shortupperN)set intersectionrrr_addoption_instance)rrRrSconflictrAs rrQzOptionGroup.addoptionsdt9))*  LL*   }XJnEF F4)5)   E :rc@t|i|}|j|dy)NTr)rr)rrRrSrAs r _addoptionzOptionGroup._addoptions$4)5)   D 9rcl|s8|jD])}|ddk(s |djs td|jr|jj ||j j |ji|j|jj|y)Nrrjr zlowercase shortoptions reserved) rislowerrrrBrr/rrSrro)rrArrs rrzOptionGroup._addoption_instances)) Hq6S=SV^^%5$%FGG H ;; KK % %f -###V\\^Fv||~F F#rN)F) rLzargparse._ArgumentGrouprDrrz Parser | Noner!rzrrr)rArrrzrr)rrrrr8rQrrrrrr-r-sN6 )       ;,: $rr-c8eZdZ dfd ZddZxZS)r*cR||_t| |dtdd||_y)NF@)r4add_helpformatter_class allow_abbrevfromfile_prefix_chars)_parsersuperr8DropShorterLongHelpFormatterr))rrr4r) __class__s rr8zPytestArgumentParser.__init__s6   8"%  %rc |jd|}|jr?|ddjdt|jj Dzz }t |j |z)z1Transform argparse error message into UsageError.z : error:  c32K|]\}}d|d|yw)z rNr)rkvs rrz-PytestArgumentParser.error..s%$"&!Q"QCr! $s)r<r)rsorteditemsr format_usage)rmessagers rerrorzPytestArgumentParser.errorss 9WI. ?? 4$))$*01F1F1H*I$ C**,s233r)rrr4rr)zdict[str, str]rr)rrrr )rrrr8r __classcell__rs@rr*r*s3%%%# %  %$4rr*c6eZdZdZdfd Zdfd ZdZxZS)ra+Shorten help for long options that differ only in extra hyphens. - Collapse **long** options that are the same except for extra hyphens. - Shortcut if there are only two options and one of them is a short one. - Cache result on the action object as this is called at least 2 times. cnd|vr!tjj|d<t||i|y)Nwidth)_pytest_ioget_terminal_widthrr8)rr^kwargsrs rr8z%DropShorterLongHelpFormatter.__init__s3 & %kk<<>F7O $)&)rct ||}|r |ddk7r|St|dd}|r|S|jd}t |dk(r+t |ddk(st |ddk(r ||_|Sg}i}|D]u}t |dk(s|ddk(r|j dstd |d ||dd}|jdd } | |vst || t |ksq||| <w|D]s}t |dk(s|ddk(r|j||dd|j|jdd k(sR|j|jdd dudj|} | |_| S) Nrrj_formatted_action_invocationrrr  rz&long optional argument without "--": []r=) r_format_action_invocationrmsplitrrrnrrrorr) ractionorgstrresr return_list short_longrAxxoption shortenedformatted_action_invocationrs rrz6DropShorterLongHelpFormatter._format_action_invocations26: fQi3&M!&*H$O J,,t$ w<1 #gaj/Q"6#gaj/Q:N28F /M %'  1F6{a6!9#3$$T*#>#sA#>?  @ '+ii &<#.I+**rcddl}g}|jD]1}|j|j|j |3|S)z}Wrap lines after splitting on original newlines. This allows to have explicit line breaks in the help text. rN)textwrap splitlinesextendwrapstrip)rtextrrlineslines r _split_linesz)DropShorterLongHelpFormatter._split_linessD OO% =D LLtzz|U; < = r)r^rrrrr)rzargparse.Actionrr)rrrrr8rrrrs@rrrs* $+L rrcReZdZdZ d dfd Z ddZxZS)OverrideIniActionzCustom argparse action that makes a CLI flag equivalent to overriding an option, in addition to behaving like `store_true`. This can simplify things since code only needs to inspect the config option and not consider the CLI flag. cLt|||dg|i|||_||_y)Nr)rr8 ini_option ini_value) roption_stringsr@r&rrr^rrs rr8zOverrideIniAction.__init__(s. qB4B6B$"rct||jdt|dd}|g}|j|jd|j t|d|y)NT override_inir)setattrr@rmrorr)rrrWr^rcurrent_overridess r__call__zOverrideIniAction.__call__6s_  499d+#I~tD  $ "   DOO#4Adnn5E!FG >+<=rr:) rrr@rr&zint | str | Nonerrrrrr)rzargparse.ArgumentParserrWrrr)rrrrr8r rrs@rrr sm#' #% # # #  # #  # >' >& >  >rr)rzRLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float']rr)# __future__rrZcollections.abcrrrrXrktypingrrr r exceptionsr _pytest._ior_pytest.deprecatedr r0rr}rr~ Exceptionrrr-ArgumentParserr* HelpFormatterrActionrrrrrs"$#$ "-  (i,i,i,X  * I X6X6v4$4$n48224:>8#9#9>B">">r