o
    E6dK                    @  s  U d Z ddlmZ ddlZddlZddlmZ ddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddl%Z%ddl&m'Z' ddl&m(Z( ddl)m*Z* ddlm+Z+ ddl&m,Z, e#d Z-e#d!d"d#Z.e#d$ed%ef d&Z/e#d'd(d&Z0e#d)d*d&Z1e#d+d,d&Z2e#d-d.d&Z3e(j4rdKd3d4Z5ndKd5d4Z5dLd8d9Z6G d:d; d;Z7dMd?d@Z8dNdBdCZ9dOdEdFZ:dPdLdMZ;dQdQdRZ<dRdWdXZ=dSd^d_Z>e#d`dJd&Z?dTdcddZ@dedf ZAdUdldmZBe#dnZCe#doZDG dpdq dqZEdrds ZFedd%dtdVd{d|ZGedd}dtdWd~d|ZGdd}dtdWdd|ZGdXddZH	}dYdZddZI	"d[d\ddZJd[ddZK			d]d^ddZLdd ZMdd ZN			d_d`ddZOG dd dZPdd ZQdd ZR				daddZSdd ZTdbddZUe#ddd&ZVG dd dee. ZWG dd deWe. ZXG dd deWe. ZYe"r#eWZZeWZ[e\Z]e\Z^neY ZZZ]eX Z[Z^dcddZ_G dd dZ`e"r>e\Zane`jbZaG dd dZcddddZddeddńZedfddɄZf	"	dgdhdd҄ZgdiddԄZhdjddׄZidkddڄZj	dldmdd߄ZkdnddZldd ZmG dd de\ZnG dd dee- ZoG dd dee- ZpG dd dee- ZqG dd derZsG dd detZuG dd deudZve"rddlmwZw ewZxnevZxe#dejyd&Zz	}dodpddZ{da|dqd dZ}drddZ~dsddZG dd	 d	eZdldtddZduddZi Zded< dvddZedZ		dwdxddZdyd"d#Zed$Zed%Zeefdzd*d+ZetdZd,d- ZG d.d/ d/ZG d0d1 d1Zd2d3 Zd4d5 Zd{d7d8Zd|d9d:Zd}d>d?Zed@Zd~dDdEZddGdHZdodIdJZdS (  zRoutines to help with the creation, loading and introspection of
modules, classes, hierarchies, attributes, functions, and methods.

    )annotationsNupdate_wrapper)CodeType)Any)Callable)cast)Dict)	FrozenSet)Generic)Iterator)List)Mapping)NoReturn)Optional)overload)Sequence)Set)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )_collections)compat)HAS_CYEXTENSION)Literal   )exc_T_T_coT)	covariant_F.)bound_MPzmemoized_property[Any]_MAz#HasMemoized.memoized_attribute[Any]_HPzhybridproperty[Any]_HMzhybridmethod[Any]objr   returnMapping[str, Any]c                 C  s
   t | S N)inspectget_annotationsr)    r0   rC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\sqlalchemy/util/langhelpers.pyr.   B      
r.   c                 C  s>   t | tr| jdd }nt| dd }|d u rtjS td|S )N__annotations__r+   )
isinstancetype__dict__getgetattrr   
EMPTY_DICTr   )r)   annr0   r0   r1   r.   G   s   

xstrc                 C  s$   |  d} t }||  | S )Nzutf-8)encodehashlibmd5update	hexdigest)r;   mr0   r0   r1   md5_hexX   s   

rC   c                   @  s2   e Zd ZU dZdZded< dddZdddZdS )safe_reraisea  Reraise an exception after invoking some
    handler code.

    Stores the existing exception info before
    invoking so that it is maintained across a potential
    coroutine context switch.

    e.g.::

        try:
            sess.commit()
        except:
            with safe_reraise():
                sess.rollback()

    TODO: we should at some point evaluate current behaviors in this regard
    based on current greenlet, gevent/eventlet implementations in Python 3, and
    also see the degree to which our own asyncio (based on greenlet also) is
    impacted by this. .rollback() will cause IO / context switch to occur in
    all these scenarios; what happens to the exception context from an
    "except:" block if we don't explicitly store it? Original issue was #2703.

    )	_exc_infozdUnion[None, Tuple[Type[BaseException], BaseException, types.TracebackType], Tuple[None, None, None]]rE   r*   Nonec                 C  s   t  | _d S r,   )sysexc_inforE   selfr0   r0   r1   	__enter__      zsafe_reraise.__enter__type_Optional[Type[BaseException]]valueOptional[BaseException]	tracebackOptional[types.TracebackType]r   c                 C  sZ   | j d usJ |d u r| j \}}}|d usJ d | _ ||d | _ |d us(J ||r,   )rE   with_traceback)rJ   rM   rO   rQ   exc_type	exc_valueexc_tbr0   r0   r1   __exit__   s   

zsafe_reraise.__exit__Nr*   rF   )rM   rN   rO   rP   rQ   rR   r*   r   )__name__
__module____qualname____doc__	__slots__r3   rK   rW   r0   r0   r0   r1   rD   _   s   
 

rD   clsType[_T]Iterator[Type[_T]]c                 c  sN    t  }| g}|r%| } | |v rq||  ||   | V  |s	d S d S r,   )setpopaddextend__subclasses__)r^   seenstackr0   r0   r1   walk_subclasses   s   
rh   elementc                 C  s4   t | tr| S zt| W S  ty   d|   Y S w )Nzunprintable element %r)r4   r<   	Exception)ri   r0   r0   r1   string_or_unprintable   s   

rk   	Type[Any]c                 C  s   d dd td| jD S )N c                 s  s    | ]}|  V  qd S r,   )lower).0nr0   r0   r1   	<genexpr>   s    
z(clsname_as_plain_name.<locals>.<genexpr>z([A-Z][a-z]+|SQL))joinrefindallrY   r^   r0   r0   r1   clsname_as_plain_name   s   
rv   instance_or_clsUnion[Type[Any], object]against_methodCallable[..., Any]boolc                 C  s.   t | ts	| j}n| }|j}t||}||kS )z1Return True if the two class methods don't match.)r4   r5   	__class__rY   r8   )rw   ry   Zcurrent_clsmethod_nameZcurrent_methodr0   r0   r1   method_is_overridden   s   

r~   slcsliceTuple[Any, ...]c                 C  s>   g }| j | j| jfD ]}t|dr| }|| q
t|S )zrdecode a slice object as sent to __getitem__.

    takes into account the 2.5 __index__() method, basically.

    	__index__)startstopstephasattrr   appendtuple)r   retr;   r0   r0   r1   decode_slice   s   
r   usedSequence[str]basesIterator[str]c                 '  sj    t | }|D ]+ t ft fddtd}|D ]}||vr+|| |V   nqtd  qd S )Nc                   s    t |  S r,   r<   )ibaser0   r1   <lambda>       z!_unique_symbols.<locals>.<lambda>i  z&exhausted namespace for symbol base %s)ra   	itertoolschainmaprangerc   	NameError)r   r   Zused_setpoolsymr0   r   r1   _unique_symbols   s    
r   fnCallable[[int], Any]rp   intIterator[Any]c                 c  s2    |r|| d @ }| |V  ||N }|sdS dS )z6Call the given function given each nonzero bit from n.r   Nr0   )r   rp   br0   r0   r1   map_bits   s   
r   _FntargetCallable[[_Fn], _Fn]c                   s   d fdd}t | S )z'A signature-matching decorator factory.r   r   r*   c           
        s(  t | st | stdt| }i }t||}ttd|d td|dd  | j	f }t
