
    gS                        d Z ddlmZ ddlZddlmZ d Zd Zd'dZ G d d	e      Z	 e	d
e
fi       Zee_        de_         edfdZedfdZedfdZedfdZefdZefdZ G d d      Zd Zd Z G d d      Z G d d      Z e       Z G d de      Z e       Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Z eeee fD ]#  Z!d%jE                  e!j                  &      e!_         % [!y)(zDefines experimental extensions to the standard "typing" module that are
supported by the mypy typechecker.

Example usage:
    from mypy_extensions import TypedDict
    )AnyN)_type_checkc                     	 t        j                  d      j                  d   dvrt        d      	 y# t        t
        f$ r Y yw xY w)N   __name__)abc	functoolstypingz4TypedDict does not support instance and class checksF)sys	_getframe	f_globals	TypeErrorAttributeError
ValueError)clsothers     D/var/www/openai/venv/lib/python3.12/site-packages/mypy_extensions.py_check_failsr      sW    ==%%j19WWRSS X
  J' s   /3 AAc                     t        |i |S N)dict)r   argskwargss      r   	_dict_newr      s           c                    |j                  dd      }||}n|rt        d      t        |      |d}	 t        j                  d      j
                  j                  dd      |d<   t        |d	|      S # t        t        f$ r Y w xY w)
NtotalTz@TypedDict takes either a dict or keyword arguments, but not both)__annotations__	__total__r   r   __main__
__module__ )
popr   r   r   r   r   getr   r   _TypedDictMeta)r   	_typename_fieldsr   r   nss         r   _typeddict_newr)      s    JJw%E	 ( ) 	) "']	?B==+5599*jQ< )R,, J' s   2A3 3BBc                   (     e Zd Zd fd	ZexZZ xZS )r%   c           	         |dk(  rt         nt        |d<   t        t        |   | |t
        f|      }|j                  di       }d}|j                         D 	ci c]  \  }}	|t        |	|       }}}	|D ]-  }
|j                  |
j                  j                  di              / ||_        t        |d      s||_        |S c c}	}w )N	TypedDict__new__r   z?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typer   )r)   r   superr%   r-   r   r$   itemsr   update__dict__r   hasattrr   )r   namebasesr(   r   tp_dictannsmsgntpbase	__class__s              r   r-   z_TypedDictMeta.__new__1   s     +/+*=994S$Lvv',O59ZZ\B\EAr;r3''\BDKK))*;R@A "&w, %G Cs   C )T)r   r!   __qualname__r-   r   __instancecheck____subclasscheck____classcell__)r;   s   @r   r%   r%   0   s    ( -98)r   r%   r,   a  A simple typed name space. At runtime it is equivalent to a plain dict.

    TypedDict creates a dictionary type that expects all of its
    instances to have a certain set of keys, with each key
    associated with a value of a consistent type. This expectation
    is not checked at runtime but is only enforced by typecheckers.
    Usage::

        Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})
        a: Point2D = {'x': 1, 'y': 2, 'label': 'good'}  # OK
        b: Point2D = {'z': 3, 'label': 'bad'}           # Fails type check
        assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')

    The type info could be accessed via Point2D.__annotations__. TypedDict
    supports two additional equivalent forms::

        Point2D = TypedDict('Point2D', x=int, y=int, label=str)

        class Point2D(TypedDict):
            x: int
            y: int
            label: str

    The latter syntax is only supported in Python 3.6+, while two other
    syntax forms work for 3.2+
    c                     | S )zA normal positional argumentr"   typer3   s     r   ArgrC   k       Kr   c                     | S )z*A positional argument with a default valuer"   rA   s     r   
DefaultArgrF   p   rD   r   c                     | S )zA keyword-only argumentr"   rA   s     r   NamedArgrH   u   rD   r   c                     | S )z,A keyword-only argument with a default valuer"   rA   s     r   DefaultNamedArgrJ   z   rD   r   c                     | S )z*A *args-style variadic positional argumentr"   rB   s    r   VarArgrM      rD   r   c                     | S )z*A **kwargs-style variadic keyword argumentr"   rL   s    r   KwArgrO      rD   r   c                       e Zd Zy)NoReturnN)r   r!   r<   r"   r   r   rQ   rQ      s    r   rQ   c                     | S r   r"   )r   s    r   traitrS      s    Jr   c                      d S )Nc                     | S r   r"   )xs    r   <lambda>zmypyc_attr.<locals>.<lambda>   s    Qr   r"   )attrskwattrss     r   
mypyc_attrrZ      s    r   c                       e Zd Zd Zd Zy)_FlexibleAliasClsAppliedc                     || _         y r   val)selfr_   s     r   __init__z!_FlexibleAliasClsApplied.__init__   s	    r   c                     | j                   S r   r^   r`   r   s     r   __getitem__z$_FlexibleAliasClsApplied.__getitem__   s    xxr   N)r   r!   r<   ra   rd   r"   r   r   r\   r\      s    r   r\   c                       e Zd Zd Zy)_FlexibleAliasClsc                     t        |d         S )N)r\   rc   s     r   rd   z_FlexibleAliasCls.__getitem__   s    'R11r   N)r   r!   r<   rd   r"   r   r   rf   rf      s    2r   rf   c                       e Zd Zd Zy)_NativeIntMetac                 "    t        |t              S r   )
isinstanceint)r   insts     r   r=   z _NativeIntMeta.__instancecheck__   s    $$$r   N)r   r!   r<   r=   r"   r   r   rj   rj      s    %r   rj   c                       e Zd ZdefdZy)i64r   c                 @    |t         urt        ||      S t        |      S r   	_sentinelrm   r   rV   r:   s      r   r-   zi64.__new__       y q$<1vr   Nr   r!   r<   rs   r-   r"   r   r   rp   rp          y r   rp   )	metaclassc                       e Zd ZdefdZy)i32r   c                 @    |t         urt        ||      S t        |      S r   rr   rt   s      r   r-   zi32.__new__   ru   r   Nrv   r"   r   r   rz   rz      rw   r   rz   c                       e Zd ZdefdZy)i16r   c                 @    |t         urt        ||      S t        |      S r   rr   rt   s      r   r-   zi16.__new__   ru   r   Nrv   r"   r   r   r}   r}      rw   r   r}   c                       e Zd ZdefdZy)u8r   c                 @    |t         urt        ||      S t        |      S r   rr   rt   s      r   r-   z
u8.__new__   ru   r   Nrv   r"   r   r   r   r      rw   r   r   a/  A native fixed-width integer type when used with mypyc.

        In code not compiled with mypyc, behaves like the 'int' type in these
        runtime contexts:

        * {name}(x[, base=n]) converts a number or string to 'int'
        * isinstance(x, {name}) is the same as isinstance(x, int)
        )r3   r   )#__doc__r
   r   r   r   r   r   r)   rB   r%   r   r,   r   r!   rC   rF   rH   rJ   rM   rO   rQ   rS   rZ   r\   rf   FlexibleAliasrj   objectrs   rp   rz   r}   r   	_int_typeformatr"   r   r   <module>r      sN    
 !-$9T 90 ;4		  
 B t 
 d 
 D 
 4 
  
     2 2
 "#%T %
 H	N N N >  c3"I	 F	**F+  # r   