
    h]                       S r SSKJr  SSKrSSKrSSKrSSKrSSKJrJ	r	J
r
JrJrJr  SSKrSSKJr  SSKJr  SSKJrJrJrJrJrJrJrJrJrJr  SS	KJr  SS
K J!r!  \" S5      r"\SSSSSSSSSSS.
                       SS jj5       r#\SSSSSSSSSS.	                       SS jj5       r#\SSSSSSSSSSS.
                       SS jj5       r#\SSSSSSSSSS.	                       SS jj5       r#SSSSSSSSSSS.
                       SS jjr#\SSSSSSSSS.                   S S jj5       r$\SSSSSSSSS.                   S!S jj5       r$SSSSSSSSS.                   S"S jjr$SSS.                       S#S jjr%g)$zCore public API.    )annotationsN)CallableLiteralSequenceTypeVarcastoverload)	Annotated   )	_argparse)
_argparse_formatter
_arguments_calling_fields_parsers	_resolver
_singleton_strings_unsafe_cacheconf)TypeForm)ConstructorRegistryOutTFT)
progdescriptionargsdefaultreturn_unknown_argsuse_underscoresconsole_outputsadd_helpconfigregistryc       
            g N fr   r   r   r   r   r   r    r!   r"   r#   s              C/home/james-whalen/.local/lib/python3.13/site-packages/tyro/_cli.pyclir*   (   s         )	r   r   r   r   r   r    r!   r"   r#   c       
            g r%   r&   r'   s              r)   r*   r*   9   s     !r+   c       
            g r%   r&   r'   s              r)   r*   r*   J   s    " r+   c       
            g r%   r&   r'   s              r)   r*   r*   ^   s    " !r+   c       
           [         R                  " 5         [        R                  " U(       a  SOS5         [	        U 4UUUUSUUUUU	U
S.UD6nSSS5        [         R                  " 5         U(       a(  [        W[        5      (       d   eUS   nU" 5       US   4$ [        [        / [        4   W5      nU" 5       $ ! , (       d  f       Nr= f)a  Generate a command-line interface from type annotations and populate the target with arguments.

:func:`cli()` is the core function of tyro. It takes a type-annotated function or class
and automatically generates a command-line interface to populate it from user arguments.

Two main usage patterns are supported:

1. With a function (CLI arguments become function parameters):

   .. code-block:: python

      import tyro

      def main(a: str, b: str) -> None:
          print(a, b)

      if __name__ == "__main__":
          tyro.cli(main)  # Parses CLI args, calls main() with them

2. With a class (CLI arguments become object attributes):

   .. code-block:: python

      from dataclasses import dataclass
      from pathlib import Path

      import tyro

      @dataclass
      class Config:
          a: str
          b: str

      if __name__ == "__main__":
          config = tyro.cli(Config)  # Parses CLI args, returns populated AppConfig
          print(f"Config: {config}")

Args:
    f: The function or type to populate from command-line arguments. This must have
        type-annotated inputs for tyro to work correctly.
    prog: The name of the program to display in the help text. If not specified, the
        script filename is used. This mirrors the argument from
        :py:class:`argparse.ArgumentParser()`.
    description: The description text shown at the top of the help output. If not
        specified, the docstring of `f` is used. This mirrors the argument from
        :py:class:`argparse.ArgumentParser()`.
    args: If provided, parse arguments from this sequence of strings instead of
        the command line. This is useful for testing or programmatic usage. This mirrors
        the argument from :py:meth:`argparse.ArgumentParser.parse_args()`.
    default: An instance to use for default values. This is only supported if ``f`` is a
        type like a dataclass or dictionary, not if ``f`` is a general callable like a
        function. This is useful for merging CLI arguments with values loaded from
        elsewhere, such as a config file.
    return_unknown_args: If True, returns a tuple of the output and a list of unknown
        arguments that weren't consumed by the parser. This mirrors the behavior of
        :py:meth:`argparse.ArgumentParser.parse_known_args()`.
    use_underscores: If True, uses underscores as word delimiters in the help text
        instead of hyphens. This only affects the displayed help; both underscores and
        hyphens are treated equivalently during parsing. The default (False) follows the
        GNU style guide for command-line options.
        https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
    console_outputs: If set to False, suppresses parsing errors and help messages.
        This is useful in distributed settings where tyro.cli() is called from multiple
        workers but console output is only desired from the main process.
    add_help: Add a -h/--help option to the parser. This mirrors the argument from
        :py:class:`argparse.ArgumentParser()`.
    config: A sequence of configuration marker objects from :mod:`tyro.conf`. This
        allows applying markers globally instead of annotating individual fields.
        For example: ``tyro.cli(Config, config=(tyro.conf.PositionalRequiredArgs,))``
    registry: A :class:`tyro.constructors.ConstructorRegistry` instance containing custom
        constructor rules.

Returns:
    If ``f`` is a type (like a dataclass), returns an instance of that type populated
    with values from the command line. If ``f`` is a function, calls the function with
    arguments from the command line and returns its result. If ``return_unknown_args``
    is True, returns a tuple of the result and a list of unused command-line arguments.
_-Fr   r   r   r   return_parserr   r   r    r!   r"   r#   Nr   r   )
r   clear_cacher   delimeter_context	_cli_impl
isinstancetupler   r   r   )r(   r   r   r   r   r   r   r    r!   r"   r#   deprecated_kwargsoutputrun_with_args_from_clis                 r)   r*   r*   r   s    @ 		#	#?C	D
# 3++
  
 
E$ &%((((!'%'22!%hr4x&8&!A%''5 
E	Ds   B::
C)r   r   r   r   r    r!   r"   r#   c                   g r%   r&   	r(   r   r   r   r   r    r!   r"   r#   s	            r)   
get_parserr>           "r+   c                   g r%   r&   r=   s	            r)   r>   r>      r?   r+   c                   [         R                  " U(       a  SOS5         [        [        R                  [        U UUSUSSUUUUUS95      sSSS5        $ ! , (       d  f       g= f)a  Get the :py:class:`argparse.ArgumentParser` object generated under-the-hood by
:func:`tyro.cli`. Useful for tools like ``sphinx-argparse``, ``argcomplete``, etc.

For tab completion, we recommend using :func:`tyro.cli`'s built-in
``--tyro-write-completion`` flag.

Args:
    f: The function or type to populate from command-line arguments.
    prog: The name of the program to display in the help text.
    description: The description text shown at the top of the help output.
    default: An instance to use for default values.
    use_underscores: If True, uses underscores as word delimiters in the help text.
    console_outputs: If set to False, suppresses parsing errors and help messages.
    add_help: Add a -h/--help option to the parser. This mirrors the argument from
        :py:class:`argparse.ArgumentParser()`.
    config: A sequence of configuration marker objects from :mod:`tyro.conf`.
    registry: A :class:`tyro.constructors.ConstructorRegistry` instance containing custom
        constructor rules.
r0   r1   NTFr2   )r   r5   r   argparseArgumentParserr6   r=   s	            r)   r>   r>     sa    B 
	#	#?C	D##'"$) / /!!
 
E	D	Ds   ,A
A$)r   r#   c       
        `  ^+ U	b  [        U	5      S:  a  [        U /U	Q7   n SU;   a  [        R                  " SSS9  US   nUR	                  SS5      (       a(  [
        R                  U    n [        R                  " S	SS9  Uc  [        R                  OUn[        R                  R                  U 5      n [        R                  " [        [        U 5      U5      (       dn  [        [         R"                  [         R$                  " 5       5      n[         R&                  " S
[(        R*                  [        [        U 5      U4/SS9n U " U5      nSnOSnUc  [-        [.        R0                  SS 5      O
[-        U5      n0 n[3        U5       H  u  nnUR5                  S5      (       d  M  SU;   a8  UR7                  S5      u  nnnS[(        R8                  " USS 5      -   S-   U-   nOS[(        R8                  " USS 5      -   nU(       a&  UU;   a   UU   U:w  a  [;        SUU   -   S-   U-   5      eUUU'   UUU'   M     SnSn[        U5      S:  aE  US   R=                  SS5      S:H  n[        U5      S:  =(       a    US   R=                  SS5      S:H  nSnSnU(       d  U(       a  US   nU(       a  [>        R@                  " US   5      nU(       d  U(       d  U(       a  S[B        l"        OS[B        l"        U
b@  U
   [F        RH                  RK                  U [M        5       U[M        5       USSUS9nSSS5        O4[F        RH                  RK                  U [M        5       U[M        5       USSUS9n[N        RP                  " 5          [N        RR                  " U[N        RT                  SUS9nWUl+        UUl,        UUl-        UUl.        UR_                  USS9  U(       a  S[B        l"        UsSSS5        $ U(       d  U(       a  S[B        l"        US;   d
   SU 35       eU(       aR  U[>        R@                  " S5      :w  a8  Uc   eURa                  [b        Rd                  " UUSURf                   3S95        O,[i        [b        Rd                  " UUSURf                   3S95        [.        Rj                  " 5         U(       a  URm                  US9u  nnOSnURo                  US9n[q        U5      nSSS5        U(       aD  WRs                  5        VVs0 s H'  u  nnUR=                  [(        R*                  S5      U_M)     nnn [t        Rv                  " U WUWSS 9u  n n![        WR                  5       W!-
  5      S:X  d   S8UR                  5        S9U! 35       eU(       a  W m+U+4S: jn U(       a0  Wc   S;5       eU Vs/ s H  nUR	                  UU5      PM     nnW U4$ Wb   S<5       eW $ ! , (       d  f       GN= f! , (       d  f       GN= fs  snnf ! [t        Rx                   Ga  n"SS!K=J>n#J?n$  SS"K@JAn%  SS#KBJCn&  SS$KDJEn'  SS%KFJGn(  SS&K'JHn)  U(       Ga  U#" U)R                  5       SS'9n*U*Ri                  U&" U$" S([        U"R                  [B        R                  5      (       a/  S)R                  U"R                  R                  R                  5      OU"R                   S*U"R                   3/[        [,        [        U"R                  [B        R                  5      (       a!  U"R                  R                  R                  c  / OU'" U(" S+S,9S-9S.U%" U$" S)R                  U"R                  R                  R                  5       S/U"R                  R                  R                   S03U"R                  R                  R                  5      S1S29/WR                  (       a  U'" U(" S+S,9S-9S3URf                   S43/O/ Q5      Q76 S5S6U(" S+S,9S795        [.        Rj                  " S5         Sn"A"GNSn"A"ff = fs  snf )=z2Helper for stitching the `tyro` pipeline together.Nr   default_instancez:`default_instance=` is deprecated! use `default=` instead.   )
stacklevelavoid_subparsersFzN`avoid_subparsers=` is deprecated! use `tyro.conf.AvoidSubcommands[]` instead.dummyT)cls_namefieldsfrozenr   z--=zAmbiguous arguments: z and r0   r1   z--tyro-print-completion   z--tyro-write-completion )markersr   parent_classesrE   intern_prefixextern_prefixr!   )r   formatter_classallow_abbrevr!   )force_required_subparsers)bashzshtcshz6Shell should be one `bash`, `zsh`, or `tcsh`, but got tyro_)parsershellroot_prefix)r   )field_name_prefix)ConsoleGroup)Padding)Panel)Rule)Style)THEME)themestderrz [bright_red][bold]Error parsing /z[/bold]:[/bright_red] red)color)stylezArgument helptext:z [bold]z[/bold])r   r   r      )padzFor full helptext, see [bold]z --help[/bold]z[bold]Value error[/bold]left)titletitle_alignborder_stylezParsed z, but only consumed c                 B   > [        T " 5       [        R                  5      $ r%   )getattrr   dummy_field_name)get_wrapped_outs   r)   <lambda>_cli_impl.<locals>.<lambda>m  s    '/"3X5N5NOr+   z,Should have parsed with `parse_known_args()`z&Should have parsed with `parse_args()`)Ulenr
   warningswarngetr   AvoidSubcommandsr   MISSING_NONPROPr   TypeParamResolverresolve_params_and_aliasesr   is_struct_typer   typedataclassesFieldfieldmake_dataclassr   rt   listsysargv	enumerate
startswith	partitionswap_delimetersRuntimeErrorreplacepathlibPathr   USE_RICHr   ParserSpecificationfrom_callable_or_typesetr   ansi_contextTyroArgumentParserTyroArgparseHelpFormatter_parser_specification_parsing_known_args_console_outputs_argsapply
write_textshtabcompleter   printexitparse_known_args
parse_argsvarsitemsr   callable_with_argsInstantiationErrorrich.consoler_   r`   rich.paddingra   
rich.panelrb   	rich.rulerc   
rich.stylerd   re   as_rich_themer7   argArgumentDefinitionjoinloweredname_or_flagsmessagehelpmetavarr!   keys),r(   r   r   r   r   r3   r   r    r!   r"   r#   r9   default_instance_internaldummy_fielddummy_wrappedmodified_argsindexr   r0   valfixedprint_completionwrite_completioncompletion_shellcompletion_target_pathparser_specr[   	namespaceunknown_argsvalue_from_prefixed_field_namekvget_outconsumed_keywordser_   r`   ra   rb   rc   rd   re   consoleru   s,                                              @r)   r6   r6   D  s   0 c&kAoql6l#..HUV	
 $$67/77!!!$	
 '.o
""7  	##>>qAA!!$tQ-1JKK
 &&..T1{KL

 %&&?$@! "&44:D
 %'Mo
s~~d###:--,KCC833CG<<sBSHE833CG<<E&e$+'-*>>H3N   #eU% &: 
4yA~7??348QQINUtAwsC8<UU 	 !+7!(d1g!6+}#
"
 "66LL'"u!:  ! M 	K X 22HHE#56 I 	
 
	)	)	+$77/II	
 (3$%8""1&EB "&J) 
,	+, /"&J# (  
$%'   $:gll3>O$O-999&11NN%.&+FKK=$9 NN%.&+FKK=$9 HHJ&,&=&=4&=&H#I|L))t)4I)-i&s 
,v  7<<>*
>1 IIh//4a7> 	' *

A%-%@%@%* &
""B -2247HHIQN 
05578 9	 N
 !O'W)WW' @LL|))#s3|L$$#M%MM#[ X0 
,	+x*
 && 8 	0($"$.E$7$7$9$GGMMEOPQPUPUWaWtWtEuEuCHHQUU]]%@%@A{|  |A  |A  B  BX  YZ  Yb  Yb  Xcd   (2!%%9V9V'W'W#$55==#5#5#= !# %)u5/A$B$8$+(-/2xx8S8S/T.UU\]^]b]b]j]j]r]r\ssz,{,-EEMM,>,>)* -9%&&" ,2?? -1u57I,J.KFKK=Xf,g)*
 .0!&"> 5 &!&U!3E#%L 	q8N MsE   85W#?A%W5.C9W5	.X;X 5`+#
W25
X`("G;`##`()r(   TypeForm[OutT]r   
None | strr   r   r   None | Sequence[str]r   None | OutTr   Literal[False]r   boolr    r   r!   r   r"   %None | Sequence[conf._markers.Marker]r#   None | ConstructorRegistryreturnr   )r(   r   r   r   r   r   r   r   r   r   r   Literal[True]r   r   r    r   r!   r   r"   r   r#   r   r   tuple[OutT, list[str]])r(   Callable[..., OutT]r   r   r   r   r   r   r   Noner   r   r   r   r    r   r!   r   r"   r   r#   r   r   r   )r(   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r   r   )r(   $TypeForm[OutT] | Callable[..., OutT]r   r   r   r   r   r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r   zOutT | tuple[OutT, list[str]])r(   r   r   r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r   argparse.ArgumentParser)r(   r   r   r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r   r   )r(   r   r   r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r   r   )r(   r   r   r   r   r   r   r   r   r   r3   r   r   r   r    r   r!   r   r"   r   r#   r   r   zEOutT | argparse.ArgumentParser | tuple[Callable[[], OutT], list[str]])&__doc__
__future__r   r   r   r   ry   typingr   r   r   r   r   r	   r   typing_extensionsr
   rO   r   rB   r   r   r   r   r   r   r   r   r   r   _typingr   constructorsr   r   r*   r>   r6   r&   r+   r)   <module>r      s    "   
  G G  ' #    -v 
 "!%*/! 48+/  	
   (    2 ) 
 
  
 "!%! 48+/!! ! 	!
 ! ! '! ! ! ! 2! )! ! 
!  
 "!% */! 48+/  	
   (    2 )  
! 
& 
 "!% ! 48+/!! ! 	!
 ! ! '! ! ! ! 2! )!  !! 
!, "!% %! 48+/|(+|( |( 	|(
 |( |( |( |( |( |( 2|( )|( #|(~ 
 "! 48+/"" " 	"
 " " " " 2" )" " 
" 
 "! 48+/"" " 	"
 " " " " 2" )" " 
"& "! 48+/2
+2

 2
 2
 2
 2
 2
 2
 22
 )2
 2
p  ,0s+s s 	s
 s s s s s s 2s )ssr+   