|dd\}}t||d}|t|d	d
 | j	|d< dt|d v rYd| }nd| }tj| j }|t| || || d| ji ttjt||| j	}	t| d| j|	_| |	_ttt|	| S )Nznot a decoratable functionzTuple[str, ...]r   r      r   r   )r   r   Fgroupedname__zKdef %(name)s%(grouped_args)s:
    return %(target)s(%(fn)s, %(apply_pos)s)
zJdef %(name)s%(grouped_args)s:
    return %(target)s(%(fn)s, %(apply_kw)s)
rY   __func__)r-   
isfunctionismethodrj   r   inspect_getfullargspec!_update_argspec_defaults_into_envr   r   rY   r   dictr@   format_argspec_plusreprrG   modulesrZ   varstypesFunctionType_exec_code_in_envr8   __defaults____wrapped__r   r   )
r   specenvnamesZ	targ_namefn_namemetadatacodemodZ	decoratedr   r0   r1   decorate   sD   



	zdecorator.<locals>.decorateN)r   r   r*   r   r   )r   r   r0   r   r1   	decorator   s   
:r   c                 C  sx   | j r:g }d}| j D ] }t|jdvr%d| }|||< || |d7 }q
|| q
t| }t||d< tj| S | S )zCgiven a FullArgSpec, convert defaults to be symbol names in an env.r   )builtins__builtin__zx%dr   r   )defaultsr5   rZ   r   listr   r   FullArgSpec)r   r   Znew_defaultsr   argr   elemr0   r0   r1   r   6  s   



r   r   Union[str, types.CodeType]r   Dict[str, Any]r   c                 C  s   t | | || S r,   )exec)r   r   r   r0   r0   r1   r   K  s   
r   _PF_TEc                   @  s6   e Zd Z	ddddZdd	 ZdddZdddZdS )PluginLoaderNgroupr<   auto_fnOptional[Callable[..., Any]]c                 C  s   || _ i | _|| _d S r,   )r   implsr   )rJ   r   r   r0   r0   r1   __init__W  s   
zPluginLoader.__init__c                 C  s   | j   d S r,   )r   clearrI   r0   r0   r1   r   ^  rL   zPluginLoader.clearr   r*   r   c                 C  s   || j v r| j |  S | jr| |}|r|| j |< | S t| jD ]}|j|kr6|j| j |< |   S q#td| j|f )NzCan't load plugin: %s:%s)	r   r   r   Zimportlib_metadata_getr   r   loadr   ZNoSuchModuleError)rJ   r   loaderimplr0   r0   r1   r   a  s   



zPluginLoader.load
modulepathobjnamerF   c                   s    fdd}|| j |< d S )Nc                    s4   t  }  ddd  D ]}t| |} qt| S )N.r   )
__import__splitr8   )r   tokenr   r   r0   r1   r   u  s   
z#PluginLoader.register.<locals>.load)r   )rJ   r   r   r   r   r0   r   r1   registert  s   zPluginLoader.registerr,   )r   r<   r   r   )r   r<   r*   r   )r   r<   r   r<   r   r<   r*   rF   )rY   rZ   r[   r   r   r   r   r0   r0   r0   r1   r   V  s    
r   c                 C  sh   zt j}W n ty   t| }|d t|d f Y S w | j}|j}t|j	d | t|j
|@ fS )Nr   r   )r-   CO_VARKEYWORDSAttributeErrorr   r   r{   __code__co_argcountr   co_varnamesco_flags)r   Zco_varkeywordsr   conargsr0   r0   r1   _inspect_func_args~  s   

	r   )_setraiseerrr5   r   Optional[Set[str]]r   Literal[True]Set[str]c                C     d S r,   r0   r^   r   r   r0   r0   r1   get_cls_kwargs  s   r   Fc                C  r   r,   r0   r   r0   r0   r1   r     s   c          	      C  s   |du }|r	t  }|dusJ | jdd}|o$t|tjo$t|jtj}|rCt|\}}|	| |sB|sB|r@t
d|  ddS nd}|rI|rY| jD ]}t||ddu rX nqL|d |S )ae  Return the full set of inherited kwargs for the given `cls`.

    Probes a class's __init__ method, collecting all named arguments.  If the
    __init__ defines a \**kwargs catch-all, then the constructor is presumed
    to pass along unrecognized keywords to its base classes, and the
    collection process is repeated recursively on each of the bases.

    Uses a subset of inspect.getfullargspec() to cut down on method overhead,
    as this is used within the Core typing system to create copies of type
    objects which is a performance-sensitive operation.

    No anonymous tuple arguments please !

    Nr   Fz
given cls z  doesn't have an __init__ method)r   rJ   )ra   r6   r7   r4   r   r   r   r   r   r@   	TypeError	__bases__r   discard)	r^   r   r   toplevelZctrZhas_initr   Zhas_kwcr0   r0   r1   r     s8   




func	List[str]c                 C  s   t | d S )zReturn the set of legal kwargs for the given `func`.

    Uses getargspec so is safe to call for methods, functions,
    etc.

    r   )r   r   )r   r0   r0   r1   get_func_kwargs  s   r   no_self_is_initcompat.FullArgSpecc              	   C  s0  t | rtd|  t | r4|r/|r/t| }t|jdd |j|j	|j
|j|j|jS t| S t | rb|r\|s@| jr\t| j}t|jdd |j|j	|j
|j|j|jS t| jS t | rot| j|ddS t| drzt| jS t| drt | jrt| j|dS td	|  td	|  )
zReturn the argument signature for any callable.

    All pure-Python callables are accepted, including
    functions, methods, classes, objects with __call__;
    builtins and other edge cases like functools.partial() objects
    raise a TypeError.

    zCan't inspect builtin: %sr   NT)r   r   r   __call__)r   zCan't inspect callable: %s)r-   	isbuiltinr   r   r   r   r   argsvarargsvarkwr   
kwonlyargskwonlydefaultsr   r   __self__r   isclassget_callable_argspecr   r   r   )r   r   r   r   r0   r0   r1   r    sR   









r  -Union[Callable[..., Any], compat.FullArgSpec]r   Dict[str, Optional[str]]c              	   C  s  t | r
t| }n| }tj| }t|d |d |d d|d }|d rB|d d }t|d dd |d |d d|d }n|d rOd|d  }|}nd}|}d}|d rf|tttt |d 7 }|d rr|t|d 7 }|d |d  }|r|d| d }	nd}	tj||d |d |	d	d
 d}
|d rtj|dd |d |d |	dd
 d}n|
}|rt||||
||dS t|||dd |
dd |dd |dd dS )a  Returns a dictionary of formatted, introspected function arguments.

    A enhanced variant of inspect.formatargspec to support code generation.

    fn
       An inspectable callable or tuple of inspect getargspec() results.
    grouped
      Defaults to True; include (parens, around, argument) lists

    Returns:

    args
      Full inspect.formatargspec for fn
    self_arg
      The name of the first positional argument, varargs[0], or None
      if the function defines no positional arguments.
    apply_pos
      args, re-written in calling rather than receiving syntax.  Arguments are
      passed positionally.
    apply_kw
      Like apply_pos, except keyword-ish args are passed as keywords.
    apply_pos_proxied
      Like apply_pos but omits the self/cls argument

    Example::

      >>> format_argspec_plus(lambda self, a, b, c=3, **d: 123)
      {'grouped_args': '(self, a, b, c=3, **d)',
       'self_arg': 'self',
       'apply_kw': '(self, a, b, c=c, **d)',
       'apply_pos': '(self, a, b, c, **d)'}

    r   r   r   N   z%s[0]r   r0   c                 S     dt |  S N=r   r;   r0   r0   r1   r   p  r   z%format_argspec_plus.<locals>.<lambda>)formatvaluec                 S  r  r  r   r  r0   r0   r1   r   y  r   )grouped_argsself_arg	apply_posapply_kwapply_pos_proxiedapply_kw_proxied)	callabler   r   inspect_formatargspeclenr   r   r   r   )r   r   r   r   r  r  r  num_defaultsZ	name_argsZdefaulted_valsr  r  r0   r0   r1   r     sv   $
