
    хi                        S SK Jr  S SKJrJrJrJr  S SKJr	  S SK
JrJrJrJr  SSKJr  SSKJr  SS jrSS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jrSS.         SS jjrg)    )annotations)AnyTypeVarIterablecast)abc)Required	Annotatedget_args
get_origin   )InheritsGeneric)is_unionc                &    [        U 5      [        :H  $ N)r   r
   typs    O/home/james-whalen/.local/lib/python3.13/site-packages/openai/_utils/_typing.pyis_annotated_typer      s    c?i''    c                8    [        U 5      =(       d    U [        :H  $ r   )r   listr   s    r   is_list_typer      s    sO"st++r   c                p    [        U 5      =(       d    U nU[        :H  =(       d    U[        R                  :H  $ )z)If the given type is `typing.Iterable[T]`)r   r   _c_abc)r   origins     r   is_iterable_typer      s)    _#FX:6??!::r   c                *    [        [        U 5      5      $ r   )	_is_unionr   r   s    r   is_union_typer       s    Z_%%r   c                &    [        U 5      [        :H  $ r   )r   r	   r   s    r   is_required_typer"      s    c?h&&r   c                &    [        U 5      [        :H  $ r   )typer   r   s    r   
is_typevarr%   !   s     9r   c                    [        U 5      (       d  [        U 5      (       a%  [        [        [        [        U 5      S   5      5      $ U $ )Nr   )r"   r   strip_annotated_typer   r$   r   r   s    r   r'   r'   (   s8     1# 6 6#Dx}Q/?$@AAJr   c                    [        U 5      n [        [        X!   5      $ ! [         a  n[	        SU  SU S35      UeS nAff = f)NzExpected type z" to have a type argument at index z but it did not)r   r   r$   
IndexErrorRuntimeError)r   indexargserrs       r   extract_type_argr.   /   sS    C=DtD$+&& t^C50RSXRYYhijpssts    
A<AN)failure_messagec                  [        [        [        U 5      =(       d    U 5      nXA;   a  [        X5      $ [	        U[
        5      (       af  SnUR                   H  nUR                  U;   d  M  Un  O   Uc  [        SU SU S35      e[        XR5      n[        U5      (       a  [        X5      $ U$ [        U=(       d    SU SU  35      e)a  Given a type like `Foo[T]`, returns the generic type variable `T`.

This also handles the case where a concrete subclass is given, e.g.
```py
class MyResponse(Foo[bytes]):
    ...

extract_type_var(MyResponse, bases=(Foo,), index=0) -> bytes
```

And where a generic subclass is given:
```py
_T = TypeVar('_T')
class MyResponse(Foo[_T]):
    ...

extract_type_var(MyResponse[bytes], bases=(Foo,), index=0) -> bytes
```
NzFCould not find the generic base class;
This should never happen;
Does z inherit from one of z ?z/Could not resolve inner type variable at index z for )
r   objectr   r.   
isinstancer   __orig_bases__
__origin__r*   r%   )r   generic_basesr+   r/   clstarget_base_classbase	extracteds           r   extract_type_var_from_baser:   7   s    4 vz#-#
.C
++ #''(,&&D-/$(! '
 $u1-D  %%6>	i   $C//
m,[\a[bbghkgl*m
nnr   )r   r$   returnbool)r   r$   r;   r$   )r   r$   r+   intr;   r$   )
r   r$   r5   ztuple[type, ...]r+   r=   r/   z
str | Noner;   r$   )
__future__r   typingr   r   r   r   collectionsr   r   typing_extensionsr	   r
   r   r   _typesr   _compatr   r   r   r   r   r    r"   r%   r'   r.   r:    r   r   <module>rE      s    " / / % G G $ +(,;&' t #'Ao	Ao $Ao 	Ao
  Ao 
Aor   