
    h                    r   U d dl mZ d dlZd dlZd dlZd dlmZmZmZmZ d dl	m
Z d dlmZmZmZmZmZ ddlmZ dd	lmZ dd
lmZ ddZddZddZddZddZddZej<                  fZde d<   ejB                  dk\  rg eej<                  ZddZ" ed      dd       Z#ddZ$dd	 	 	 	 	 	 	 	 	 ddZ%y)     )annotationsN)AnyTypeVarIterablecast)abc)TypeIsRequired	Annotatedget_args
get_origin   )	lru_cache   )InheritsGeneric)is_unionc                &    t        |       t        k(  S N)r   r   typs    Q/var/www/Befach/backend/env/lib/python3.12/site-packages/openai/_utils/_typing.pyis_annotated_typer      s    c?i''    c                .    t        |       xs | t        k(  S r   )r   listr   s    r   is_list_typer      s    sO"st++r   c                \    t        |       xs | }|t        k(  xs |t        j                  k(  S )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                *    t        t        |             S r   )	_is_unionr   r   s    r   is_union_typer#   #   s    Z_%%r   c                &    t        |       t        k(  S r   )r   r
   r   s    r   is_required_typer%   '   s    c?h&&r   c                &    t        |       t        k(  S r   )typer   r   s    r   
is_typevarr(   +   s     9r   z1tuple[type[typing_extensions.TypeAliasType], ...]_TYPE_ALIAS_TYPES)      c               "    t        | t              S )zReturn whether the provided argument is an instance of `TypeAliasType`.

    ```python
    type Int = int
    is_type_alias_type(Int)
    # > True
    Str = TypeAliasType("Str", str)
    is_type_alias_type(Str)
    # > True
    ```
    )
isinstancer)   )tps    r   is_type_alias_typer/   6   s     b+,,r   i  )maxsizec                |    t        |       st        |       r%t        t        t        t        |       d               S | S )Nr   )r%   r   strip_annotated_typer   r'   r   r   s    r   r2   r2   F   s2     1# 6#Dx}Q/?$@AAJr   c                    t        |       }	 t        t        ||         S # t        $ r}t	        d|  d| d      |d }~ww xY w)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_argr9   N   sU    C=DtD$u+&& t^C50RSXRYYhijpssts     	A<A)failure_messagec               b   t        t        t        |       xs |       }||v rt        | |      S t	        |t
              r^d}|j                  D ]  }|j                  |v s|} n |t        d| d| d      t        ||      }t        |      rt        | |      S |S t        |xs d| d|        )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   r9   r-   r   __orig_bases__
__origin__r5   r(   )r   generic_basesr6   r:   clstarget_base_classbase	extracteds           r   extract_type_var_from_baserD   V   s    4 vz#-#
.C
mU++ #'(,&&D-/$(! '
 $u1-D  %%6>	i  $C//
m,[\a[bbghkgl*m
nnr   )r   r'   returnbool)r.   r   rE   z'TypeIs[typing_extensions.TypeAliasType])r   r'   rE   r'   )r   r'   r6   intrE   r'   )
r   r'   r?   ztuple[type, ...]r6   rG   r:   z
str | NonerE   r'   )&
__future__r   systypingtyping_extensionsr   r   r   r   collectionsr   r   r	   r
   r   r   r   _utilsr   _typesr   _compatr   r"   r   r   r    r#   r%   r(   TypeAliasTyper)   __annotations__version_infor/   r2   r9   rD    r   r   <module>rT      s    " 
   / / %   $ +(,;&'  IZHgHgGi D iwB+BV-A-AB-  4 t #'Ao	Ao $Ao 	Ao
  Ao 
Aor   