"
	



r   c                 C  sz   | t ju rd}|rdnd}|rdnd}nzt| |dW S  ty2   d}|r(|nd}|r.dnd	}Y nw td|||||d
S )a  format_argspec_plus with considerations for typical __init__ methods

    Wraps format_argspec_plus with error handling strategies for typical
    __init__ cases::

      object.__init__ -> (self)
      other unreflectable (usually C) -> (self, *args, **kwargs)

    z(self)rJ   z() r   z(self, *args, **kwargs)zself, *args, **kwargsz(*args, **kwargs)z*args, **kwargs)r  r  r  r  r  r  )objectr   r   r   r   )methodr   r  r   Zproxiedr0   r0   r1   format_argspec_init  s&   

r  r0   
target_clstarget_cls_sphinx_nameproxy_cls_sphinx_nameclassmethodsmethods
attributesCallable[[_T], _T]c                 C  s   dd }|S )aS  A class decorator indicating attributes should refer to a proxy
    class.

    This decorator is now a "marker" that does nothing at runtime.  Instead,
    it is consumed by the tools/generate_proxy_methods.py script to
    statically generate proxy methods and attributes that are fully
    recognized by typing tools such as mypy.

    c                 S  s   | S r,   r0   ru   r0   r0   r1   r        z&create_proxy_methods.<locals>.decorater0   )r  r   r!  r"  r#  r$  r   r0   r0   r1   create_proxy_methods  s   r'  c                 C  sJ   zt | W S  ty$   | tju rdgdddf Y S dgdddf Y S w )zinspect.getargspec with considerations for typical __init__ methods

    Wraps inspect.getargspec with error handling for typical __init__ cases::

      object.__init__ -> (self)
      other unreflectable (usually C) -> (self, *args, **kwargs)

    rJ   Nr   kwargs)r   r   r   r  r   )r  r0   r0   r1   getargspec_init  s   	
r)  c                 C  s   t | tjr| js| jS | S )zSAdjust the incoming callable such that a 'self' argument is not
    required.

    )r4   r   
MethodTyper  r   )Zfunc_or_clsr0   r0   r1   unbound_method_to_callable  s   r+  additional_kwSequence[Tuple[str, Any]]
to_inspect%Optional[Union[object, List[object]]]
omit_kwargc              	     s6  |du rg}nt |}t  g }t  }d}t|D ]p\}}zt|j}	W n	 ty1   Y qw |	j	r:t
|	j	nd}
|dkr_|	jrF|	j}|
rT||	jd|
   n||	jdd  n| fdd|	jd|
  D  |
r|	j	sxJ |dd t|	j|
 d |	j	D  qg }|fdd|D  |durt|r|d	d t|D  | D ]+\}}||v rqzt| }| ur||kr|d
||f  W q ty   Y qw |r|D ])\}}zt| }| ur||kr|d
||f  W q ty   Y qw djjd|f S )z}Produce a __repr__() based on direct association of the __init__()
    specification vs. same-named attributes present.

    Nr   r   c                   s   g | ]}| fqS r0   r0   ro   r   )missingr0   r1   
<listcomp>      z generic_repr.<locals>.<listcomp>c                 S  s   g | ]\}}||fqS r0   r0   )ro   r   defaultr0   r0   r1   r3    s    c                 3  s     | ]}t t |d V  qd S r,   )r   r8   r1  r/   r0   r1   rq     s    zgeneric_repr.<locals>.<genexpr>c                 S  s   g | ]}t |qS r0   r   )ro   valr0   r0   r1   r3    r4  z%s=%rz%s(%s), )r   to_listr  OrderedDict	enumerater   r   r   r   r   r  r  rd   r   r@   zipr   r8   itemsr   rj   r|   rY   rr   )r)   r,  r.  r0  Zpos_argsZkw_argsZvargsr   Zinspr   Zdefault_lenoutputr   Zdefvalr7  r0   )r2  r)   r1   generic_repr  sv   


r?  c                   @  s6   e Zd ZdZdZdd Zdd Zddd	Zd
d ZdS )portable_instancemethodz_Turn an instancemethod into a (parent, name) pair
    to produce a serializable callable.

    )r   r   r(  __weakref__c                 C  s   | j | j| jdS )Nr   r   r(  rB  rI   r0   r0   r1   __getstate__=  s   z$portable_instancemethod.__getstate__c                 C  s&   |d | _ |d | _|dd| _d S )Nr   r   r(  r0   )r   r   r7   r(  )rJ   stater0   r0   r1   __setstate__D  s   

z$portable_instancemethod.__setstate__r0   c                 C  s   |j | _|j| _|| _d S r,   )r  r   rY   r   r(  )rJ   methr(  r0   r0   r1   r   I  s   
z portable_instancemethod.__init__c                 O  s$   | | j t| j| j|i |S r,   )r@   r(  r8   r   r   )rJ   r   kwr0   r0   r1   r   N  s   z portable_instancemethod.__call__N)r0   )	rY   rZ   r[   r\   r]   rC  rE  r   r   r0   r0   r0   r1   r@  5  s    
r@  c                   s   | h t | j}|rV| } fdd|jD }|D ]}||  | q|jdks1t|ds2q fddt|t	s@|
 n|
|D D ]}||  | qG|s
t  S )a'  Return an unordered sequence of all classes related to cls.

    Traverses diamond hierarchies.

    Fibs slightly: subclasses of builtin types are not returned.  Thus
    class_hierarchy(class A(object)) returns (A, object), not A plus every
    class systemwide that derives from object.

    c                 3  s    | ]	}| vr|V  qd S r,   r0   ro   _Zhierr0   r1   rq   b      z"class_hierarchy.<locals>.<genexpr>r   re   c                   s   g | ]}| vr|qS r0   r0   rH  rJ  r0   r1   r3  k  s
    z#class_hierarchy.<locals>.<listcomp>)r   __mro__rb   r   r   rc   rZ   r   
issubclassr5   re   )r^   processr   r   r   sr0   rJ  r1   class_hierarchyS  s&   





	rP  c                 c  sB    t | }|D ]}| jD ]}||jv r||j| fV   nqqdS )ziterate all the keys and attributes associated
    with a class, without using getattr().

    Does not use getattr() so that class-sensitive
    descriptors (i.e. property.__get__()) are not called.

    N)dirrL  r6   )r^   keyskeyr   r0   r0   r1   iterate_attributesy  s   

rT  
self.proxyc              	     s.  |r|}ndu rd fddt |D }|D ]{}zt||}t|ds(W qt|d|}ttj|}	W n	 ty>   Y qw zt|	}
t	|
d }t	|
d dd }W n t
ye   d	}d
}Y nw dt  }|durs||ipti }t|| z|	j|| _W n	 ty   Y nw t |||  qdS )z9Automates delegation of __specials__ for a proxying type.N)r]   __del____getattribute____metaclass__rC  rE  c                   s6   g | ]}| d r|d rt |s|vr|qS )r   )
startswithendswithr   ro   rB   into_clsskipr0   r1   r3    s    z0monkeypatch_proxied_specials.<locals>.<listcomp>r   r   r   r   z(self, *args, **kw)z(*args, **kw)z?def %(method)s%(fn_args)s: return %(name)s.%(method)s%(d_args)s)rQ  r8   r   r   r   r   r   r   r   r  r   localsr   r   setattr)r]  Zfrom_clsr^  onlyr   Zfrom_instanceZdundersr  Zmaybe_fnr   r   Zfn_argsZd_argspyr   r0   r\  r1   monkeypatch_proxied_specials  sN   




