o
    #i                     @  s6  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 d4ddZd4ddZd4ddZd4ddZd4ddZd4ddZd4ddZejfZ de!d< ej"dkr}g e ejR Z d5d#d$Z#ed%d&d6d'd(Z$d7d+d,Z%dd-d8d2d3Z&dS )9    )annotationsN)AnyTypeVarIterablecast)abc)TypeIsRequired	Annotatedget_args
get_origin   )	lru_cache   )InheritsGeneric)is_uniontyptypereturnboolc                 C     t | tkS N)r   r
   r    r   U/var/www/html/flask_server/venv/lib/python3.10/site-packages/openai/_utils/_typing.pyis_annotated_type      r   c                 C  s   t | p| tkS r   )r   listr   r   r   r   is_list_type   s   r   c                 C  s*   t | p| }|tjkp|tjkp|tjkS r   )r   typing_extensionsSequencetyping_c_abcr   originr   r   r   is_sequence_type   s   r%   c                 C  s   t | p| }|tkp|tjkS )z)If the given type is `typing.Iterable[T]`)r   r   r"   r#   r   r   r   is_iterable_type"   s   r&   c                 C  s   t t| S r   )	_is_unionr   r   r   r   r   is_union_type(   r   r(   c                 C  r   r   )r   r	   r   r   r   r   is_required_type,   r   r)   c                 C  r   r   )r   r   r   r   r   r   
is_typevar0   s   r*   z1tuple[type[typing_extensions.TypeAliasType], ...]_TYPE_ALIAS_TYPES)      tpr   'TypeIs[typing_extensions.TypeAliasType]c                C  s
   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+   )r.   r   r   r   is_type_alias_type;   s   
r1   i  )maxsizec                 C  s*   t | st| rtttt| d S | S )Nr   )r)   r   strip_annotated_typer   r   r   r   r   r   r   r3   K   s   r3   indexintc              
   C  sJ   t | }ztt|| W S  ty$ } ztd|  d| d|d }~ww )NzExpected type z" to have a type argument at index z but it did not)r   r   r   
IndexErrorRuntimeError)r   r4   argserrr   r   r   extract_type_argS   s   r:   )failure_messagegeneric_basestuple[type, ...]r;   
str | Nonec                C  s   t tt| p| }||v rt| |S t|trGd}|jD ]}|j|v r'|} nq|du r7td| d| dt||}t	|rEt| |S |S t|pQd| 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   r:   r0   r   __orig_bases__
__origin__r7   r*   )r   r<   r4   r;   clstarget_base_classbase	extractedr   r   r   extract_type_var_from_base[   s.   





	rF   )r   r   r   r   )r.   r   r   r/   )r   r   r   r   )r   r   r4   r5   r   r   )
r   r   r<   r=   r4   r5   r;   r>   r   r   )'
__future__r   sysr!   r   r   r   r   r   collectionsr   r"   r   r	   r
   r   r   _utilsr   _typesr   _compatr   r'   r   r   r%   r&   r(   r)   r*   TypeAliasTyper+   __annotations__version_infor1   r3   r:   rF   r   r   r   r   <module>   s4    









