
    Z[tj                     <   d dl Z d dlmZ d dlmZ d dlmZmZ ddlmZm	Z	m
Z
mZ ddlmZmZmZmZ dee   d	efd
Z G d de      Z G d de      Z G d de      Z G d de      Zdee   d	eee   ee   f   fdZdedef   d	eeef   fdZdedz  ded	efdZy)    N)Callable)copy)Anycast   )	Annotatedget_args
get_originget_type_hints)ArgumentInfo
OptionInfoParameterInfo	ParamMeta
param_typereturnc                 F    | t         u ry| t        u ryd| j                   dS )Nz`Option`z
`Argument``)r   r   __name__)r   s    t/home/cube/projects/richard/traning coach/task-12-independent-verification-r8/tests/profile-test-deps/typer/utils.py_param_type_to_user_stringr   
   s0     Z	|	#z""#1%%    c                   J    e Zd ZU eed<   ee   ed<   dedee   fdZdefdZy)#AnnotatedParamWithDefaultValueErrorargument_namer   c                      || _         || _        y Nr   r   selfr   r   s      r   __init__z,AnnotatedParamWithDefaultValueError.__init__       *$r   r   c                 P    t        | j                        }| d| j                  dS )Nz0 default value cannot be set in `Annotated` for z). Set the default value with `=` instead.)r   r   r   r   param_type_strs     r   __str__z+AnnotatedParamWithDefaultValueError.__str__   s5    3DOOD &&))RT	
r   N	r   
__module____qualname__str__annotations__typer   r    r%    r   r   r   r      7    ]##%c %tM7J %
 
r   r   c                   d    e Zd ZU eed<   ee   ed<   ee   ed<   dedee   dee   fdZdefdZy)"MixedAnnotatedAndDefaultStyleErrorr   annotated_param_typedefault_param_typec                 .    || _         || _        || _        y r   r   r0   r1   )r   r   r0   r1   s       r   r    z+MixedAnnotatedAndDefaultStyleError.__init__+   s     +$8!"4r   r   c                     t        | j                        }t        | j                        }d| d}| j                  | j                  u r|dz  }n	|d| dz  }|d| j                  z  }|S )NzCannot specify z in `Annotated` andz default value z as a default valuez together for )r   r0   r1   r   )r   annotated_param_type_strdefault_param_type_strmsgs       r   r%   z*MixedAnnotatedAndDefaultStyleError.__str__5   s    #=d>W>W#X !;D<S<S!T 899LM$$(?(??##CQ-..ABBC 2 2566
r   Nr&   r,   r   r   r/   r/   &   sU    }--]++55 #=15 !/	5	 	r   r/   c                   0    e Zd ZU eed<   defdZdefdZy)MultipleTyperAnnotationsErrorr   c                     || _         y r   r   )r   r   s     r   r    z&MultipleTyperAnnotationsError.__init__D   s
    *r   r   c                      d| j                   S )Nz8Cannot specify multiple `Annotated` Typer arguments for r<   )r   s    r   r%   z%MultipleTyperAnnotationsError.__str__G   s    &&)+	
r   N)r   r'   r(   r)   r*   r    r%   r,   r   r   r:   r:   A   s     +c +
 
r   r:   c                   J    e Zd ZU eed<   ee   ed<   dedee   fdZdefdZy)"DefaultFactoryAndDefaultValueErrorr   r   c                      || _         || _        y r   r   r   s      r   r    z+DefaultFactoryAndDefaultValueError.__init__R   r!   r   r   c                 6    t        | j                        }d| S )NzBCannot specify `default_factory` and a default value together for )r   r   r#   s     r   r%   z*DefaultFactoryAndDefaultValueError.__str__V   s%    3DOOD"#%	
r   Nr&   r,   r   r   r?   r?   N   r-   r   r?   base_annotationc                     t        |       t        ur| g fS t        |       ^} }| |D cg c]  }t        |t              r| c}fS c c}w r   )r
   r   r	   
isinstancer   )rB   maybe_typer_annotations
annotations      r   (_split_annotation_from_typer_annotationsrG   ^   sc     /")3""080I-O-11Jj-0 	1   s   Afunc.c                    t        j                  | d      }t        |       }i }|j                  j	                         D ]  }t        |j                        \  }}t        |      dkD  rt        |j                        |j                  }|r|\  }t        |j                  t              r4t        |j                  t        |      t        |j                              t        |      }t        |t               rF|j                  dur8t#        t$        |j                        g|j&                  xs d|_        d|_
        |j                  dur t)        t        |      |j                        |j                  |j*                  ur|j                  |_
        |}n|j                  |v r||j                     }t        |t              ret        |      }|j                  du r|j,                  r|j,                  |_
        n,|j,                  r t/        |j                  t        |            |}t1        |j                  ||	      ||j                  <    |S )
NT)eval_strr   r3   .r,   )r   r   r   )namedefaultrF   )inspect	signaturer   
parametersvaluesrG   rF   lenr:   rK   rL   rD   r   r/   r+   r   r   r   r)   param_declsr   emptydefault_factoryr?   r   )	rH   rN   
type_hintsparamsparamrF   typer_annotationsrL   parameter_infos	            r   get_params_from_functionrZ   k   s   !!$6I%JF%%,,.(P)
%
%  !A%/

;;--0^ %--78"'**)-n)='+EMM':  ".1N >:6"**#5 n445.$006B.* *-& %%S09#N3"'**  }}EKK/ */&$GZZ:%#EJJ/Jg}-!']N %%,1O1O)7)G)G&//8"'**n9M  %G&W
uzzQ /V Mr   env_var_valuerL   c                 B    | |S | j                         }|dv ry|dv ry|S )N)yyesttrueon1T)nnoffalseoff0F)lower)r[   rL   values      r   parse_boolean_env_varrk      s8    !E4455Nr   ) rM   collections.abcr   r   typingr   r   _typingr   r	   r
   r   modelsr   r   r   r   r+   r)   r   	Exceptionr   r/   r:   r?   tuplelistrG   dictrZ   boolrk   r,   r   r   <module>ru      s     $   D D F F	&4+> 	&3 	&
) 
  6

I 


 
 
#Y

49d=))*
O8CH#5 O$sI~:N Odt d t r   