rc  c                 C  s   t | d| t |d|u S )z;Return True if the two methods are the same implementation.r   )r8   )Zmeth1Zmeth2r0   r0   r1   methods_equivalent  s   rd  c                 C  sf  |s|st dt|trt| |r| S t|pdd t|D }tt| }tj}t|tr2|}n|s;t }tj}nt|}||||rI| S t| t	sc|tju rUdpVd}t d| |d
|f G dd	 d	}|rrd
|j |_t }	t| D ]'\}
}|
|vrt d|
 t|st d|
|f t||
t| |	|
 qy||	|r|S t dd
||	  )a  Ensure basic interface compliance for an instance or dict of callables.

    Checks that ``obj`` implements public methods of ``cls`` or has members
    listed in ``methods``. If ``required`` is not supplied, implementing at
    least one interface method is sufficient. Methods present on ``obj`` that
    are not in the interface are ignored.

    If ``obj`` is a dict and ``dict`` does not meet the interface
    requirements, the keys of the dictionary are inspected. Keys present in
    ``obj`` that are not in the interface will raise TypeErrors.

    Raises TypeError if ``obj`` does not meet the interface criteria.

    In all passing cases, an object with callable members is returned.  In the
    simple case, ``obj`` is returned as-is; if dict processing kicks in then
    an anonymous class is returned.

    obj
      A type, instance, or dictionary of callables.
    cls
      Optional, a type.  All public methods of cls are considered the
      interface.  An ``obj`` instance of cls will always pass, ignoring
      ``required``..
    methods
      Optional, a sequence of method names to consider as the interface.
    required
      Optional, a sequence of mandatory implementations. If omitted, an
      ``obj`` that provides at least one interface method is considered
      sufficient.  As a convenience, required may be a type, in which case
      all public methods of the type are required.

    z2a class or collection of method names are requiredc                 S  s   g | ]	}| d s|qS )rI  )rY  r[  r0   r0   r1   r3    s    z as_interface.<locals>.<listcomp>zany ofzall ofz%r does not implement %s: %sr8  c                   @     e Zd ZdZdS )z(as_interface.<locals>.AnonymousInterfacezA callable-holding shell.NrY   rZ   r[   r\   r0   r0   r0   r1   AnonymousInterface      rg  Z	Anonymousz%r: unknown in this interfacez%r=%r is not callablez,dictionary does not contain required keys %s)r   r4   r5   ra   rQ  operatorgegtintersectionr   rr   rY   dictlike_iteritemsr  r`  staticmethodrc   )r)   r^   r#  requiredZ	interfaceZimplementedZcompliesZ	qualifierrg  foundr  r   r0   r0   r1   as_interface  sP   !


rq  _GFDzgeneric_fn_descriptor[Any]c                   @  s   e Zd ZU dZded< ded< ded< d%d&d
dZed'ddZed(ddZd)ddZer8d*ddZ	d+ddZ
d,d d!Zed-d#d$ZdS ).generic_fn_descriptorag  Descriptor which proxies a function when the attribute is not
    present in dict

    This superclass is organized in a particular way with "memoized" and
    "non-memoized" implementation classes that are hidden from type checkers,
    as Mypy seems to not be able to handle seeing multiple kinds of descriptor
    classes used for the same attribute.

    Callable[..., _T_co]fgetOptional[str]r\   r<   rY   Ndocc                 C     || _ |p|j| _|j| _d S r,   ru  r\   rY   rJ   ru  rw  r0   r0   r1   r   <  s   zgeneric_fn_descriptor.__init__rJ   rr  r)   rF   r^   r   r*   c                 C  r   r,   r0   rJ   r)   r^   r0   r0   r1   __get__A     zgeneric_fn_descriptor.__get__r  r!   c                 C  r   r,   r0   r{  r0   r0   r1   r|  E  r}  Union[_GFD, _T_co]c                 C     t  r,   NotImplementedErrorr{  r0   r0   r1   r|  I     instancerO   c                 C  r   r,   r0   rJ   r  rO   r0   r0   r1   __set__N  r&  zgeneric_fn_descriptor.__set__c                 C  r   r,   r0   )rJ   r  r0   r0   r1   
__delete__Q  r&  z generic_fn_descriptor.__delete__c                 C  r  r,   r  rJ   r)   r0   r0   r1   _resetT  r  zgeneric_fn_descriptor._resetr   c                 C  r  r,   r  r^   r)   r   r0   r0   r1   resetW  s   zgeneric_fn_descriptor.resetr,   )ru  rt  rw  rv  )rJ   rr  r)   rF   r^   r   r*   rr  )r)   r  r^   r   r*   r!   )rJ   rr  r)   r   r^   r   r*   r~  r  r   rO   r   r*   rF   r  r   r*   rF   )r)   r   r*   rF   )r)   r   r   r<   r*   rF   )rY   rZ   r[   r\   r3   r   r   r|  r   r  r  r  classmethodr  r0   r0   r0   r1   rs  -  s"   
 




rs  c                   @  s    e Zd ZdZesdd ZdS dS )_non_memoized_propertyza plain descriptor that proxies a function.

    primary rationale is to provide a plain attribute that's
    compatible with memoized_property which is also recognized as equivalent
    by mypy.

    c                 C  s   |d u r| S |  |S r,   ru  r{  r0   r0   r1   r|  g  s   
z_non_memoized_property.__get__N)rY   rZ   r[   r\   r   r|  r0   r0   r0   r1   r  \  s
    r  c                   @  s0   e Zd ZdZesdd Zdd Zedd ZdS )	_memoized_propertyz2A read-only @property that is only evaluated once.c                 C  s&   |d u r| S |  | |j| j< }|S r,   )ru  r6   rY   rJ   r)   r^   resultr0   r0   r1   r|  r  s   z_memoized_property.__get__c                 C  s   t || j d S r,   )r  r  rY   r  r0   r0   r1   r  x  s   z_memoized_property._resetc                 C  s   |j |d  d S r,   )r6   rb   r  r0   r0   r1   r  {  s   z_memoized_property.resetN)	rY   rZ   r[   r\   r   r|  r  r  r  r0   r0   r0   r1   r  m  s    r  c                   s    fdd}t | S )zDecorate a method memoize its return value.

    Best applied to no-arg methods: memoization is not sensitive to
    argument values, and will always return the same value even when
    called with different arguments.

    c                   sB   | g|R i |  fdd}j |_ j|_|| jj <  S )Nc                        S r,   r0   arG  r  r0   r1   memo  r&  z6memoized_instancemethod.<locals>.oneshot.<locals>.memo)rY   r\   r6   rJ   r   rG  r  r   r  r1   oneshot  s   z(memoized_instancemethod.<locals>.oneshotr   )r   r  r0   r  r1   memoized_instancemethod  s   	
r  c                   @  sh   e Zd ZU dZesdZe Zded< dddZ	dd	d
Z
dddZG dd dee ZedddZdS )HasMemoizedzA mixin class that maintains the names of memoized elements in a
    collection for easy cache clearing, generative, etc.

    r0   zFrozenSet[str]_memoized_keysr*   rF   c                 C  s   | j D ]	}| j|d  qd S r,   )r  r6   rb   rJ   r   r0   r0   r1   _reset_memoizations     
zHasMemoized._reset_memoizationsc                 C  s   | j D ]	}|| jvsJ qd S r,   )r  r6   r  r0   r0   r1   _assert_no_memoizations  r  z#HasMemoized._assert_no_memoizationsrS  r<   rO   r   c                 C  s   || j |< |  j|hO  _d S r,   )r6   r  )rJ   rS  rO   r0   r0   r1   _set_memoized_attribute  s   
z#HasMemoized._set_memoized_attributec                   @  sZ   e Zd ZU dZded< ded< ded< ddd
dZedddZedddZdd ZdS )zHasMemoized.memoized_attributezTA read-only @property that is only evaluated once.

        :meta private:

        Callable[..., _T]ru  rv  r\   r<   rY   Nrw  c                 C  rx  r,   ry  rz  r0   r0   r1   r     s   z'HasMemoized.memoized_attribute.__init__rJ   r&   r)   rF   r^   r   r*   c                 C  r   r,   r0   r{  r0   r0   r1   r|    r}  z&HasMemoized.memoized_attribute.__get__r    c                 C  r   r,   r0   r{  r0   r0   r1   r|    r}  c                 C  s8   |d u r| S |  | |j| j< }| j| jhO  _|S r,   )ru  r6   rY   r  r  r0   r0   r1   r|    s
   r,   )ru  r  rw  rv  )rJ   r&   r)   rF   r^   r   r*   r&   )r)   r   r^   r   r*   r    )rY   rZ   r[   r\   r3   r   r   r|  r0   r0   r0   r1   memoized_attribute  s   
 r  r   r#   c                   s   d	 fdd}t | S )
zMDecorate a method memoize its return value.

        :meta private:

        rJ   r   r   rG  r*   c                   sT   | g|R i |  fdd}j |_ j|_|| jj < |  jj hO  _ S )Nc                    r  r,   r0   r  r  r0   r1   r    r&  zBHasMemoized.memoized_instancemethod.<locals>.oneshot.<locals>.memo)rY   r\   r6   r  r  r  r  r1   r    s   z4HasMemoized.memoized_instancemethod.<locals>.oneshotN)rJ   r   r   r   rG  r   r*   r   r   )r^   r   r  r0   r  r1   r    s   
z#HasMemoized.memoized_instancemethodNrX   )rS  r<   rO   r   r*   rF   r   r#   r*   r#   )rY   rZ   r[   r\   r   r]   	frozensetr  r3   r  r  r  memoized_propertyr    r  r  r  r0   r0   r0   r1   r    s   
 


 r  c                   @  s&   e Zd ZdZdZdd Zdd	d
ZdS )MemoizedSlotszApply memoized items to an object using a __getattr__ scheme.

    This allows the functionality of memoized_property and
    memoized_instancemethod to be available to a class using __slots__.

    r0   c                 C  s   t |r,   )r   )rJ   rS  r0   r0   r1   _fallback_getattr     zMemoizedSlots._fallback_getattrrS  r<   r*   r   c                   s    ds
 drttjd r(td  }t| |S tjd rGtd   fdd} j|_|S S )NZ_memoized_attr_Z_memoized_method_c                    s:   | i |  fdd}j |_ j|_t|  S )Nc                    r  r,   r0   r  r  r0   r1   r  (  r&  z8MemoizedSlots.__getattr__.<locals>.oneshot.<locals>.memo)rY   r\   r`  )r   rG  r  r   rS  rJ   r  r1   r  %  s   z*MemoizedSlots.__getattr__.<locals>.oneshot)rY  r   r   r|   r8   r`  r\   r  )rJ   rS  rO   r  r0   r  r1   __getattr__  s   
zMemoizedSlots.__getattr__N)rS  r<   r*   r   )rY   rZ   r[   r\   r]   r  r  r0   r0   r0   r1   r  	  s
    r  c                 C  sB   t | tr|   } | dv rdS | dv rdS td|  t| S )N)trueyesonyt1T)falsenooffrp   f0FzString is not true/false: %r)r4   r<   striprn   
ValueErrorr{   r/   r0   r0   r1   asbool7  s   
r  text!Callable[[str], Union[str, bool]]c                    s   d fdd}|S )	zqReturn a callable that will evaluate a string as
    boolean, or one of a set of "alternate" string values.

    r)   r<   r*   Union[str, bool]c                   s   |  v r| S t | S r,   )r  r/   r  r0   r1   bool_or_valueI  s   z"bool_or_str.<locals>.bool_or_valueN)r)   r<   r*   r  r0   )r  r  r0   r  r1   bool_or_strC  s   r  rO   Optional[int]c                 C  s   | du r| S t | S )zCoerce to integer.N)r   )rO   r0   r0   r1   asintR  s   r  rG  rS  rM   
flexi_booldestOptional[Dict[str, Any]]rF   c                 C  sx   |du r| }|| v r6t |trt | | |s:| | dur8|tu r,|r,t| | ||< dS || | ||< dS dS dS dS )zIf 'key' is present in dict 'kw', coerce its value to type 'type\_' if
    necessary.  If 'flexi_bool' is True, the string '0' is considered false
    when coercing to boolean.
    N)r4   r5   r{   r  )rG  rS  rM   r  r  r0   r0   r1   coerce_kw_typeZ  s   r  c                   s$   t |}|ft fdd|D  S )zbProduce a tuple structure that is cacheable using the __dict__ of
    obj to retrieve values

    c                 3  (    | ]}| j v r| j | fV  qd S r,   r6   ro   kr/   r0   r1   rq   z      z"constructor_key.<locals>.<genexpr>)r   r   )r)   r^   r   r0   r/   r1   constructor_keyt  s   
r  r   c                   s4   t |}| fdd||D  ||i |S )zInstantiate cls using the __dict__ of obj as constructor arguments.

    Uses inspect to match the named arguments of ``cls``.

    c                 3  r  r,   r  r  r/   r0   r1   rq     r  z#constructor_copy.<locals>.<genexpr>)r   r@   
difference)r)   r^   r   rG  r   r0   r/   r1   constructor_copy  s
   r  Callable[[], int]c                    s$   t  td  fdd} | S )z%Return a threadsafe counter function.r   c                     s0    t  W  d    S 1 sw   Y  d S r,   )nextr0   counterlockr0   r1   _next  s   $zcounter.<locals>._next)	threadingLockr   count)r  r0   r  r1   r    s   
r  specimenr5  Optional[Type[Any]]c                 C  s   t | dr| jdurt| jtrtS | jS t| trtnt}|| tr%tS || tr,tS || tr3tS t | dr:tS t | drAtS t | drHtS |S )zGiven an instance or class, guess if it is or is acting as one of
    the basic collection types: list, set and dict.  If the __emulates__
    property is present, return that preferentially.
    __emulates__Nr   rc   ra   )r   r  rM  ra   r4   r5   r   r   )r  r5  Zisar0   r0   r1   duck_type_collection  s(   






r  r   argtype'Union[Tuple[Type[Any], ...], Type[Any]]r   c                 C  sX   t | |r| S t |tr td|ddd |D t| f td||t| f )Nz8Argument '%s' is expected to be one of type %s, got '%s'z or c                 s  s    | ]}d | V  qdS )z'%s'Nr0   )ro   r  r0   r0   r1   rq     s    z"assert_arg_type.<locals>.<genexpr>z6Argument '%s' is expected to be of type '%s', got '%s')r4   r   r   ArgumentErrorrr   r5   )r   r  r   r0   r0   r1   assert_arg_type  s   

r  c                   s   t  drt  S t dt dddu rtd  t  dr. fdd}| S t  d	r@tfd
d  D S td  )z?Return a (key, value) iterator for almost any dict-like object.r=  __getitem__r7   NzObject '%r' is not dict-likeiterkeysc                  3  s.       D ]} d usJ | | fV  qd S r,   )r  )rS  dictlikegetterr0   r1   iterator  s
   z$dictlike_iteritems.<locals>.iteratorrR  c                 3  s    | ]	}| |fV  qd S r,   r0   )ro   rS  )r  r0   r1   rq     rK  z%dictlike_iteritems.<locals>.<genexpr>)r   r   r=  r8   r   iterrR  )r  r  r0   r  r1   rm    s   


rm  c                      s8   e Zd ZU dZded< d fddZddddZ  ZS )classpropertyaA  A decorator that behaves like @property except that operates
    on classes rather than instances.

    The decorator is currently special when using the declarative
    module, but note that the
    :class:`~.sqlalchemy.ext.declarative.declared_attr`
    decorator should be used for this purpose with declarative.

    Callable[[Any], Any]ru  r   r   rG  c                   s&   t  j|g|R i | |j| _d S r,   )superr   r\   )rJ   ru  r   rG  r|   r0   r1   r     s   zclassproperty.__init__Nr)   r^   Optional[type]r*   c                 C  s
   |  |S r,   r  r{  r0   r0   r1   r|    r2   zclassproperty.__get__)ru  r  r   r   rG  r   r,   )r)   r   r^   r  r*   r   )rY   rZ   r[   r\   r3   r   r|  __classcell__r0   r0   r  r1   r    s
   
 
r  c                   @  s*   e Zd ZdddZdd
dZdddZdS )hybridpropertyr   r  c                 C  s   || _ || _d S r,   )r   clslevelrJ   r   r0   r0   r1   r     s   
zhybridproperty.__init__r  r   ownerr*   r    c                 C      |d u r|  |}|S | |S r,   r  r   rJ   r  r  Zclsvalr0   r0   r1   r|       

zhybridproperty.__get__rz   hybridproperty[_T]c                 C  
   || _ | S r,   r  r  r0   r0   r1   
classlevel	     zhybridproperty.classlevelNr   r  r  r   r  r   r*   r    )r   rz   r*   r  )rY   rZ   r[   r   r|  r  r0   r0   r0   r1   r    s    

r  c                   @  s>   e Zd ZdddZdd
dZdddZdddZdddZdS )rw_hybridpropertyr   r  c                 C  s   || _ || _d | _d S r,   )r   r  setfnr  r0   r0   r1   r     s   
zrw_hybridproperty.__init__r  r   r  r*   r    c                 C  r  r,   r  r  r0   r0   r1   r|    r  zrw_hybridproperty.__get__rO   rF   c                 C  s   | j d usJ |  || d S r,   r  r  r0   r0   r1   r    s   zrw_hybridproperty.__set__rz   rw_hybridproperty[_T]c                 C  r  r,   r  r  r0   r0   r1   setter  r  zrw_hybridproperty.setterc                 C  r  r,   r  r  r0   r0   r1   r  #  r  zrw_hybridproperty.classlevelNr  r  r  )r   rz   r*   r  )rY   rZ   r[   r   r|  r  r   r  r0   r0   r0   r1   r    s    



r  c                   @  s.   e Zd ZdZdddZdd
dZdddZdS )hybridmethodz/Decorate a function as cls- or instance- level.r   r  c                 C  s   | | _ | _|| _d S r,   )r   r   r  r  r0   r0   r1   r   +  s   
zhybridmethod.__init__r  r   r  r*   c                 C  s&   |d u r| j ||jS | j||S r,   )r  r|  r|   r   )rJ   r  r  r0   r0   r1   r|  /  s   zhybridmethod.__get__rz   hybridmethod[_T]c                 C  r  r,   r  r  r0   r0   r1   r  5  r  zhybridmethod.classlevelNr  )r  r   r  r   r*   r  )r   rz   r*   r  )rY   rZ   r[   r\   r   r|  r  r0   r0   r0   r1   r  (  s
    

r  c                   @  sV   e Zd ZU dZded< i Zded< e Z		ddddZ	dd Z
dd Zdd ZdS )symbolaI  A constant symbol.

    >>> symbol('foo') is symbol('foo')
    True
    >>> symbol('foo')
    <symbol 'foo>

    A slight refinement of the MAGICCOOKIE=object() pattern.  The primary
    advantage of symbol() is its repr().  They are also singletons.

    Repeated calls of symbol('name') will all return the same instance.

    r<   r   zDict[str, symbol]symbolsNrw  rv  	canonicalr  r*   c                 C  s   | j G | j|}|d u r1t|tsJ |d u rt|}tt|}||_	|r+||_
|| j|< n|rA||krAtd|d| |W  d    S 1 sMw   Y  d S )Nz#Can't replace canonical symbol for z with new int value )_lockr  r7   r4   r<   hashr   __new__r  r   r\   r   )r^   r   rw  r  r   r0   r0   r1   r  N  s&   $zsymbol.__new__c                 C  s   t | jdt| ffS )Nr;   )r  r   r   rI   r0   r0   r1   
__reduce__l  s   zsymbol.__reduce__c                 C  s   t | S r,   r6  rI   r0   r0   r1   __str__o  r  zsymbol.__str__c                 C  s   d| j dS )Nzsymbol()r   rI   r0   r0   r1   __repr__r  rL   zsymbol.__repr__)NN)r   r<   rw  rv  r  r  r*   r  )rY   rZ   r[   r\   r3   r  r  r  r  r  r	  r
  r  r0   r0   r0   r1   r  :  s   
 r  c                   @  s    e Zd ZdddZdddZdS )_IntFlagMeta	classnamer<   r   Tuple[Type[Any], ...]dict_r   rG  r   r*   rF   c           	      K  sx   g  | _ }| D ]%\}}t|trt||d}n
|ds"tdq	t| || || q	t	
dd |D | _d S )N)r  rI  z#Expected integer values for IntFlagc                 S  s   i | ]}|j |qS r0   r  )ro   r   r0   r0   r1   
<dictcomp>  r4  z)_IntFlagMeta.__init__.<locals>.<dictcomp>)Z_itemsr=  r4   r   r  rY  r   r`  r   r   Zimmutabledict__members__)	r^   r  r   r  rG  r=  r  vr   r0   r0   r1   r   w  s   



