
    XiO                       S SK Jr  S SKrS SKJr  S SKJr  S SKJr  S SKrS SKrS SK	J
r
  S SK	Jr  S SK	Jr  S S	K	Jr  S
SKJr  S SKrS SKJr  Sr " S S5      r\" 5       r\ " S S5      5       r    SS jr " S S\5      r " S S5      r " S S5      r " S S\R:                  5      r " S S\R>                  5      r  " S S\RB                  5      r"g)     )annotationsN)Callable)Mapping)Sequence)Any)final)Literal)NoReturn   )
UsageError)check_ispytestfile_or_dirc                      \ rS rSrSS jrSrg)NotSet   c                    g)Nz<notset> selfs    L/var/www/html/venv/lib/python3.13/site-packages/_pytest/config/argparsing.py__repr__NotSet.__repr__   s        r   Nreturnstr)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r      s    r   r   c                  ,   \ rS rSrSr  SSS.       SS jjjr\SS j5       r\R                  SS j5       rSS	 jr	 S       SS
 jjr
SS jr S     SS jjr S     SS jjr S     SS jjrS\4SS.           SS jjjrSrg)Parser   zParser 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	_ispytestc               V   [        U5        SSKJn  X l        0 U l        [        XU R                  5      U l        U R                  R                  S5      n[        USU SS9U l	        U R                  /U l
        U R                  R                  [        SS9nXFl        0 U l        0 U l        g )	Nr   )filescompleterzCustom options
_anonymousTr%   *)nargs)r   _pytest._argcompleter(   _processopt
extra_infoPytestArgumentParser	optparseradd_argument_groupOptionGroupr)   _groupsadd_argumentFILE_OR_DIR	completer_inidict_ini_aliases)r   usage
processoptr&   r(   anonymous_arggroupfile_or_dir_args          r   __init__Parser.__init__'   s     	y!7%*,-d4??K!^^>>?OP%dd
 (..55k5M$2!9;,.r   c                .    U R                   R                  $ Nr0   progr   s    r   rB   Parser.progA   s    ~~"""r   c                $    XR                   l        g r@   rA   )r   values     r   rB   rC   E   s    #r   c                n    U R                   (       a$  UR                  (       a  U R                  U5        g g g r@   )r-   dest)r   options     r   processoptionParser.processoptionI   s*    {{  (  r   c                   U R                    H  nUR                  U:X  d  M  Us  $    U R                  R                  U=(       d    U5      n[	        XQU SS9nSn[        U R                   5       H  u  pgUR                  U:X  d  M    O   U R                   R                  US-   U5        U R                  R                  R                  US-   U R                  R                  R                  5       5        U$ )a  Get (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 <pytest.Parser.addoption>` but
will be shown in the respective group in the output of
``pytest --help``.
Tr%   r   r   )	r3   namer0   r1   r2   	enumerateinsert_action_groupspop)r   rL   descriptionaftergrouparggroupigrps           r   getgroupParser.getgroupN   s     \\EzzT! " >>44[5HDIHDDA-FAxx5  . 	AE5) 	%%,,QUDNN4Q4Q4U4U4WXr   c                <    U R                   R                  " U0 UD6  g)a  Register 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()
    <argparse.ArgumentParser.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)r   optsattrss      r   rZ   Parser.addoptionm   s     	!!4151r   c                   SSK Jn  U" U R                  5        U Vs/ s H  n[        R                  " U5      PM     nnUc  [
        R                  " 5       n SUl        U R                  R                  XRS9U?$ s  snf ! U?f = f)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,   r_   r0   osfspathargparse	Namespace_raise_print_helpparse_intermixed_args)r   argsra   r_   xstrargss         r   parseParser.parse}   sz     	9')-.A299Q<. **,I	,*.I'>>777U+ / +s    A:A? ?Bc                &    U R                  XS9S   $ )zRParse the known arguments at this point.

:returns: An argparse namespace object.
r`   r   )parse_known_and_unknown_args)r   rh   ra   s      r   parse_known_argsParser.parse_known_args   s     000KANNr   c                   U Vs/ s H  n[         R                  " U5      PM     nn[        R                  S:  d  S[        R                  s=::  a  S:  al  O  OiU R                  R                  XB5      u  p%Uc   e[        U[        5      n/ nU H,  nUR                  S5      (       a  UOUR                  U5        M.     X'4$ U R                  R                  XB5      $ s  snf )zParse 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.
)         )rr      )rr   ru   r   -)rb   rc   sysversion_infor0   ro   getattrr5   
startswithappendparse_known_intermixed_args)	r   rh   ra   ri   rj   unknownr   unknown_flagsargs	            r   rn   #Parser.parse_known_and_unknown_args   s     *..A299Q<.j(Gs7G7G,T*,T!%!@!@!TI(((!)[9K')M"%.."5"5;NNsS ++>>==gQQ /s    Cr   )aliasesc               4   US;   d   eUc  SnU[         L a  [        U5      nX#U4U R                  U'   U H`  nX`R                  ;   a  [        SU< S35      eU R                  R                  U5      =nb  [        U< SU< 35      eXR                  U'   Mb     g)a  Register 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) <pytest.Config.getini>`.
)	Nstringpathspathlistrh   linelistboolintfloatNr   zalias z- conflicts with existing configuration optionz is already an alias of )NOT_SETget_ini_default_for_typer7   
ValueErrorr8   get)r   rL   helptypedefaultr   aliasalreadys           r   addiniParser.addini   s    n  

 

 
	
 

 <Dg.t4G#73dE% UI%RS   ,,0077D E9,DWK!PQQ'+e$ r   )r)   r3   r8   r7   r-   r.   r0   )NN)r9   
str | Noner:   z!Callable[[Argument], None] | Noner&   r   r   Noner   )rE   r   r   r   )rH   Argumentr   r   ) N)rL   r   rQ   r   rR   r   r   r2   r[   r   r\   r   r   r   r@   )rh    Sequence[str | os.PathLike[str]]ra   argparse.Namespace | Noner   argparse.Namespace)rh   r   ra   r   r   z$tuple[argparse.Namespace, list[str]])rL   r   r   r   r   zYLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float'] | Noner   r   r   Sequence[str]r   r   )r   r   r   r    __doc__r=   propertyrB   setterrI   rW   rZ   rk   ro   rn   r   r   r!   r   r   r   r#   r#      s    !8</
  // 6/
 / 
/4 # # 
[[$ $) EI&)7A	>2& 04,., -, 
	,6 04	O.	O -	O 
		O 04R.R -R 
.	R@ P, "$P,P, P,	P, P, P, 
P, P,r   r#   c                >    U S;   a  / $ U S:X  a  gU S:X  a  gU S:X  a  gg)	zg
Used by addini to get the default value for a given config option type, when
default is not supplied.
)r   r   rh   r   r   Fr   r   r   g        r   r   )r   s    r   r   r     s3     88				r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	ArgumentErrori!  zQRaised if an Argument instance is created with invalid or
inconsistent arguments.c                0    Xl         [        U5      U l        g r@   )msgr   	option_id)r   r   rH   s      r   r=   ArgumentError.__init__%  s    Vr   c                t    U R                   (       a  SU R                    SU R                   3$ U R                  $ )Nzoption : )r   r   r   s    r   __str__ArgumentError.__str__)  s.    >>T^^,Btxxj9988Or   )r   r   N)r   r   rH   zArgument | strr   r   r   )r   r   r   r    r   r=   r   r!   r   r   r   r   r   !  s    %r   r   c                  J    \ rS rSrSrS
S jrSS jrSS jrSS jrSS jr	Sr
g	)r   i0  zClass 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                   X l         / U l        / U l         US   U l         US   U l        U R                  U5        UR                  S5      nU(       a  X0l        gU R                  (       a(  U R                  S   SS R                  SS5      U l        g U R                  S   S	S U l        g! [         a     Nf = f! [         a     Nf = f! [         a  nS
U l        [        SU 5      UeSnAff = f)z5Store params in private vars for use in add_argument.r   r   rG   r      Nrv   _r   z???zneed a long or short option)_attrs_short_opts
_long_optsr   KeyErrorr   _set_opt_stringsr   rG   replace
IndexErrorr   )r   namesr\   rG   es        r   r=   Argument.__init__9  s    &(%'	fDI	 +DL 	e$ 99V,I__*12.66sC@DIP ,,Q/3	  		
  		  P!	#$A4HaOPs:   
B- 
B= C -
B:9B:=
C
	C

C0C++C0c                4    U R                   U R                  -   $ r@   )r   r   r   s    r   r   Argument.namesT  s    $//11r   c                    SSSU R                   4 H  n [        X5      U R                  U'   M     U R                  $ ! [         a     M9  f = f)Nr   rG   r   )rG   ry   r   AttributeError)r   attrs     r   r\   Argument.attrsW  sQ    		:D$+D$7D! ;
 {{ " s   =
A
Ac                p   U H  n[        U5      S:  a  [        SU< S3U 5      e[        U5      S:X  a@  US   S:X  a	  US   S:w  d  [        SU< S3U 5      eU R                  R                  U5        Mr  USS S	:X  a	  US   S:w  d  [        S
U< S3U 5      eU R                  R                  U5        M     g)zXDirectly from optparse.

Might not be necessary as this is passed to argparse later on.
r   zinvalid option string z&: must be at least two characters longr   rv   r   zinvalid short option string z/: must be of the form -x, (x any non-dash char)--zinvalid long option string z*: must start with --, followed by non-dashN)lenr   r   r{   r   )r   r[   opts      r   r   Argument._set_opt_strings`  s    
 C3x!|#,SG 4; ; 
 SQA##a&C-'6sg >H H 
   '',AaD(SVs]'5cW =C C 
 &&s+- r   c                   / nU R                   (       a  US[        U R                   5      -   /-  nU R                  (       a  US[        U R                  5      -   /-  nUS[        U R                  5      -   /-  n[	        U S5      (       a  US[        U R
                  5      -   /-  n[	        U S5      (       a  US[        U R                  5      -   /-  nSR                  S	R                  U5      5      $ )
Nz_short_opts: z_long_opts: zdest: r   ztype: r   z	default: zArgument({}), )	r   reprr   rG   hasattrr   r   formatjoin)r   rh   s     r   r   Argument.__repr__}  s    _tD,<,<'==>>D??^d4??&;;<<DDO+,,4  XTYY/00D4##[4#5566D$$TYYt_55r   )r   r   r   r   rG   r   N)r   r   r\   r   r   r   )r   z	list[str])r   zMapping[str, Any])r[   r   r   r   r   )r   r   r   r    r   r=   r   r\   r   r   r!   r   r   r   r   r   0  s!    P62,:6r   r   c                  \    \ rS rSrSr S	         S
S jjrSS jrSS jrS	SS jjrSr	g)r2   i  z,A group of options shown in its own section.c                L    [        U5        Xl        X l        / U l        X0l        g r@   )r   	_arggrouprL   optionsparser)r   rT   rL   r   r&   s        r   r=   OptionGroup.__init__  s"     	y!!	')r   c                    [        U5      R                  S U R                   5       5      nU(       a  [        SU S35      e[	        U0 UD6nU R                  USS9  g)a  Add an option to this group.

If a shortened version of a long option is specified, it will
be suppressed in the help. ``addoption('--twowords', '--two-words')``
results in help showing ``--two-words`` only, but ``--twowords`` gets
accepted **and** the automatic destination is in ``args.twowords``.

:param opts:
    Option names, can be short or long options.
:param attrs:
    Same attributes as the argparse library's :meth:`add_argument()
    <argparse.ArgumentParser.add_argument>` function accepts.
c              3  R   #    U  H  oR                  5         H  o"v   M     M     g 7fr@   )r   ).0r   rL   s      r   	<genexpr>(OptionGroup.addoption.<locals>.<genexpr>  s      *
(SYY[TD[DLs   %'zoption names z already addedF
shortupperN)setintersectionr   r   r   _addoption_instance)r   r[   r\   conflictrH   s        r   rZ   OptionGroup.addoption  sd     t9)) *
 LL*
 
 }XJnEFF4)5)  E :r   c                :    [        U0 UD6nU R                  USS9  g )NTr   )r   r   )r   r[   r\   rH   s       r   
_addoptionOptionGroup._addoption  s$    4)5)  D 9r   c                   U(       dA  UR                    H1  nUS   S:X  d  M  US   R                  5       (       d  M(  [        S5      e   U R                  (       a  U R                  R	                  U5        U R
                  R                  " UR                  5       0 UR                  5       D6  U R                  R                  U5        g )Nr   rv   r   zlowercase shortoptions reserved)r   islowerr   r   rI   r   r4   r   r\   r   r{   )r   rH   r   r   s       r   r   OptionGroup._addoption_instance  s    ))q6S=SV^^%5%5$%FGG * ;;KK%%f-##V\\^Fv||~FF#r   )r   rL   r   r   N)F)
rT   zargparse._ArgumentGrouprL   r   r   zParser | Noner&   r   r   r   r   )rH   r   r   r   r   r   )
r   r   r   r    r   r=   rZ   r   r   r!   r   r   r   r2   r2     sS    6  )  	
  
;,:
$ 
$r   r2   c                  F   ^  \ rS rSr        SU 4S jjrSS jrSrU =r$ )r/   i  c                H   > Xl         [        TU ]	  US[        SSS9  X0l        g )NF@)r9   add_helpformatter_classallow_abbrevfromfile_prefix_chars)_parsersuperr=   DropShorterLongHelpFormatterr.   )r   r   r9   r.   	__class__s       r   r=   PytestArgumentParser.__init__  s2     8"% 	 	
 %r   c           	         U R                    SU 3nU R                  (       a?  USSR                  S [        U R                  R	                  5       5       5       5      -   -  n[        U R                  5       U-   5      e)z1Transform argparse error message into UsageError.z	: error: 
c              3  6   #    U  H  u  pS U SU 3v   M     g7f)z  r   Nr   )r   kvs      r   r   -PytestArgumentParser.error.<locals>.<genexpr>  s"      $*I$!"QCr!*Is   )rB   r.   r   sorteditemsr   format_usage)r   messager   s      r   errorPytestArgumentParser.error  ss    9WI.??4$)) $*01F1F1H*I$   C **,s233r   )r   r.   )r   r#   r9   r   r.   zdict[str, str]r   r   )r   r   r   r
   )r   r   r   r    r=   r   r!   __classcell__r   s   @r   r/   r/     s8    %% % #	%
 
%$4 4r   r/   c                  F   ^  \ rS rSrSrSU 4S jjrSU 4S jjrS rSrU =r	$ )	r   i  a  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.
c                t   > SU;  a!  [         R                  R                  5       US'   [        TU ]  " U0 UD6  g )Nwidth)_pytest_ioget_terminal_widthr   r=   )r   rh   kwargsr   s      r   r=   %DropShorterLongHelpFormatter.__init__  s3    & %kk<<>F7O$)&)r   c                J  > [         TU ]  U5      nU(       a  US   S:w  a  U$ [        USS 5      nU(       a  U$ UR                  S5      n[	        U5      S:X  a,  [	        US   5      S:X  d  [	        US   5      S:X  a  X!l        U$ / n0 nU H  n[	        U5      S:X  d	  US   S:X  a  M  UR                  S5      (       d  [        S	U S
3U5      eUSS  nUR                  SS5      n	X;  d  [	        Xi   5      [	        U5      :  d  M{  XU	'   M     U Hx  n[	        U5      S:X  d	  US   S:X  a  UR                  U5        USS  UR                  UR                  SS5      5      :X  d  MV  UR                  UR                  SSS5      5        Mz     SR                  U5      n
Xl        U
$ )Nr   rv   _formatted_action_invocationr   r   r    r   z&long optional argument without "--": []r   =)r   _format_action_invocationry   splitr   r  rz   r   r   r{   r   r   )r   actionorgstrresr   return_list
short_longrH   xxoption	shortenedformatted_action_invocationr   s              r   r  6DropShorterLongHelpFormatter._format_action_invocation  s   26:fQi3&M!&*H$OJ,,t$w<1#gaj/Q"6#gaj/Q:N28/M%'
F6{a6!9#3$$T**#<VHAF  abzH ((b1I*c*2G.H3L / )19%  F6{a6!9#3""6*abzZ^^FNN3,CDD""6>>#sA#>?	 
 '+ii&<#.I+**r   c                    SSK n/ nUR                  5        H2  nUR                  UR                  UR	                  5       U5      5        M4     U$ )zmWrap lines after splitting on original newlines.

This allows to have explicit line breaks in the help text.
r   N)textwrap
splitlinesextendwrapstrip)r   textr   r  lineslines         r   _split_lines)DropShorterLongHelpFormatter._split_lines  s?    
 	OO%DLLtzz|U;< &r   r   )rh   r   r  r   r   r   )r  zargparse.Actionr   r   )
r   r   r   r    r   r=   r  r  r!   r   r   s   @r   r   r     s    *$+L
 
r   r   c                  b   ^  \ rS rSrSr S           SU 4S jjjr      SS jrSrU =r$ )	OverrideIniActioni   zCustom 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.
c               H   > [         TU ]  " XS/UQ70 UD6  X@l        XPl        g )Nr   )r   r=   
ini_option	ini_value)	r   option_stringsrG   r+   r$  r%  rh   r  r   s	           r   r=   OverrideIniAction.__init__(  s(     	qB4B6B$"r   c                    [        X R                  S5        [        USS 5      nUc  / nUR                  U R                   SU R
                   35        [        USU5        g )NToverride_inir
  )setattrrG   ry   r{   r$  r%  )r   r   ra   rh   r  current_overridess         r   __call__OverrideIniAction.__call__6  s]     		99d+#I~tD$ "  DOO#4Adnn5E!FG	>+<=r   )r$  r%  r@   )r&  r   rG   r   r+   zint | str | Noner$  r   r%  r   r   r   )r   zargparse.ArgumentParserra   r   r   r   )	r   r   r   r    r   r=   r,  r!   r   r   s   @r   r"  r"     sw     #'	#%# #  	# # # 
# #>'> &> 
> >r   r"  )r   zRLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float']r   r   )#
__future__r   rd   collections.abcr   r   r   rb   rw   typingr   r   r	   r
   
exceptionsr   _pytest._ior  _pytest.deprecatedr   r5   r   r   r#   r   	Exceptionr   r   r2   ArgumentParserr/   HelpFormatterr   Actionr"  r   r   r   <module>r8     s    "  $ # $ 	 
     "  -  
 ( i, i, i,X 		*I X6 X6v4$ 4$n4822 4:>8#9#9 >B"> ">r   