
    ESjE                    |   d dl mZ d dlZd dlmZ d dlm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 d dlZd dlmZ d dlmZ dZe G d d             Z	 	 	 	 ddZ G d d      Z G d d      Z G d dej6                        Z G d dej:                        Z G d dej>                        Z y)    )annotationsN)Callable)Sequence)Any)final)Literal)NoReturn   )
UsageError)NOTSET)check_ispytestfile_or_dirc                     e Zd ZdZ	 	 dddd	 	 	 	 	 	 	 	 	 ddZedd       Zej                  dd       ZddZ	 d	 	 	 	 	 	 	 dd	Z	dd
Z
	 d	 	 	 	 	 ddZ	 d	 	 	 	 	 ddZ	 d	 	 	 	 	 ddZdefdd	 	 	 	 	 	 	 	 	 	 	 ddZy)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)prog	_ispytestc               x   t        |       ddlm} || _        i | _        t        || j                  |      | _        | j                  j                  d      }t        |d| d      | _	        | j                  g| _
        i | _        | j                  j                  t        d	      }||_        i | _        i | _        y )
Nr   )filescompleterr   zCustom options
_anonymousTr   *)nargs)r   _pytest._argcompleter   _processopt
extra_infoPytestArgumentParser	optparseradd_argument_groupOptionGroupr   _groups	_opt2destadd_argumentFILE_OR_DIR	completer_inidict_ini_aliases)selfusage
processoptr   r   r   anonymous_arggroupfile_or_dir_args           j/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/_pytest/config/argparsing.py__init__zParser.__init__    s     	y!7%*,-eT__4P!^^>>?OP%dd
 ()+..55k5M$2!9;,.    c                .    | j                   j                  S Nr   r   r(   s    r-   r   zParser.prog=   s    ~~"""r/   c                &    || j                   _        y r1   r2   )r(   values     r-   r   zParser.progA   s    #r/   c                Z    | j                   r|j                  r| j                  |       y y y r1   )r   dest)r(   options     r-   processoptionzParser.processoptionE   s*    {{  (  r/   c                   | j                   D ]  }|j                  |k(  s|c S  | j                  j                  |xs |      }t	        ||| d      }d}t        | j                         D ]  \  }}|j                  |k(  s n | j                   j                  |dz   |       | j                  j                  j                  |dz   | j                  j                  j                                |S )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
   )	r!   namer   r   r    	enumerateinsert_action_groupspop)r(   r;   descriptionaftergrouparggroupigrps           r-   getgroupzParser.getgroupJ   s     \\EzzT! " >>44[5HDIHdDDA-FAsxx5  . 	AE5) 	%%,,QUDNN4Q4Q4U4U4WXr/   c                <     | j                   j                  |i | y)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-   rH   zParser.addoptioni   s     	"!!4151r/   c                   ddl m}  || j                         |D cg c]  }t        j                  |       }}|t        j                         }	 d|_        | j                  j                  ||      |`S c c}w # |`w xY w)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   rM   r   osfspathargparse	Namespace_raise_print_helpparse_intermixed_args)r(   argsrO   rM   xstrargss         r-   parsezParser.parsey   s|     	9')-.A299Q<. **,I	,*.I'>>7797U+ / +s   A8#A= =Bc                .    | j                  ||      d   S )zbParse the known arguments at this point.

        :returns: An argparse namespace object.
        rN   r   )parse_known_and_unknown_args)r(   rV   rO   s      r-   parse_known_argszParser.parse_known_args   s     000KANNr/   c                   |D cg c]  }t        j                  |       }}t        j                  dk  sdt        j                  cxk  rdk  rgn nd| j                  j                  ||      \  }}|J t        |t              }g }|D ]&  }|j                  d      r|n|j                  |       ( ||fS | j                  j                  ||      S c c}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.
        )         )r^      )r^   ra   r
   -)rP   rQ   sysversion_infor   r\   getattrr$   
startswithappendparse_known_intermixed_args)	r(   rV   rO   rW   rX   unknownr   unknown_flagsargs	            r-   r[   z#Parser.parse_known_and_unknown_args   s     *..A299Q<.j(Gs7G7G,T*,T!%!@!@)!TIw(((!)[9K')M"%.."5;NNsS m++>>==gyQQ /s   C )aliasesc               "   |dv sJ |d}|t         u rt        |      }|||f| j                  |<   |D ][  }|| j                  v rt        d|d      | j                  j                  |      x}t        |d|      || j                  |<   ] y)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pathlistrV   linelistboolintfloatNro   zalias z- conflicts with existing configuration optionz is already an alias of )r   get_ini_default_for_typer&   
ValueErrorr'   get)r(   r;   helptypedefaultrm   aliasalreadys           r-   addinizParser.addini   s    n  

 

 
	
 

 <Df.t4G#T73dE% UI%RS   ,,0077D E9,DWK!PQQ'+De$ r/   )NN)
r)   
str | Noner*   z!Callable[[Argument], None] | Noner   r   r   rs   returnNoner   str)r5   r   r   r   )r8   Argumentr   r   ) N)r;   r   r@   r   rA   r   r   r    rJ   r   rK   r   r   r   r1   )rV    Sequence[str | os.PathLike[str]]rO   argparse.Namespace | Noner   argparse.Namespace)rV   r   rO   r   r   z$tuple[argparse.Namespace, list[str]])r;   r   ry   r   rz   zYLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float'] | Noner{   r   rm   Sequence[str]r   r   )__name__
__module____qualname____doc__r.   propertyr   setterr9   rF   rH   rY   r\   r[   r   r~   rl   r/   r-   r   r      s    !8</
  // 6/
 / / 
/: # # 
[[$ $) EI&)7A	>2& 04,., -, 
	,6 04	O.	O -	O 
		O 04R.R -R 
.	R@ P, "$P,P, P,	P, P, P, 
P,r/   r   c                4    | dv rg S | dk(  ry| dk(  ry| dk(  ryy)	zs
    Used by addini to get the default value for a given config option type, when
    default is not supplied.
    )rp   rq   rV   rr   rs   Frt   r   ru   g        r   rl   )rz   s    r-   rv   rv     s3     88				r/   c                  f    e Zd ZdZd
dZddZddZedd       Zedd       Z	edd       Z
ddZy	)r   z$An option defined in an OptionGroup.c                    || _         y r1   )_action)r(   actions     r-   r.   zArgument.__init__   s	    r/   c                .    | j                   j                  S r1   )r   __dict__r3   s    r-   rK   zArgument.attrs#  s    ||$$$r/   c                .    | j                   j                  S r1   )r   option_stringsr3   s    r-   nameszArgument.names&  s    ||***r/   c                .    | j                   j                  S r1   )r   r7   r3   s    r-   r7   zArgument.dest)      ||   r/   c                .    | j                   j                  S r1   )r   r{   r3   s    r-   r{   zArgument.default-  s    ||###r/   c                .    | j                   j                  S r1   )r   rz   r3   s    r-   rz   zArgument.type1  r   r/   c                f   t        | dd       }|yg }|dt        | j                               z   gz  }|dt        | j                        z   gz  }|j                  r|dt        | j                        z   gz  }|dt        | j
                        z   gz  }dj                  dj                  |            S )	Nr   zArgument(<uninitialized>)zopts: zdest: ztype: z	default: zArgument({}), )re   reprr   r7   rz   r{   formatjoin)r(   r   rV   s      r-   __repr__zArgument.__repr__5  s    y$/>.D..//DO+,,;;XTYY/00DtDLL1122$$TYYt_55r/   N)r   argparse.Actionr   r   )r   dict[str, Any])r   r   r   )r   r   )r   z
Any | None)r   r   r   r   r.   rK   r   r   r7   r{   rz   r   rl   r/   r-   r   r     sU    .%+ ! ! $ $ ! !
6r/   r   c                  V    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 ddZd	dZd	dZ	 	 	 	 	 	 	 	 d
dZy)r    z,A group of options shown in its own section.c                R    t        |       || _        || _        g | _        || _        y r1   )r   	_arggroupr;   optionsparser)r(   rC   r;   r   r   s        r-   r.   zOptionGroup.__init__E  s(     	y!!	')r/   c                    t        |      j                  d | j                  D              }|rt        d| d      | j	                  ||d       y)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.
            Note that lower-case short options (e.g. `-x`) are reserved.
        :param attrs:
            Same attributes as the argparse library's :meth:`add_argument()
            <argparse.ArgumentParser.add_argument>` function accepts.
        c              3  J   K   | ]  }|j                         D ]  }|   y wr1   )r   ).0optr;   s      r-   	<genexpr>z(OptionGroup.addoption.<locals>.<genexpr>a  s"      *
(SSYY[TD[DLs   !#zoption names z already addedFallow_reservedN)setintersectionr   rw   _addoption_inner)r(   rJ   rK   conflicts       r-   rH   zOptionGroup.addoptionR  sW     t9)) *
 LL*
 
 }XJnEFFdE%@r/   c                ,    | j                  ||d       y)z}Like addoption(), but also allows registering short lower case options (e.g. -x),
        which are reserved for pytest core.Tr   N)r   rI   s      r-   
_addoptionzOptionGroup._addoptionh  s     	dE$?r/   c                   |s=|D ]8  }t        |      dk\  s|d   dk(  s|d   j                         s/t        d        | j                  j                  |i |}t        |      }| j                  j                  |       | j                  rT|j                         D ]%  }|j                  | j                  j                  |<   ' | j                  j                  |       y y )N   r   rb   r
   z$lowercase short options are reserved)lenislowerrw   r   r#   r   r   rg   r   r   r7   r"   r9   )r(   rJ   rK   r   r   r   r8   r;   s           r-   r   zOptionGroup._addoption_innerm  s     s8q=SVs]s1v~~7G$%KLL  -,,d<e<&!F#;;.4kk%%d+ 'KK%%f- r/   N)F)
rC   zargparse._ArgumentGroupr;   r   r   zParser | Noner   rs   r   r   r   )rJ   ztuple[str, ...]rK   r   r   rs   r   r   )r   r   r   r   r.   rH   r   r   rl   r/   r-   r    r    B  sp    6  )  	
  
A,@
.#.,:.LP.	.r/   r    c                  <     e Zd Zdd	 	 	 	 	 	 	 d fdZddZ xZS )r   Nr   c               F    t         |   ||dt        dd       || _        y )NF@)r)   r   add_helpformatter_classallow_abbrevfromfile_prefix_chars)superr.   DropShorterLongHelpFormatterr   )r(   r)   r   r   	__class__s       r-   r.   zPytestArgumentParser.__init__  s2     	8"% 	 	
 %r/   c           	         | j                    d| }| j                  r?|ddj                  d t        | j                  j	                               D              z   z  }t        | j                         |z         )z1Transform argparse error message into UsageError.z	: error: 
c              3  2   K   | ]  \  }}d | d|   yw)z  z: Nrl   )r   kvs      r-   r   z-PytestArgumentParser.error.<locals>.<genexpr>  s%      $*I$!Q"QCr!*Is   )r   r   r   sorteditemsr   format_usage)r(   messagemsgs      r-   errorzPytestArgumentParser.error  su     9WI.??4$)) $*01F1F1H*I$   C **,s233r/   )r)   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      %% #%
 % 
%&	4r/   r   c                  8     e Zd ZdZd fdZd fdZddZ xZS )r   zShorten 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.
    c                n    d|vr!t         j                  j                         |d<   t        |   |i | y )Nwidth)_pytest_ioget_terminal_widthr   r.   )r(   rV   kwargsr   s      r-   r.   z%DropShorterLongHelpFormatter.__init__  s3    & %kk<<>F7O$)&)r/   c                   t         	|   |      }|r
|d   dk7  r|S |j                  d      }t        |      dk(  r$t        |d         dk(  st        |d         dk(  r|S g }i }|D ]p  }t        |      dk(  s|d   dk(  r|j	                  d      sJ d| d	       |dd  }|j                  dd
      }||vst        ||         t        |      k  sl|||<   r |D ]s  }t        |      dk(  s|d   dk(  r|j                  |       |dd  |j                  |j                  dd
            k(  sR|j                  |j                  ddd             u dj                  |      S )Nr   rb   r   r   r
    z--z&long optional argument without "--": []r   =)	r   _format_action_invocationsplitr   rf   replacerg   rx   r   )
r(   r   orgstrr   return_list
short_longr8   xxoption	shortenedr   s
            r-   r   z6DropShorterLongHelpFormatter._format_action_invocation  s   26:fQi3&M,,t$w<1#gaj/Q"6#gaj/Q:NM%'
F6{a6!9#3$$T* 8B* abzH ((b1I
*c*Y2G.H3L / )1
9%  F6{a6!9#3""6*abzZ^^FNN3,CDD""6>>#sA#>?	 
 yy%%r/   c                    g }|j                         D ]5  }|j                  t        j                  |j	                         |             7 |S )z}Wrap lines after splitting on original newlines.

        This allows to have explicit line breaks in the help text.
        )
splitlinesextendtextwrapwrapstrip)r(   textr   lineslines        r-   _split_linesz)DropShorterLongHelpFormatter._split_lines  s<    
 OO%DLLtzz|U;< &r/   )rV   r   r   r   r   r   )r   r   r   r   )r   r   r   rt   r   z	list[str])r   r   r   r   r.   r   r   r   r   s   @r-   r   r     s    *&>r/   r   c                  R     e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 	 	 d fdZ	 	 	 	 	 	 ddZ xZS )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.
    c               L    t        |   ||dg|i | || _        || _        y )Nr   )r   r.   
ini_option	ini_value)	r(   r   r7   r   r   r   rV   r   r   s	           r-   r.   zOverrideIniAction.__init__  s.     	qB4B6B$"r/   c                    t        || j                  d       t        |dd       }|g }|j                  | j                   d| j
                          t        |d|       y )NToverride_inir   )setattrr7   re   rg   r   r   )r(   r   rO   rV   r   current_overridess         r-   __call__zOverrideIniAction.__call__  s_     		499d+#I~tD$ "  DOO#4Adnn5E!FG	>+<=r/   r1   )r   r   r7   r   r   zint | str | Noner   r   r   r   r   r   )r   zargparse.ArgumentParserrO   r   r   r   )r   r   r   r   r.   r   r   r   s   @r-   r   r     sm     #'	#%# #  	# # # 
#>'> &> 
>r/   r   )rz   zRLiteral['string', 'paths', 'pathlist', 'args', 'linelist', 'bool', 'int', 'float']r   r   )!
__future__r   rR   collections.abcr   r   rP   rc   r   typingr   r   r   r	   
exceptionsr   _pytest._ior   _pytest.compatr   _pytest.deprecatedr   r$   r   rv   r   r    ArgumentParserr   HelpFormatterr   Actionr   rl   r/   r-   <module>r     s    "  $ $ 	 
      "  ! -  l, l, l,^ 		*"6 "6J9. 9.x4822 4@48#9#9 4n"> ">r/   