z_IntFlagMeta.__init__Iterator[symbol]c                 C  s   t d)Nziter not implemented to ensure compatibility with Python 3.11 IntFlag.  Please use __members__.  See https://github.com/python/cpython/issues/99304r  rI   r0   r0   r1   __iter__  s   z_IntFlagMeta.__iter__N)
r  r<   r   r  r  r   rG  r   r*   rF   )r*   r  )rY   rZ   r[   r   r  r0   r0   r0   r1   r  v  s    
r  c                   @  re  )_FastIntFlagzAn 'IntFlag' copycat that isn't slow when performing bitwise
    operations.

    the ``FastIntFlag`` class will return ``enum.IntFlag`` under TYPE_CHECKING
    and ``_FastIntFlag`` otherwise.

    Nrf  r0   r0   r0   r1   r    rh  r  )	metaclass)IntFlag_EchoicesDict[_E, List[Any]]resolve_symbol_namesOptional[_E]c                 C  sj   |  D ]\}}| |u r|  S |r| |jkr|  S | |v r#|  S q| du r*dS td| d| )aO  Given a user parameter, parse the parameter into a chosen value
    from a list of choice objects, typically Enum values.

    The user argument can be a string name that matches the name of a
    symbol, or the symbol object itself, or any number of alternate choices
    such as True/False/ None etc.

    :param arg: the user argument.
    :param choices: dictionary of enum values to lists of possible
        entries for each.
    :param name: name of the argument.   Used in an :class:`.ArgumentError`
        that is raised if the parameter doesn't match any available argument.

    NzInvalid value for 'z': )r=  r   r   r  )r   r  r   r  Z
enum_valuechoicer0   r0   r1   parse_user_argument_for_enum  s   r   r  c                 C  s   t | _ t d7 a dS )zAssign a '_creation_order' sequence to the given instance.

    This allows multiple instances to be sorted in order of creation
    (typically within a single thread; the counter is not particularly
    threadsafe).

    r   N)_creation_order)r  r0   r0   r1   set_creation_order  s   	r"  r(  c                 O  s>   z| |i |W S  t y   tdt dd   Y dS w )zXexecutes the given function, catches all exceptions and converts to
    a warning.

    z%s('%s') ignoredr   r   N)rj   warnrG   rH   )r   r   r(  r0   r0   r1   warn_exception  s
   r$     c                 C  s<   zt | |krd| d|  W S | W S  ty   |  Y S w )Nz%s...r   )r  r   )rO   Zlen_r0   r0   r1   ellipses_string  s   r&  c                      s@   e Zd ZU dZded< d fd
dZdddZdddZ  ZS )_hash_limit_stringa/  A string subclass that can only be hashed on a maximum amount
    of unique values.

    This is used for warnings so that we can send out parameterized warnings
    without the __warningregistry__ of the module,  or the non-overridable
    "once" registry within warnings.py, overloading memory,


    r   _hashrO   r<   numr   Sequence[Any]r*   c                   s<   || d|  }t  | |}td|t|| f |_|S )Nz6 (this warning may be suppressed after %d occurrences)z%s_%d)r  r  r  r(  )r^   rO   r)  r   ZinterpolatedrJ   r  r0   r1   r    s   z_hash_limit_string.__new__c                 C  s   | j S r,   )r(  rI   r0   r0   r1   __hash__	  r  z_hash_limit_string.__hash__otherr   r{   c                 C  s   t | t |kS r,   )r  )rJ   r,  r0   r0   r1   __eq__  s   z_hash_limit_string.__eq__)rO   r<   r)  r   r   r*  r*   r'  )r*   r   )r,  r   r*   r{   )	rY   rZ   r[   r\   r3   r  r+  r-  r  r0   r0   r  r1   r'    s   
 


r'  msgrv  c                 C  s*   |rt tj| |d dS t | tj dS )zdIssue a warning.

    If msg is a string, :class:`.exc.SAWarning` is used as
    the category.

    )r   N)_warnings_warnr   	SAWarning)r.  r   r0   r0   r1   r#    s   r#  r*  c                 C  s    |rt | d|} t| tj dS )z\Issue a warning with a parameterized string, limiting the number
    of registrations.

    
   N)r'  r/  r   r0  )r.  r   r0   r0   r1   warn_limited  s   r2  z)Dict[CodeType, Tuple[str, Type[Warning]]]_warning_tagsmessagecategoryType[Warning]Callable[[_F], _F]c                   s    fdd}|S )Nc                   s    ft | j< | S r,   )r3  r   r  r5  r4  r0   r1   go-  s   z#tag_method_for_warnings.<locals>.gor0   )r4  r5  r9  r0   r8  r1   tag_method_for_warnings*  s   r:  z&^(?:sqlalchemy\.(?!testing)|alembic\.)Union[str, Warning]Optional[Type[Warning]]
stacklevelc                 C  s   zt |}W n ty   d}Y nK   d}Y nDd }}|d ur]|s0tt|jdds0d}|jt	v rJd}t	|j \}}|pA|}|  d| d} |j
}|sT|d7 }n|rY|rYn|d us!|d urmtj| ||d d	 d S tj| |d d	 d S )
Nr   FrY   r  Tz (r  r   )r=  )rG   	_getframer  rs   match_not_sa_pattern	f_globalsr7   f_coder3  f_backwarningsr#  )r4  r5  r=  frameZstacklevel_foundZwarning_tag_foundZ_suffixZ	_categoryr0   r0   r1   r/  7  s4   

r/  r  retry_on_exceptionCallable[..., Optional[_T]]c                   s    gd	 fdd}|S )
zNDecorate the given function to be a no-op after it is called exactly
    once.r   r   rG  r*   Optional[_T]c                    s>    }r  }z|| i |W S    rd|  d S )Nr   )rb   insert)r   rG  Z	strong_fnZonce_fnr   oncerF  r0   r1   r9  r  s   zonly_once.<locals>.goN)r   r   rG  r   r*   rH  r0   )r   rF  r9  r0   rJ  r1   	only_oncej  s   rL  z%sqlalchemy/([a-z_]+/){0,2}[a-z_]+\.pyzunit(?:2|test2?/)tbexclude_prefixre.Pattern[str]exclude_suffixc                 C  s   d}t | d }||kr"|| | r"|d7 }||kr"|| | s||kr<|| | r<|d8 }||kr<|| | s-| ||d  S )at  Chop extraneous lines off beginning and end of a traceback.

    :param tb:
      a list of traceback lines as returned by ``traceback.format_stack()``

    :param exclude_prefix:
      a regular expression object matching lines to skip at beginning of
      ``tb``

    :param exclude_suffix:
      a regular expression object matching lines to skip at end of ``tb``
    r   r   )r  search)rM  rN  rP  r   endr0   r0   r1   chop_traceback  s   rS  c                 C  s$   d|  }t   }t|| |d S )Nz&def set(obj, value):    obj.%s = valuera   )r_  copyr   )attrnamer   r   r0   r0   r1   
attrsetter  s   

rV  c                      s&   e Zd ZdZdZd fddZ  ZS )
TypingOnlyzA mixin class that marks a class as 'typing only', meaning it has
    absolutely no methods, attributes, or runtime functionality whatsoever.

    r0   r*   rF   c                   sF   t | jv rt| jh d}|rtd|  d| dt   d S )N>   rZ   __orig_bases__r]   r3   r\   zClass z< directly inherits TypingOnly but has additional attributes r   )rW  r   ra   r6   r  AssertionErrorr  __init_subclass__)r^   	remainingr  r0   r1   rZ    s   

	zTypingOnly.__init_subclass__rX   )rY   rZ   r[   r\   r]   rZ  r  r0   r0   r  r1   rW    s    rW  c                      s<   e Zd ZU dZded< 	 d fddZedd
dZ  ZS )EnsureKWArga6  Apply translation of functions to accept \**kw arguments if they
    don't already.

    Used to ensure cross-compatibility with third party legacy code, for things
    like compiler visit methods that need to accept ``**kw`` arguments,
    but may have been copied from old code that didn't accept them.

    r<   ensure_kwargr*   rF   c                   sf   | j }| j}|r,|D ]!}t||}|r+|| }t|}|js+| |}t| || q
t	 
  d S r,   )r]  r6   rs   r?  r   r   r  
_wrap_w_kwr`  r  rZ  )r^   Zfn_regZclsdictrS  rB   r   r   wrappedr  r0   r1   rZ    s   

zEnsureKWArg.__init_subclass__r   rz   c                   s   d fdd}t | S )Nr   r   rG  r*   c                    s    |  S r,   r0   )r   rG  r  r0   r1   wrap  r  z$EnsureKWArg._wrap_w_kw.<locals>.wrap)r   r   rG  r   r*   r   r   )r^   r   r`  r0   r  r1   r^    s   
zEnsureKWArg._wrap_w_kwrX   )r   rz   r*   rz   )	rY   rZ   r[   r\   r3   rZ  r  r^  r  r0   r0   r  r1   r\    s   
 	r\  c                 C  sh   t |dr
t| |S | }|jj|_t |dr|j|_t |jdr+|jjr+|jj|_|S |jr2|j|_|S )zAugment functools.update_wrapper() to work with objects with
    a ``__call__()`` method.

    :param fn:
      object with __call__ method

    rY   rZ   r\   )r   r   r|   rY   rZ   r   r\   )wrapperr   Z_fr0   r0   r1   wrap_callable  s   




rb  c                 C  s   d| vr	|  dS d}g g}d}t| }||k r`| | }|dkrC|dkr>||d k r>| |d  dkr>|d d |d7 }n|dN }n|dkrQ|dkrQ|g  n|d | |d7 }||k sdd |D S )a  Parse a dotted identifier with accommodation for quoted names.

    Includes support for SQL-style double quotes as a literal character.

    E.g.::

        >>> quoted_token_parser("name")
        ["name"]
        >>> quoted_token_parser("schema.name")
        ["schema", "name"]
        >>> quoted_token_parser('"Schema"."Name"')
        ['Schema', 'Name']
        >>> quoted_token_parser('"Schema"."Name""Foo"')
        ['Schema', 'Name""Foo']

    "r   r   r   r  c                 S  s   g | ]}d  |qS )r  )rr   )ro   r   r0   r0   r1   r3  1  s    z'quoted_token_parser.<locals>.<listcomp>)r   r  r   )rO   rD  r  idxlvcharr0   r0   r1   quoted_token_parser  s&   
$

rg  paramsc                   s   t    fdd}|S )Nc                   s:   | j d ur| j p	d}|rt|fdd D }|| _ | S )Nr  c                   s   i | ]}| qS r0   r0   )ro   paramr  r0   r1   r  :  s    z8add_parameter_text.<locals>.decorate.<locals>.<dictcomp>)r\   inject_param_text)r   rw  rh  r  r0   r1   r   7  s
   z$add_parameter_text.<locals>.decorate)r   r9  )rh  r  r   r0   rk  r1   add_parameter_text4  s   
rl  c                 C  sJ   |  dd}t|dkr| S |\}}|ds |d t| S t| S )N
r   rm   )r   r  rY  textwrapdedent)r  Z
split_text	firstliner[  r0   r0   r1   _dedent_docstringA  s   

rq  given_doctext
injecttextposc                 C  s   t | pd}|d}t|dkr|d t|d}|d r(|dd dd t|D }|dd |t|t|d  }|d| | ||d   }d	|S )Nr  rm  r   r   c                 S  s   g | ]
\}}|  s|qS r0   )r  )ro   r)  liner0   r0   r1   r3  X  s    z)inject_docstring_text.<locals>.<listcomp>)
rq  r   r  r   rn  ro  rI  r;  minrr   )rr  rs  rt  doctextlinesZinjectlinesZblanksZ
inject_posr0   r0   r1   inject_docstring_textM  s   


ry  z(\s+):param (.+?):rw  inject_paramsDict[str, str]c           
      C  s  t |  }g }d }|r| }t|}|d u rO|rN|dd}||v rNdt|d d }|rHt	d|d }	|	rHdt|	d }|||  }n+|r\|
d|dg d }n| sk|
||dg d }n|drz|
|| g q|| |sd|S )	Nr   *rm   r   z(\s+)\Sr   rm  z::)collectionsdeque
splitlinespopleft
_param_regr?  r   lstripr  rs   rd   rstriprZ  r   rr   )
rw  rz  Zdoclinesrx  Z	to_injectru  rB   ri  indentm2r0   r0   r1   rj  d  s:   



!rj  r   c                 C  s~   t | dkrdS t | dk}|r| dd n| dd | dd  } dd | D }|r0d|S d	d|dd |d f S )
zTrims a list of strings from the middle and return a string of up to
    four elements. Strings greater than 11 characters will be truncatedr   Nr
  r   r  c                 S  s,   g | ]}t |d krd|dd   n|qS )   z%s..N)r  )ro   r   r0   r0   r1   r3    s   , z$repr_tuple_names.<locals>.<listcomp>r8  z%s, ..., %s)r  rr   )r   flagresr0   r0   r1   repr_tuple_names  s   (
r  c                 C  s   t rdS | r
tddS )NTzDcython extensions were expected to be installed, but are not presentF)r   ImportError)Zraise_r0   r0   r1   has_compiled_ext  s   r  )r)   r   r*   r+   )r;   r   r*   r<   )r^   r_   r*   r`   )ri   r   r*   r<   )r^   rl   r*   r<   )rw   rx   ry   rz   r*   r{   )r   r   r*   r   )r   r   r   r<   r*   r   )r   r   rp   r   r*   r   )r   rz   r*   r   )r   r   r   r   r   r<   r*   rz   )r^   r5   r   r   r   r   r*   r   )r^   r5   r   r   r   r{   r*   r   )r   rz   r*   r   )FF)r   rz   r   r{   r   r{   r*   r   )T)r   r  r   r{   r*   r	  )r0   r0   r0   )r  rl   r   r<   r!  r<   r"  r   r#  r   r$  r   r*   r%  )r0   Nr0   )
r)   r   r,  r-  r.  r/  r0  r   r*   r<   )NNrU  N)NNNr  )r)   r   r*   r{   )r  r<   r*   r  )rO   r   r*   r  )TN)rG  r   rS  r<   rM   rl   r  r{   r  r  r*   rF   )r)   r   r^   rl   r*   r   )
r)   r    r^   r_   r   r   rG  r   r*   r    )r*   r  r,   )r  r   r5  r  r*   r  )r   r   r  r  r   r<   r*   r   )F)
r   r   r  r  r   r<   r  r{   r*   r  r  )r   rz   r   r   r(  r   r*   r   )r%  )r.  r<   r   rv  r*   rF   )r.  r<   r   r*  r*   rF   )r4  r<   r5  r6  r*   r7  )Nr   )r4  r;  r5  r<  r=  r   r*   rF   )r   r  rF  r{   r*   rG  )rM  r   rN  rO  rP  rO  r*   r   )rh  r   r  r<   r*   r7  )r  r<   r*   r<   )rr  rv  rs  r<   rt  r   r*   r<   )rw  r<   rz  r{  r*   r<   )r   r   r*   rv  )r\   
__future__r   r}  enum	functoolsr   r>   r-   r   ri  rs   rG   rn  r  r   r   typingr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rD  r  r   r   Z_has_cyr   r   r   r    r!   r#   r%   r&   r'   r(   Zpy310r.   rC   rD   rh   rk   rv   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r  r'  r)  r+  r?  r@  rP  rT  rc  rd  rq  rr  rs  r  r  r  Znon_memoized_propertypropertyZro_memoized_propertyZro_non_memoized_propertyr  r  Z!HasMemoized_ro_memoized_attributer  r  r  r  r  r  r  r  r  r  r  rm  r  r  r  r  r   r  r5   r  r  r  ZFastIntFlagEnumr  r   r!  r"  r$  r&  r<   r'  r#  r2  r3  r3   r:  compiler@  r/  rL  Z_SQLA_REZ_UNITTEST_RErS  NoneTyperV  rW  r\  rb  rg  rl  rq  ry  r  rj  r  r  r0   r0   r0   r1   <module>   sd  ;
	@(	5;u#N&CV/P.#< 
"


3),+