
    Wd                     	   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"#          Z. e#d$ed%ef         &          Z/ e#d'd(&          Z0 e#d)d*&          Z1 e#d+d,&          Z2 e#d-d.&          Z3e(j4        rdd3Z5ndd4Z5dd7Z6 G d8 d9          Z7dd=Z8dd?Z9ddAZ:ddGZ;ddKZ<ddPZ=ddVZ> e#dWdE&          Z?ddZZ@d[ ZAddaZB e#db          ZC e#dc          ZD G dd de          ZEdf ZFedd%dgddn            ZGeddodgddp            ZGddodgddqZGddtZH	 d d!dxZI	 d"d#d|ZJd"d}ZK	 	 	 d$d%dZLd ZMd ZN	 	 	 d&d'dZO G d d          ZPd ZQd ZR	 	 	 	 d(dZSd ZTd)dZU e#dd&          ZV G d dee.                   ZW G d deWe.                   ZX G d deWe.                   ZYe"r	eWZZeWZ[e\Z]e\Z^neYxZZZ]eXxZ[Z^d*dZ_ G d d          Z`e"re\Zane`jb        Za G d d          Zcd+dZdd,dZed-dZf	 	 d.d/dZgd0dZhd1dZid2dZj	 d3d4dZkd5dZld Zm G d de\          Zn G dĄ dee-                   Zo G dƄ dee-                   Zp G dȄ dee-                   Zq G dʄ der          Zs G d̄ det          Zu G d΄ deuЦ          Zve"r	ddlmwZw ewZxnevZx e#dejy        &          Zz	 d6d7dׄZ{da|d8dلZ}d9dۄZ~d:d݄Z G dބ de          Zd3d;dZd<dZi Zded<   d=dZ ej        d          Z	 	 d>d?dZd@dZ ej        d          Z ej        d          ZeefdAdZ etd          Zd Z G d d          Z G d d           Zd Zd ZdBdZdCdZdDd	Z ej        d
          ZdEdZdFdZd6dZdS (G  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                *    t          j        |           S N)inspectget_annotationsr*   s    W/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.pyr0   r0   B   s    &s+++    c                    t          | t                    r| j                            dd           }nt	          | dd           }|t
          j        S t          d|          S )N__annotations__r,   )
isinstancetype__dict__getgetattrr   
EMPTY_DICTr	   )r*   anns     r2   r0   r0   G   sa     c4   	8,""#4d;;CC#0$77C;**+S111r3   xstrc                    |                      d          } t          j                    }|                    |            |                                S )Nzutf-8)encodehashlibmd5update	hexdigest)r=   ms     r2   md5_hexrF   X   s;    	AAHHQKKK;;==r3   c                  2    e Zd ZU dZdZded<   ddZ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]]rI   r+   Nonec                6    t          j                    | _        d S r.   )sysexc_inforI   selfs    r2   	__enter__zsafe_reraise.__enter__   s    r3   type_Optional[Type[BaseException]]valueOptional[BaseException]	tracebackOptional[types.TracebackType]r   c                    | j         J |+| j         \  }}}|J d | _         |                    |          d | _         |J |                    |          r.   )rI   with_traceback)rO   rQ   rS   rU   exc_type	exc_valueexc_tbs          r2   __exit__zsafe_reraise.__exit__   ss     ~)))=*..'Hi(((!DN**6222!DN$$$&&y111r3   Nr+   rJ   )rQ   rR   rS   rT   rU   rV   r+   r   )__name__
__module____qualname____doc__	__slots__r5   rP   r\    r3   r2   rH   rH   _   sc          0 I   ( ( ( (2 2 2 2 2 2r3   rH   clsType[_T]Iterator[Type[_T]]c              #     K   t                      }| g}|r]|                                } | |v r|                    |            |                    |                                            | V  |[d S d S r.   )setpopaddextend__subclasses__)rd   seenstacks      r2   walk_subclassesro      s      UUDEE
 iikk$;;HHSMMMS''))***			      r3   elementc                z    t          | t                    r| S 	 t          |           S # t          $ r d| z  cY S w xY w)Nzunprintable element %r)r6   r>   	Exception)rp   s    r2   string_or_unprintablers      sV    '3 6	6w<< 	6 	6 	6+g5555	6s   ( ::	Type[Any]c                p    d                     d t          j        d| j                  D                       S )N c              3  >   K   | ]}|                                 V  d S r.   )lower).0ns     r2   	<genexpr>z(clsname_as_plain_name.<locals>.<genexpr>   s;        		     r3   z([A-Z][a-z]+|SQL))joinrefindallr^   rd   s    r2   clsname_as_plain_namer      sC    88  :&:CLII     r3   instance_or_clsUnion[Type[Any], object]against_methodCallable[..., Any]boolc                z    t          | t                    s| j        }n| }|j        }t	          ||          }||k    S )z1Return True if the two class methods don't match.)r6   r7   	__class__r^   r:   )r   r   current_clsmethod_namecurrent_methods        r2   method_is_overriddenr      sG     ot,, &%/% )K'.{K'H'HN^++r3   slcsliceTuple[Any, ...]c                    g }| j         | j        | j        fD ];}t          |d          r|                                }|                    |           <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=   s      r2   decode_slicer      sa     CY#(*  1k"" 	A

1::r3   usedSequence[str]basesIterator[str]c           
   '    K   t          |           }|D ]lt          j        ft          fdt	          d                              }|D ]!}||vr|                    |           |V   n"t          dz            md S )Nc                (    t          |           z   S r.   r>   )ibases    r2   <lambda>z!_unique_symbols.<locals>.<lambda>   s    $Q- r3   i  z&exhausted namespace for symbol base %s)rh   	itertoolschainmaprangerj   	NameError)r   r   used_setpoolsymr   s        @r2   _unique_symbolsr      s      4yyH M MG''''t55
 
  	M 	MC(""S!!!			 #
 DtKLLL M Mr3   fnCallable[[int], Any]rz   intIterator[Any]c              #  L   K   |r|| dz   z  } | |          V  ||z  }|dS dS )z6Call the given function given each nonzero bit from n.r   Nrc   )r   rz   bs      r2   map_bitsr      sW        !aLbee	Q      r3   _FntargetCallable[[_Fn], _Fn]c                0     d fd}t          |           S )z'A signature-matching decorator factory.r   r   r+   c                   t          j        |           s#t          j        |           st          d          t	          j        |           }i }t          ||          }t          t          d|d                             t          d|dd                   z   | j	        fz   }t          |dd          \  }}t          ||          }|                    t          |d	
                     | j	        |d<   dt          |d                   v rd|z  }nd|z  }t          j        | j                 }|                    t%          |                     |                    |
|| d| j        i           t          t&          j        t+          ||| j	                            }	t-          | d|           j        |	_        | |	_        t          t2          t5          |	|                     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)
r^   __func__)r/   
isfunctionismethodrr   r   inspect_getfullargspec!_update_argspec_defaults_into_envr   r	   r^   r   dictrC   format_argspec_plusreprrL   modulesr_   varstypesFunctionType_exec_code_in_envr:   __defaults____wrapped__r   r   )r   specenvnames	targ_namefn_namemetadatacodemod	decoratedr   s             r2   decoratezdecorator.<locals>.decorate   s   !"%% 	:g.>r.B.B 	:8999,R00 0s;; $($q'2233$d1Q3i001{n 	
 -UHdCC	7-1w-O-O-O+D%@@@AAA; 4Q==   	 D 	  k"-(

499

IvwJNOOOdC55
 
	 ")Z!<!<!I	 "	C	266777r3   )r   r   r+   r   r   )r   r   s   ` r2   	decoratorr      s4    88 88 88 88 88 88t (F+++r3   c                .   | j         rg }d}| j         D ]R}t          |          j        dvr%d|z  }|||<   |                    |           |dz  }=|                    |           St	          |           }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   )defaultsr7   r_   r   listr   r   FullArgSpec)r   r   new_defaultsr   argr   elems          r2   r   r   6  s     } = 	) 	)CCyy#+FFFqyD	##D)))Q##C((((Dzz%%Q!4((r3   r   Union[str, types.CodeType]r   Dict[str, Any]r   c                2    t          | |           ||         S r.   )exec)r   r   r   s      r2   r   r   K  s     	sOOOw<r3   _PF_TEc                  0    e Zd Z	 dddZd ZddZddZdS )PluginLoaderNgroupr>   auto_fnOptional[Callable[..., Any]]c                0    || _         i | _        || _        d S r.   )r   implsr   )rO   r   r   s      r2   __init__zPluginLoader.__init__W  s     
%'
r3   c                8    | j                                          d S r.   )r   clearrN   s    r2   r   zPluginLoader.clear^  s    
r3   r   r+   r   c                x   || j         v r | j         |                     S | j        r+|                     |          }|r|| j         |<    |            S t          j        | j                  D ]2}|j        |k    r%|j        | j         |<   |                                c S 3t          j        d| j        d|          )NzCan't load plugin: :)	r   r   r   importlib_metadata_getr   r   loadr    NoSuchModuleError)rO   r   loaderimpls       r2   r   zPluginLoader.loada  s    4:#4:d#%%%< 	 \\$''F  #)
4 vxx1$*== 	# 	#DyD  #'9
4 yy{{""" ! ##*.***dd;
 
 	
r3   
modulepathobjnamerJ   c                *    fd}|| j         |<   d S )Nc                     t                    }                     d          dd          D ]}t          | |          } t          |           S )N.r   )
__import__splitr:   )r   tokenr   r   s     r2   r   z#PluginLoader.register.<locals>.loadu  sW    Z((C#))#..qrr2 * *c5))3(((r3   )r   )rO   r   r   r   r   s     `` r2   registerzPluginLoader.registert  s6    	) 	) 	) 	) 	) 	)  
4r3   r.   )r   r>   r   r   )r   r>   r+   r   )r   r>   r   r>   r   r>   r+   rJ   )r^   r_   r`   r   r   r   r   rc   r3   r2   r   r   V  sg        BF      
 
 
 
&           r3   r   c                    	 t           j        }| j        }|j        }t	          |j        d |                   t          |j        |z            fS # t          $ r4 t          j
        |           }|d         t          |d                   fcY S w xY w)Nr   r   )r/   CO_VARKEYWORDS__code__co_argcountr   co_varnamesr   co_flagsAttributeErrorr   r   )r   co_varkeywordsconargsr   s        r2   _inspect_func_argsr
  ~  s    
 / ['((~-..
 	
  & & &
 ,R00AwT!W%%%%&s   A ;BB)_setraiseerrr7   r  Optional[Set[str]]r  Literal[True]Set[str]c                   d S r.   rc   rd   r  r  s      r2   get_cls_kwargsr    s	     Cr3   Fc                   d S r.   rc   r  s      r2   r  r    s	     Cr3   c                  |du }|rt                      }|J | j                            dd          }|o8t          |t          j                  ot          |j        t          j                  }|rCt          |          \  }}|	                    |           |s|s|rt          d|  d          dS nd}|r|r| j        D ]}t          ||           n|                    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  rO   )rh   r8   r9   r6   r   r   r  r   r
  rC   	TypeError	__bases__r  discard)	rd   r  r  toplevelctrhas_initr   has_kwcs	            r2   r  r    s=   " t|H uu
,

:u
-
-C 	 	5sE.//	5s|U^44   *3//vE 	h 	 FFFF   t v  	 	Aad+++3 4 	LLKr3   func	List[str]c                6    t          j        |           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  s    r2   get_func_kwargsr     s     (..q11r3   no_self_is_initcompat.FullArgSpecc           	        t          j        |           rt          d| z            t          j        |           rq|r[|rYt	          j        |           }t	          j        |j        dd         |j        |j	        |j
        |j        |j        |j                  S t	          j        |           S t          j        |           r|rg|s| j        r^t	          j        | j                  }t	          j        |j        dd         |j        |j	        |j
        |j        |j        |j                  S t	          j        | j                  S t          j        |           rt%          | j        |d          S t)          | d          rt	          j        | j                  S t)          | d          rAt          j        | j                  rt%          | j        |          S t          d	| z            t          d	| z            )
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   s       r2   r.  r.    s     ,;3b8999		B		 *; 	5 	5044D%	!""
#    0444		"		 ; 	> 	>BK 	>0==D%	!""
#    0===			 ;#K4
 
 
 	
 
Z	 	  
;,R[999	Z	 	  ;BK(( 	?'W    82=>>>4r9:::r3   -Union[Callable[..., Any], compat.FullArgSpec]r   Dict[str, Optional[str]]c           
        t          |           rt          j        |           }n| }t          j        | }t          j        |d         |d         |d         d|d                   }|d         rG|d         d         }t          j        |d         dd         |d         |d         d|d                   }n|d         rd|d         z  }|}nd}|}d}|d         r6|t	          t          t          t                   |d                             z  }|d         r|t	          |d                   z  }|d         |d         z   }|r|d|z
  d         }	nd}	t          j        ||d         |d         |	d	 
          }
|d         r/t          j        |dd         |d         |d         |	d 
          }n|
}|rt          ||||
||          S t          |||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   rc   c                &    dt          |           z   S N=r   r=   s    r2   r   z%format_argspec_plus.<locals>.<lambda>p  s    cCFFl r3   )formatvaluec                &    dt          |           z   S r4  r   r6  s    r2   r   z%format_argspec_plus.<locals>.<lambda>y  s    #A, r3   )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_defaults	name_argsdefaulted_valsr<  r>  s               r2   r   r     sw   H || ,R00'.D,Qa$q'4a I Aw &71:"8GABBKa$q'4a
 
 
a &T!W$%%LAw 7DsT!W55666Aw %DG$Q$q'!I  "1|#3#5#56+QQ**  H Aw 	$!7abbMGG..
 
 
 $ 
/-
 
 
 	
 "oad^/"5-ad3
 
 
 	
r3   c                    | t           j        u rd}|rdnd}|rdnd}n0	 t          | |          S # t          $ r d}|r|nd}|rdnd	}Y nw xY wt	          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)rO   z() r   z(self, *args, **kwargs)zself, *args, **kwargsz(*args, **kwargs)z*args, **kwargs)r:  r9  r;  r<  r=  r>  )objectr   r   r  r   )methodr   r9  r'  proxieds        r2   format_argspec_initrK    s       ".xx!)$$r	L&vw???? 	L 	L 	L4L#*G<<0GD-4K)):KGGG	L !!    s   0 A
Arc   
target_clstarget_cls_sphinx_nameproxy_cls_sphinx_nameclassmethodsmethods
attributesCallable[[_T], _T]c                    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 r.   rc   r   s    r2   r   z&create_proxy_methods.<locals>.decorate  s    
r3   rc   )rL  rM  rN  rO  rP  rQ  r   s          r2   create_proxy_methodsrU    s    $   Or3   c                    	 t          j        |           S # t          $ r! | t          j        u r	dgdddfcY S dgdddfcY S w xY 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)

    rO   Nr'  kwargs)r   r   r  rH  r   )rI  s    r2   getargspec_initrX    sn    6,V444 6 6 6V_$$HdD$////Hfh5555	6s    AA Ac                V    t          | t          j                  r| j        s| j        S | S )zSAdjust the incoming callable such that a 'self' argument is not
    required.

    )r6   r   
MethodTyper,  r   )func_or_clss    r2   unbound_method_to_callabler\    s2     +u/00 9M ##r3   additional_kwSequence[Tuple[str, Any]]
to_inspect%Optional[Union[object, List[object]]]
omit_kwargc           	     h    | g}nt          j        |          }t                      g }t          j                    }d}t	          |          D ]%\  }}	 t          j        |j                  }	|	j        rt          |	j                  nd}
|dk    rW|	j
        r|	j
        }|
r$|                    |	j        d|
                     nR|                    |	j        dd                    n/|                    fd|	j        d|
          D                        |
rI|	j        sJ |                    d t          |	j        |
 d         |	j                  D                        # t          $ r Y #w xY wg }|                     fd|D                        |=t!           |          r-|                    d t#           |          D                        |                                D ]P\  }}||v r
	 t#           |          }|ur ||k    r|                    |d|           A# t(          $ r Y Mw xY w|rN|D ]K\  }}	 t#           |          }|ur ||k    r|                    |d|           <# t(          $ r Y Hw xY w j        j        d	d
                    |          dS )z}Produce a __repr__() based on direct association of the __init__()
    specification vs. same-named attributes present.

    Nr   r   c                    g | ]}|fS rc   rc   )ry   r   missings     r2   
<listcomp>z generic_repr.<locals>.<listcomp>  s    IIIc7^IIIr3   c                    g | ]	\  }}||f
S rc   rc   )ry   r   defaults      r2   re  z generic_repr.<locals>.<listcomp>  s0       (C g  r3   c              3  T   K   | ]"}t          t          |d                     V  #d S r.   )r   r:   )ry   r   r*   s     r2   r{   zgeneric_repr.<locals>.<genexpr>  s7      DDC$wsC..//DDDDDDr3   c                ,    g | ]}t          |          S rc   r   )ry   vals     r2   re  z generic_repr.<locals>.<listcomp>  s    @@@StCyy@@@r3   r5  (, ))r   to_listrH  OrderedDict	enumerater   r   r   r   rB  r(  rk   r'  rC   zipr  r   r:   itemsr   rr   r   r^   r|   )r*   r]  r_  ra  pos_argskw_argsvargsr   inspr   default_lenoutputr   defvalrk  rd  s   `              @r2   generic_reprr{    si    U

!)*55
hhGH2>2J2L2LGEZ((  4	0??D 15D#dm,,,1KAvv< ) LE 3OODIan$=>>>>OODIabbM2222IIIItyK</HIII    	}$$$ ,/ I{lmm4dm- -    %  	 	 	H	4 F
MMDDDD8DDDDDDWS%00@@GC,?,?@@@AAA}}  V*	#sG,,C'!!cVmmcc2333 	 	 	D	  ( 	 	KCc300g%%#--MMSSS##"6777    }---tyy/@/@/@/@AAs6   E''
E54E595H//
H<;H<	5I??
JJc                  0    e Zd ZdZdZd Zd Zd	dZd ZdS )
portable_instancemethodz_Turn an instancemethod into a (parent, name) pair
    to produce a serializable callable.

    )r   r   rW  __weakref__c                ,    | j         | j        | j        dS )Nr   r   rW  r  rN   s    r2   __getstate__z$portable_instancemethod.__getstate__=  s     kIk
 
 	
r3   c                p    |d         | _         |d         | _        |                    dd          | _        d S )Nr   r   rW  rc   )r   r   r9   rW  )rO   states     r2   __setstate__z$portable_instancemethod.__setstate__D  s1    Ho&M	ii"--r3   rc   c                D    |j         | _        |j        | _        || _        d S r.   )r,  r   r^   r   rW  )rO   methrW  s      r2   r   z portable_instancemethod.__init__I  s    mM	r3   c                v    |                     | j                    t          | j        | j                  |i |S r.   )rC   rW  r:   r   r   )rO   r   kws      r2   r%  z portable_instancemethod.__call__N  s9    
		$+.wt{DI..:r:::r3   N)rc   )	r^   r_   r`   ra   rb   r  r  r   r%  rc   r3   r2   r}  r}  5  sf         
 :I
 
 
. . .
   
; ; ; ; ;r3   r}  c                *   | ht          | j                  }|r|                                }fd|j        D             }|D ],}|                    |                               |           -|j        dk    st          |d          stfdt          |t                    s|
                                n|
                    |          D             D ],}|                    |                               |           -|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  $   K   | ]
}|v|V  d S r.   rc   ry   _hiers     r2   r{   z"class_hierarchy.<locals>.<genexpr>b  s'      99q1D======99r3   r   rl   c                    g | ]}|v|	S rc   rc   r  s     r2   re  z#class_hierarchy.<locals>.<listcomp>k  s.     
 
 

 }}  }}r3   )r   __mro__ri   r  r   rj   r_   r   
issubclassr7   rl   )rd   processr  r   r   sr  s         @r2   class_hierarchyr  S  s?    5D3;G
 KKMM9999AK999 	 	ANN1HHQKKKK<:%%WQ8H-I-I%
 
 
 
 "!T**)  """%%a((
 
 
 
	 
	A NN1HHQKKKK+  , ::r3   c              #  ~   K   t          |           }|D ](}| j        D ]}||j        v r||j        |         fV   n)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)dirr  r8   )rd   keyskeyr  s       r2   iterate_attributesr  y  sl       s88D   	 	Aaj  AJsO,,,, ! r3   
self.proxyc                    |r|}n d fdt          |          D             }|D ]-}	 t          ||          }t          |d          s%t          |d|          }t          t          j        |          }	n# t          $ r Y ]w xY w	 t          j        |	          }
t          j	        |
d                   }t          j	        |
d         dd                   }n# t          $ r d}d	}Y nw xY wd
t                      z  }|dur||ipi }t          ||           	 |	j        ||         _        n# t          $ r Y nw xY wt           |||                    /dS )z9Automates delegation of __specials__ for a proxying type.N)rb   __del____getattribute____metaclass__r  r  c                    g | ]B}|                     d           r+|                    d           rt          |          s|v@|CS )r   )
startswithendswithr   )ry   rE   into_clsskips     r2   re  z0monkeypatch_proxied_specials.<locals>.<listcomp>  sl     	
 	
 	
T""		

 JJt$$	
  !,,	
 TMM  "MMr3   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)r  r:   r   r	   r   r   r  r   r   rA  r  localsr   r   setattr)r  from_clsr  onlyr   from_instancedundersrI  maybe_fnr   r   fn_argsd_argspyr   s   ` `            r2   monkeypatch_proxied_specialsr    s     
<D	
 	
 	
 	
 	
]]	
 	
 	
  / /	x00H8Z00 xX>>He((33BB 	 	 	H		%044D247;;G1$q'!""+>>FF 	% 	% 	%+G$FFF	%
35;XX> 	 %?4*?E2 	 	R	')CK$$ 	 	 	D	&#f+....?/ /s<    A;+A;;
BBACC.-C.D00
D=<D=c                F    t          | d|           t          |d|          u S )z;Return True if the two methods are the same implementation.r   )r:   )meth1meth2s     r2   methods_equivalentr    s0     5*e,,z51 1  r3   c           	     J   |s|st          d          t          |t                    rt          | |          r| S t          |pd t	          |          D                       }t          t	          |                     }t
          j        }t          |t                    r|}n,|st                      }t
          j        }nt          |          } ||                    |          |          r| S t          | t                    s<|t
          j        u rdpd}t          | d|dd
                    |                     G d d	          }|rd
|j        z   |_        t                      }	t          |           D ]r\  }
}|
|vrt          d|
z            t          |          st          |
d|d          t          ||
t          |                     |	                    |
           s ||	|          r|S t          dd
                    ||	z
            z            )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                <    g | ]}|                     d           |S )r  )r  )ry   rE   s     r2   re  z as_interface.<locals>.<listcomp>  s)    MMMa1<<;L;LMMMMr3   zany ofzall ofz does not implement z: rm  c                      e Zd ZdZdS )(as_interface.<locals>.AnonymousInterfacezA callable-holding shell.Nr^   r_   r`   ra   rc   r3   r2   AnonymousInterfacer    s        ''''r3   r  	Anonymousz%r: unknown in this interfacer5  z is not callablez,dictionary does not contain required keys %s)r  r6   r7   rh   r  operatorgegtintersectionr   r|   r^   dictlike_iteritemsr@  r  staticmethodrj   )r*   rd   rP  required	interfaceimplementedcomplies	qualifierr  foundrI  r   s               r2   as_interfacer    sx   B  Nw NLMMM#t C!5!5 
GMMM3s88MMMNNIc#hh--K{H(D!! ! !55;x==x((33X>> 
 c4   
+8DH	ssIIItyy3335
 
 	

( ( ( ( ( ( ( (  A&1CL&@#EEE*3//  "";fDEEE~~ 	FvvvtttDEEE"FL,>,>???		&xx   "!!
6
))Hu$
%
%	&  r3   _GFDzgeneric_fn_descriptor[Any]c                      e Zd ZU dZded<   ded<   ded<   dd d
Zed!d            Zed"d            Zd#dZerd$dZ	d%dZ
d&dZe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]ra   r>   r^   Ndocc                H    || _         |p|j        | _        |j        | _        d S r.   r  ra   r^   rO   r  r  s      r2   r   zgeneric_fn_descriptor.__init__<  s$    	*dlr3   rO   r  r*   rJ   rd   r   r+   c                    d S r.   rc   rO   r*   rd   s      r2   __get__zgeneric_fn_descriptor.__get__A      r3   rH  r"   c                    d S r.   rc   r  s      r2   r  zgeneric_fn_descriptor.__get__E  r  r3   Union[_GFD, _T_co]c                    t                      r.   NotImplementedErrorr  s      r2   r  zgeneric_fn_descriptor.__get__I      !###r3   instancerS   c                    d S r.   rc   rO   r  rS   s      r2   __set__zgeneric_fn_descriptor.__set__N      Cr3   c                    d S r.   rc   )rO   r  s     r2   
__delete__z generic_fn_descriptor.__delete__Q  r  r3   c                    t                      r.   r  rO   r*   s     r2   _resetzgeneric_fn_descriptor._resetT  r  r3   r   c                    t                      r.   r  rd   r*   r   s      r2   resetzgeneric_fn_descriptor.resetW  s    !###r3   r.   )r  r  r  r  )rO   r  r*   rJ   rd   r   r+   r  )r*   rH  rd   r   r+   r"   )rO   r  r*   r   rd   r   r+   r  r  r   rS   r   r+   rJ   r  r   r+   rJ   )r*   r   r+   rJ   )r*   r   r   r>   r+   rJ   )r^   r_   r`   ra   r5   r   r   r  r   r  r  r  classmethodr  rc   r3   r2   r  r  -  s          MMM& & & & &
    X    X$ $ $ $  	 	 	 		 	 	 	$ $ $ $ $ $ $ [$ $ $r3   r  c                       e Zd ZdZes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                4    || S |                      |          S r.   r  r  s      r2   r  z_non_memoized_property.__get__g  s    {99S>>!r3   N)r^   r_   r`   ra   r   r  rc   r3   r2   r  r  \  sA           "	" 	" 	" 	" 	"" "r3   r  c                  8    e Zd ZdZesd Zd Zed             ZdS )_memoized_propertyz2A read-only @property that is only evaluated once.c                V    || S |                      |          x|j        | j        <   }|S r.   )r  r8   r^   rO   r*   rd   results       r2   r  z_memoized_property.__get__r  s.    {3799S>>ACL'&Mr3   c                F    t                               || j                   d S r.   )r  r  r^   r  s     r2   r  z_memoized_property._resetx  s       dm44444r3   c                <    |j                             |d            d S r.   )r8   ri   r  s      r2   r  z_memoized_property.reset{  s     t$$$$$r3   N)	r^   r_   r`   ra   r   r  r  r  r  rc   r3   r2   r  r  m  s[        << 	 	 	5 5 5 % % [% % %r3   r  c                .      f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                z     | g|R i |fd}j         |_         j        |_        || j        j         <   S )Nc                     S r.   rc   ar  r  s     r2   memoz6memoized_instancemethod.<locals>.oneshot.<locals>.memo  s    Mr3   )r^   ra   r8   rO   r'  r  r  r  r   s       @r2   oneshotz(memoized_instancemethod.<locals>.oneshot  sc    D&4&&&2&&	 	 	 	 	 z%)bk"r3   r   )r   r  s   ` r2   memoized_instancemethodr    s.    	 	 	 	 	 '2&&&r3   c                      e Zd ZU dZesdZ e            Zded<   ddZ	ddZ
ddZ G d dee                   Ze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.

    rc   zFrozenSet[str]_memoized_keysr+   rJ   c                P    | j         D ]}| j                            |d            d S r.   )r   r8   ri   rO   r   s     r2   _reset_memoizationszHasMemoized._reset_memoizations  s9    ' 	* 	*DMdD))))	* 	*r3   c                0    | j         D ]}|| j        vsJ d S r.   )r   r8   r  s     r2   _assert_no_memoizationsz#HasMemoized._assert_no_memoizations  s4    ' 	- 	-Dt},,,,,	- 	-r3   r  r>   rS   r   c                <    || j         |<   | xj        |hz  c_        d S r.   )r8   r   )rO   r  rS   s      r2   _set_memoized_attributez#HasMemoized._set_memoized_attribute  s*    "cu$r3   c                  r    e Zd ZU dZded<   ded<   ded<   ddd
Zedd            Zedd            Zd ZdS )HasMemoized.memoized_attributezTA read-only @property that is only evaluated once.

        :meta private:

        Callable[..., _T]r  r  ra   r>   r^   Nr  c                H    || _         |p|j        | _        |j        | _        d S r.   r  r  s      r2   r   z'HasMemoized.memoized_attribute.__init__  s$    DI.$,DL MDMMMr3   rO   r'   r*   rJ   rd   r   r+   c                    d S r.   rc   r  s      r2   r  z&HasMemoized.memoized_attribute.__get__      Cr3   r!   c                    d S r.   rc   r  s      r2   r  z&HasMemoized.memoized_attribute.__get__  r  r3   c                    || S |                      |          x|j        | j        <   }|xj        | j        hz  c_        |S r.   )r  r8   r^   r   r  s       r2   r  z&HasMemoized.memoized_attribute.__get__  sF    {3799S>>ACL'&4=/1Mr3   r.   )r  r
  r  r  )rO   r'   r*   rJ   rd   r   r+   r'   )r*   r   rd   r   r+   r!   )r^   r_   r`   ra   r5   r   r   r  rc   r3   r2   memoized_attributer	    s         	 	 	 	* 	* 	* 	* 	* 
	 	 	 
	 
	 	 	 
		 	 	 	 	r3   r  r   r$   c                0    dfd}t          |          S )zMDecorate a method memoize its return value.

        :meta private:

        rO   r   r'  r  r+   c                     | g|R i |fd}j         |_         j        |_        || j        j         <   | xj        j         hz  c_        S )Nc                     S r.   rc   r  s     r2   r  zBHasMemoized.memoized_instancemethod.<locals>.oneshot.<locals>.memo  s    r3   )r^   ra   r8   r   r  s       @r2   r  z4HasMemoized.memoized_instancemethod.<locals>.oneshot  s{    R*t***r**F     KDM:DL)-DM"+&BK=0Mr3   )rO   r   r'  r   r  r   r+   r   r   )rd   r   r  s    ` r2   r  z#HasMemoized.memoized_instancemethod  s3    
	 
	 
	 
	 
	 
	 gr***r3   Nr]   )r  r>   rS   r   r+   rJ   r   r$   r+   r$   )r^   r_   r`   ra   r   rb   	frozensetr   r5   r  r  r  memoized_propertyr!   r  r  r  rc   r3   r2   r  r    s          
   	%.Y[[N0000* * * *- - - -% % % %    .r2   @ + + + [+ + +r3   r  c                  $    e Zd ZdZdZd Z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__.

    rc   c                     t          |          r.   )r  )rO   r  s     r2   _fallback_getattrzMemoizedSlots._fallback_getattr  s    S!!!r3   r  r>   r+   r   c                                         d          s                     d          rt                    t           j        d           r. t	           d                       }t           |           |S t           j        d           r(t	           d            fd}j        |_        |S                                S )N_memoized_attr__memoized_method_c                 v     | i |fd}j         |_         j        |_        t          |           S )Nc                     S r.   rc   r  s     r2   r  z8MemoizedSlots.__getattr__.<locals>.oneshot.<locals>.memo(  s    !Mr3   )r^   ra   r  )r'  r  r  r  r   r  rO   s      @r2   r  z*MemoizedSlots.__getattr__.<locals>.oneshot%  sY    TR" " " " " !#!zc4(((r3   )r  r  r   r   r:   r  ra   r  )rO   r  rS   r  r   s   ``  @r2   __getattr__zMemoizedSlots.__getattr__  s   >>+,, 	/1
 1
 	/ !%%% T^%<s%<%<== 	/:GD"9C"9"9::<<ED#u%%%LT^%>%>%>?? 	/838899B	 	 	 	 	 	 	 !jGON))#...r3   N)r  r>   r+   r   )r^   r_   r`   ra   rb   r  r   rc   r3   r2   r  r  	  sH          I" " "/ / / / / /r3   r  c                    t          | t                    rD|                                                                 } | dv rdS | dv rdS t	          d| z            t          |           S )N)trueyesonyt1T)falsenooffrz   f0FzString is not true/false: %r)r6   r>   striprx   
ValueErrorr   r1   s    r2   asboolr/  7  sp    #s Ciikk!!66649995;cABBB99r3   text!Callable[[str], Union[str, bool]]c                      d f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                .    | v r| S t          |           S r.   )r/  )r*   r0  s    r2   bool_or_valuez"bool_or_str.<locals>.bool_or_valueI  s    $;;J#;;r3   )r*   r>   r+   r3  rc   )r0  r5  s   ` r2   bool_or_strr6  C  s)          r3   rS   Optional[int]c                (    | | S t          |           S )zCoerce to integer.)r   )rS   s    r2   asintr9  R  s     }u::r3   r  r  rQ   
flexi_booldestOptional[Dict[str, Any]]rJ   c                    || }|| v rnt          |t                    rt          | |         |          sG| |         =|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)r6   r7   r   r/  )r  r  rQ   r:  r;  s        r2   coerce_kw_typer>  Z  s     | 	r		E4(( 	0:2c7E0J0J 	sGD==Z=r#wDIIIbgDIII 		 		r3   c                `     t          |          }|ft           fd|D                       z   S )zbProduce a tuple structure that is cacheable using the __dict__ of
    obj to retrieve values

    c              3  H   K   | ]}|j         v |j         |         fV  d S r.   r8   ry   kr*   s     r2   r{   z"constructor_key.<locals>.<genexpr>z  sC        !"qCL/@/@CLO/@/@/@/@ r3   )r  r   )r*   rd   r   s   `  r2   constructor_keyrD  t  sS    
 3E6E    &+      r3   r'  c                     t          |          }|                     f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  H   K   | ]}|j         v |j         |         fV  d S r.   rA  rB  s     r2   r{   z#constructor_copy.<locals>.<genexpr>  sC        !"a3<>O>OCLO>O>O>O>O r3   )r  rC   
difference)r*   rd   r'  r  r   s   `    r2   constructor_copyrH    ss     3EII    &+&6&6r&:&:      3r3   Callable[[], int]c                 d    t          j                    t          j        d          fd} | S )z%Return a threadsafe counter function.r   c                 Z    5  t                     cd d d            S # 1 swxY w Y   d S r.   )next)counterlocks   r2   _nextzcounter.<locals>._next  sv     	! 	!==	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s    $$)	threadingLockr   count)rO  rM  rN  s    @@r2   rM  rM    sG     >Doa  G! ! ! ! ! ! Lr3   specimenrg  Optional[Type[Any]]c                   t          | d          r/| j        !t          | j        t                    rt          S | j        S t	          | t
                    rt          nt          } || t                    rt          S  || t                    rt          S  || t                    rt          S t          | d          rt          S t          | d          rt          S t          | d          rt          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   rj   rh   )r   rV  r  rh   r6   r7   r   r   )rS  rg  isas      r2   duck_type_collectionrX    s     x(( ) ,!32
 2
, J(("8T22
B**
C
s8T 	Xs		 
	Xt		 x"" 	5	!	! 
	5	!	! r3   r   argtype'Union[Tuple[Type[Any], ...], Type[Any]]r   c           
     6   t          | |          r| S t          |t                    rHt          j        d|dd                    d |D                       dt          |           d          t          j        d|d|dt          |           d          )	Nz
Argument 'z ' is expected to be one of type z or c              3      K   | ]	}d |z  V  
dS )z'%s'Nrc   )ry   r  s     r2   r{   z"assert_arg_type.<locals>.<genexpr>  s&      $A$AAVaZ$A$A$A$A$A$Ar3   z, got ''z' is expected to be of type 'z', got ')r6   r   r    ArgumentErrorr|   r7   )r   rY  r   s      r2   assert_arg_typer_    s     #w 
gu%% 		##44$A$A$A$A$AAAAA49999N  
 ##44$s))))-  r3   c           	         t           d          r!t                                                     S t           dt           dd                    t	          d z            t           d          r fd} |            S t           d          r-t          fd	                                 D                       S t	          d z            )
z?Return a (key, value) iterator for almost any dict-like object.rs  __getitem__r9   NzObject '%r' is not dict-likeiterkeysc               3  `   K                                    D ]} J |  |           fV  d S r.   )rb  )r  dictlikegetters    r2   iteratorz$dictlike_iteritems.<locals>.iterator  sT      ((** ' ')))66#;;&&&&&' 'r3   r  c              3  2   K   | ]}| |          fV  d S r.   rc   )ry   r  re  s     r2   r{   z%dictlike_iteritems.<locals>.<genexpr>  s0      BB3S&&++&BBBBBBr3   )r   r   rs  r:   r  iterr  )rd  rf  re  s   ` @r2   r  r    s     x!! &HNN$$%%%X}ght.L.LMMF~6ABBBx$$ C	' 	' 	' 	' 	' 	'
 xzz	6	"	" CBBBB(--//BBBBBB6ABBBr3   c                  :     e Zd ZU dZded<   d fdZdddZ x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]r  r   r   r  c                Z     t                      j        |g|R i | |j        | _        d S r.   )superr   ra   )rO   r  r   r  r   s       r2   r   zclassproperty.__init__  s7    ****r***|r3   Nr*   rd   Optional[type]r+   c                ,    |                      |          S r.   r  r  s      r2   r  zclassproperty.__get__  s    yy~~r3   )r  rk  r   r   r  r   r.   )r*   r   rd   rn  r+   r   )r^   r_   r`   ra   r5   r   r  __classcell__r   s   @r2   rj  rj    sp           $ $ $ $ $ $        r3   rj  c                  &    e Zd ZddZdd	ZddZdS )hybridpropertyr  r
  c                "    || _         || _        d S r.   )r  clslevelrO   r  s     r2   r   zhybridproperty.__init__  s    	r3   r  r   ownerr+   r!   c                ^    ||                      |          }|S |                     |          S r.   ru  r  rO   r  rw  clsvals       r2   r  zhybridproperty.__get__  0    ]]5))FM99X&&&r3   r   hybridproperty[_T]c                    || _         | S r.   ru  rv  s     r2   
classlevelzhybridproperty.classlevel	      r3   Nr  r
  r  r   rw  r   r+   r!   )r  r   r+   r}  )r^   r_   r`   r   r  r  rc   r3   r2   rs  rs    sP           ' ' ' '     r3   rs  c                  6    e Zd ZddZdd	ZddZddZddZdS )rw_hybridpropertyr  r
  c                0    || _         || _        d | _        d S r.   )r  ru  setfnrv  s     r2   r   zrw_hybridproperty.__init__  s    	37


r3   r  r   rw  r+   r!   c                ^    ||                      |          }|S |                     |          S r.   ry  rz  s       r2   r  zrw_hybridproperty.__get__  r|  r3   rS   rJ   c                D    | j         J |                      ||           d S r.   r  r  s      r2   r  zrw_hybridproperty.__set__  s*    z%%%

8U#####r3   r   rw_hybridproperty[_T]c                    || _         | S r.   r  rv  s     r2   setterzrw_hybridproperty.setter  s    
r3   c                    || _         | S r.   r  rv  s     r2   r  zrw_hybridproperty.classlevel#  r  r3   Nr  r  r  )r  r   r+   r  )r^   r_   r`   r   r  r  r  r  rc   r3   r2   r  r    sx        8 8 8 8
' ' ' '$ $ $ $        r3   r  c                  *    e Zd ZdZddZdd	ZddZdS )hybridmethodz/Decorate a function as cls- or instance- level.r  r
  c                0    |x| _         | _        || _        d S r.   )r  r   ru  rv  s     r2   r   zhybridmethod.__init__+  s    $((	DMr3   r  r   rw  r+   c                |    | | j                             ||j                  S | j                            ||          S r.   )ru  r  r   r  )rO   r  rw  s      r2   r  zhybridmethod.__get__/  s:    =((@@@9$$Xu555r3   r   hybridmethod[_T]c                    || _         | S r.   r  rv  s     r2   r  zhybridmethod.classlevel5  r  r3   Nr  )r  r   rw  r   r+   r
  )r  r   r+   r  )r^   r_   r`   ra   r   r  r  rc   r3   r2   r  r  (  sV        99   6 6 6 6     r3   r  c                  j    e Zd ZU dZded<   i Zded<    ej                    Z	 	 dddZ	d Z
d Z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]symbolsNr  r  	canonicalr7  r+   c                   | j         5  | j                            |          }|ct          |t                    sJ |t          |          }t                              t          |          }||_	        |r||_
        || j        |<   n|r||k    rt          d| d|           |cd d d            S # 1 swxY w Y   d S )Nz#Can't replace canonical symbol for z with new int value )_lockr  r9   r6   r>   hashr   __new__r  r   ra   r  )rd   r   r  r  r   s        r2   r  zsymbol.__new__N  s0    Y 	 	+//$''C{!$,,,,,$ $T

Ikk&)44 &"%CK %(D!! c!1!1#:d : :.7: :   -	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   BB33B7:B7c                >    t           | j        dt          |           ffS )Nr=   )r  r   r   rN   s    r2   
__reduce__zsymbol.__reduce__l  s    	3D		222r3   c                     t          |           S r.   rj  rN   s    r2   __str__zsymbol.__str__o  s    Dzzr3   c                    d| j         dS )Nzsymbol(rn  r   rN   s    r2   __repr__zsymbol.__repr__r  s    '''''r3   )NN)r   r>   r  r  r  r7  r+   r  )r^   r_   r`   ra   r5   r  rP  rQ  r  r  r  r  r  rc   r3   r2   r  r  :  s           III!#G####INE
 "#'	    <3 3 3  ( ( ( ( (r3   r  c                      e Zd ZddZddZdS )_IntFlagMeta	classnamer>   r   Tuple[Type[Any], ...]dict_r   r  r   r+   rJ   c                v   g x| _         }|                                D ]w\  }}t          |t                    rt	          ||          }n%|                    d          st          d          Qt          | ||           |                    |           xt          j
        d |D                       | _        d S )N)r  r  z#Expected integer values for IntFlagc                    i | ]
}|j         |S rc   r  )ry   r   s     r2   
<dictcomp>z)_IntFlagMeta.__init__.<locals>.<dictcomp>  s    ,,,sSXs,,,r3   )_itemsrs  r6   r   r  r  r  r  r   r   immutabledict__members__)	rd   r  r   r  r  rs  rC  vr   s	            r2   r   z_IntFlagMeta.__init__w  s      
UKKMM 	 	DAq!S!! Q!,,,\\#&&  EFFFCC   LL&4,,e,,,
 
r3   Iterator[symbol]c                     t          d          )Nziter not implemented to ensure compatibility with Python 3.11 IntFlag.  Please use __members__.  See https://github.com/python/cpython/issues/99304r  rN   s    r2   __iter__z_IntFlagMeta.__iter__  s    !=
 
 	
r3   N)
r  r>   r   r  r  r   r  r   r+   rJ   )r+   r  )r^   r_   r`   r   r  rc   r3   r2   r  r  v  s<        
 
 
 
.
 
 
 
 
 
r3   r  c                      e Zd ZdZdS )_FastIntFlagzAn 'IntFlag' copycat that isn't slow when performing bitwise
    operations.

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

    Nr  rc   r3   r2   r  r    s           r3   r  )	metaclass)IntFlag_EchoicesDict[_E, List[Any]]resolve_symbol_namesOptional[_E]c                    |                                 D ]&\  }}| |u r|c S |r| |j        k    r|c S | |v r|c S '| dS t          j        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': )rs  r   r    r^  )r   r  r   r  
enum_valuechoices         r2   parse_user_argument_for_enumr    s    ( &mmoo  
F*! 	cZ_&<&<F]]  {t

B$BB3BB
C
CCr3   r  c                2    t           | _         t           dz  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  s    r2   set_creation_orderr    s      /HqOOOr3   rW  c                    	  | |i |S # t           $ r/ t          dt          j                    dd         z             Y dS w xY w)zXexecutes the given function, catches all exceptions and converts to
    a warning.

    z%s('%s') ignoredr   r   N)rr   warnrL   rM   )r  r'  rW  s      r2   warn_exceptionr    sc    
7tT$V$$$ 7 7 7#,..1"556666667s   
 5AA   c                l    	 t          |           |k    rd| d|         z  S | S # t          $ r | cY S w xY w)Nz%s...r   )rB  r  )rS   len_s     r2   ellipses_stringr    sT    u::U1T6]**L   s   $ $ 33c                  @     e Zd ZU dZded<   d fd
ZddZddZ x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   _hashrS   r>   numr'  Sequence[Any]r+   c                    ||z  d|z  z   }t                                          | |          }t          d|t          |          |z  fz            |_        |S )Nz6 (this warning may be suppressed after %d occurrences)z%s_%d)rm  r  r  r  )rd   rS   r  r'  interpolatedrO   r   s         r2   r  z_hash_limit_string.__new__  s_     DsJ
 wwsL11'UD,>,>,D$EEFF
r3   c                    | j         S r.   )r  rN   s    r2   __hash__z_hash_limit_string.__hash__	  s
    zr3   otherr   r   c                B    t          |           t          |          k    S r.   )r  )rO   r  s     r2   __eq__z_hash_limit_string.__eq__  s    DzzT%[[((r3   )rS   r>   r  r   r'  r  r+   r  )r+   r   )r  r   r+   r   )	r^   r_   r`   ra   r5   r  r  r  rp  rq  s   @r2   r  r    s|           JJJ        ) ) ) ) ) ) ) )r3   r  msgr  c                    |r%t          t          j        | |                     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   s     r2   r  r    sG      +s}St44455555sCM*****r3   r  c                `    |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    r  )r  r'  s     r2   warn_limitedr    s5    
  0 b$//3&&&&&r3   z)Dict[CodeType, Tuple[str, Type[Warning]]]_warning_tagsmessagecategoryType[Warning]Callable[[_F], _F]c                      fd}|S )Nc                *    ft           | j        <   | S r.   )r  r  )r   r  r  s    r2   goz#tag_method_for_warnings.<locals>.go-  s    &-x%8bk"	r3   rc   )r  r  r  s   `` r2   tag_method_for_warningsr  *  s)          Ir3   z&^(?:sqlalchemy\.(?!testing)|alembic\.)Union[str, Warning]Optional[Type[Warning]]
stacklevelc                   	 t          j        |          }dx}}|~|s5t          j        t          |j                            dd                    sd}|j        t          v r#d}t          |j                 \  }}|p|}|  d| d} |j	        }|s|dz  }n|r|rn|~n# t          $ r d}Y n d}Y nxY w|t          j        | ||dz   	           d S t          j        | |dz   	           d S )
NFr^   rG  Tz (rn  r   r   )r  )rL   	_getframer}   match_not_sa_pattern	f_globalsr9   f_coder  f_backr.  warningsr  )r  r  r  framestacklevel_foundwarning_tag_found_suffix	_categorys           r2   r  r  7  s]   %j)) 054, $ (BH!4!4Z!D!D- - (
 $( 
 |},,$(!'4U\'B$)#0y$22222LE# a

! &7 3      


 


< gxJNCCCCCCg*q.999999s   B B.)B.r
  retry_on_exceptionCallable[..., Optional[_T]]c                "      gd fd}|S )zNDecorate the given function to be a no-op after it is called exactly
    once.r   r   r  r+   Optional[_T]c                     }r;                                 }	  || i |S #  r                    d|            xY wd S )Nr   )ri   insert)r   r  	strong_fnonce_fnr   oncer  s       r2   r  zonly_once.<locals>.gor  sf     	 	hhjjGw*r***% ,KK7+++ts   # >)r   r   r  r   r+   r  rc   )r   r  r  r  s   `` @r2   	only_oncer  j  s=     4D        Ir3   z%sqlalchemy/([a-z_]+/){0,2}[a-z_]+\.pyzunit(?:2|test2?/)tbexclude_prefixre.Pattern[str]exclude_suffixc                `   d}t          |           dz
  }||k    rA|                    | |                   r&|dz  }||k    r|                    | |                   &||k    rA|                    | |                   r&|dz  }||k    r|                    | |                   &| ||dz            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   )rB  search)r   r  r  r   ends        r2   chop_tracebackr    s    " E
b''A+C
3,,>00E;;,
 3,,>00E;;,
3,,>00C99,q 3,,>00C99,ecAgor3   c                |    d| z  }t                                                      }t          ||           |d         S )Nz&def set(obj, value):    obj.%s = valuerh   )r  copyr   )attrnamer   r   s      r2   
attrsetterr    s4    6AD
((--//CsOOOu:r3   c                  (     e Zd ZdZdZd fdZ xZS )
TypingOnlyzA mixin class that marks a class as 'typing only', meaning it has
    absolutely no methods, attributes, or runtime functionality whatsoever.

    rc   r+   rJ   c                    t           | j        v rAt          | j                                      h d          }|rt          d|  d| d          t                                                       d S )N>   ra   rb   r_   __orig_bases__r5   zClass z< directly inherits TypingOnly but has additional attributes r   )r  r  rh   r8   rG  AssertionErrorrm  __init_subclass__)rd   	remainingr   s     r2   r  zTypingOnly.__init_subclass__  s    &&CL))44   I  $:S : :-6: : :   	!!#####r3   r]   )r^   r_   r`   ra   rb   r  rp  rq  s   @r2   r  r    sN         
 I$ $ $ $ $ $ $ $ $ $r3   r  c                  J     e Zd ZU dZded<   	 d
 fdZedd	            Z x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+   rJ   c                2   | j         }| j        }|re|D ]b}t          j        ||          }|rI||         }t	          j        |          }|j        s&|                     |          }t          | ||           ct                      
                                 d S r.   )r  r8   r}   r  r   r   r)  
_wrap_w_kwr  rm  r  )	rd   fn_regclsdictr  rE   r   r   wrappedr   s	           r2   r  zEnsureKWArg.__init_subclass__  s    !, 	3 3 3HVS)) 3 B!8<<D: 3"%.."4"4S'222!!#####r3   r   r   c                0    dfd}t          |          S )Nr   r   r  r+   c                      |  S r.   rc   )r   r  r   s     r2   wrapz$EnsureKWArg._wrap_w_kw.<locals>.wrap  s    2s8Or3   )r   r   r  r   r+   r   r   )rd   r   r  s    ` r2   r  zEnsureKWArg._wrap_w_kw  s3    	 	 	 	 	 	 dB'''r3   r]   )r   r   r+   r   )	r^   r_   r`   ra   r5   r  r  r  rp  rq  s   @r2   r  r    s|           $ $ $ $ $ $ ( ( ( [( ( ( ( (r3   r  c                0   t          |d          rt          | |          S | }|j        j        |_        t          |d          r|j        |_        t          |j        d          r|j        j        r|j        j        |_        n|j        r|j        |_        |S )zAugment functools.update_wrapper() to work with objects with
    a ``__call__()`` method.

    :param fn:
      object with __call__ method

    r^   r_   ra   )r   r   r   r^   r_   r%  ra   )wrapperr   _fs      r2   wrap_callabler!    s     r: gr***l+2|$$ 	*MBM2;	** 	$r{/B 	$,BJJZ 	$BJ	r3   c                   d| vr|                      d          S d}g g}d}t          |           }||k     r| |         }|dk    rE|dk    r9||dz
  k     r0| |dz            dk    r!|d                             d           |dz  }nC|dz  }n=|dk    r|dk    r|                    g            n|d                             |           |dz  }||k     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                8    g | ]}d                      |          S )rG  )r|   )ry   r   s     r2   re  z'quoted_token_parser.<locals>.<listcomp>1  s"    ///uBGGENN///r3   )r   rB  r   )rS   r  r  idxlvchars         r2   quoted_token_parserr(    s   $ %{{3 E!dF
C	UB
((Sz3;;zzcBFlluS1W~/D/Dr
!!#&&&q
S[[UaZZMM"2Jd###q (( 0/////r3   paramsc                >     t          j                     fd}|S )Nc                v    | j         d ur| j         pd}|rt          |fdD                       }|| _         | S )NrG  c                    i | ]}|S rc   rc   )ry   paramr0  s     r2   r  z8add_parameter_text.<locals>.decorate.<locals>.<dictcomp>:  s    )J)J)J%%)J)J)Jr3   )ra   inject_param_text)r   r  r)  r0  s     r2   r   z$add_parameter_text.<locals>.decorate7  sT    j$39r 	L#C)J)J)J)J6)J)J)JKKC
	r3   )r   ro  )r)  r0  r   s   `` r2   add_parameter_textr/  4  s9    !&))F      Or3   c                    |                      dd          }t          |          dk    r| S |\  }}|                    d          s|dz   t          j        |          z   S t          j        |           S )N
r   rv   )r   rB  r  textwrapdedent)r0  
split_text	firstliner  s       r2   _dedent_docstringr6  A  su    D!$$J
:!)	9$$ %4(/)"<"<<<t$$$r3   given_doctext
injecttextposc                ,   t          | pd          }|                    d          }t          |          dk    r|                    d           t	          j        |                              d          }|d         r|                    dd           d t          |          D             }|                    dd           |t          |t          |          dz
                     }|d|         |z   ||d          z   }d	                    |          S )NrG  r1  r   r   c                @    g | ]\  }}|                                 |S rc   )r-  )ry   r  lines      r2   re  z)inject_docstring_text.<locals>.<listcomp>X  s)    HHHic44::<<HcHHHr3   )
r6  r   rB  r   r2  r3  r  rq  minr|   )r7  r8  r9  doctextlinesinjectlinesblanks
inject_poss           r2   inject_docstring_textrC  M  s    %]%8b99GMM$E
5zzQR/*--33D99K1~ "1b!!!HH9U#3#3HHHF
MM!QCVq112J!J,+-jkk0BBE99Ur3   z(\s+):param (.+?):r>  inject_paramsDict[str, str]c                z   t          j        |                                           }g }d }|rz|                                }t                              |          }||r|                    d                              d          }||v rwdt          |                    d                    z  dz   }|rBt          j        d|d                   }	|	r%dt          |	                    d                    z  }|||         z   }n|r|
                    d|dg           d }no|                                s|
                    ||dg           d }n@|                    d          r+|
                    ||                                g           e|                    |           |zd                    |          S )	Nr   *rv   r   z(\s+)\Sr   r1  z::)collectionsdeque
splitlinespopleft
_param_regr  r   lstriprB  r}   rk   rstripr  r   r|   )
r>  rD  doclinesr?  	to_injectr<  rE   r-  indentm2s
             r2   r.  r.  d  s    !3!3!5!566HE I
 !!T"" >

))#..M)) 3qwwqzz??2S8F   <Xj(1+>> <%(3rxx{{+;+;%;F &u)= =I 
	LL$	40111II 	LL$	40111II]]4   	 LL$ 0 0 2 23444T?  B 99Ur3   r   c                *   t          |           dk    rdS t          |           dk    }|r
| dd         n| dd         | dd         z   } d | D             }|rd                    |          S d                    |dd                   d|d         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   Nr2  r   r?  c                R    g | ]$}t          |          d k    rd|dd          z  n|%S )   z%s..N)rB  )ry   r   s     r2   re  z$repr_tuple_names.<locals>.<listcomp>  s8    
L
L
LdTR6D"IT
L
L
Lr3   rm  z, ..., )rB  r|   )r   flagress      r2   repr_tuple_namesrX    s     5zzQtu::?D;E!A#JJE!A#Jrss$;E
L
Le
L
L
LC >yy~~ $		#ac( 3 3 3 3SWW==r3   c                :    t           rdS | rt          d          dS )NTzDcython extensions were expected to be installed, but are not presentF)r   ImportError)raise_s    r2   has_compiled_extr\    s5     t	 "
 
 	

 ur3   )r*   r   r+   r,   )r=   r   r+   r>   )rd   re   r+   rf   )rp   r   r+   r>   )rd   rt   r+   r>   )r   r   r   r   r+   r   )r   r   r+   r   )r   r   r   r>   r+   r   )r   r   rz   r   r+   r   )r   r   r+   r   )r   r   r   r   r   r>   r+   r   )rd   r7   r  r  r  r  r+   r  )rd   r7   r  r  r  r   r+   r  )r  r   r+   r  )FF)r   r   r!  r   r"  r   r+   r#  )T)r   r/  r   r   r+   r0  )rc   rc   rc   )rL  rt   rM  r>   rN  r>   rO  r   rP  r   rQ  r   r+   rR  )rc   Nrc   )
r*   r   r]  r^  r_  r`  ra  r   r+   r>   )NNr  N)NNNr  )r*   r   r+   r   )r0  r>   r+   r1  )rS   r   r+   r7  )TN)r  r   r  r>   rQ   rt   r:  r   r;  r<  r+   rJ   )r*   r   rd   rt   r+   r   )
r*   r!   rd   re   r'  r   r  r   r+   r!   )r+   rI  r.   )rS  r   rg  rT  r+   rT  )r   r   rY  rZ  r   r>   r+   r   )F)
r   r   r  r  r   r>   r  r   r+   r  r  )r  r   r'  r   rW  r   r+   r   )r  )r  r>   r   r  r+   rJ   )r  r>   r'  r  r+   rJ   )r  r>   r  r  r+   r  )Nr   )r  r  r  r  r  r   r+   rJ   )r   r
  r  r   r+   r  )r   r  r  r  r  r  r+   r  )r)  r   r0  r>   r+   r  )r0  r>   r+   r>   )r7  r  r8  r>   r9  r   r+   r>   )r>  r>   rD  rE  r+   r>   )r   r  r+   r  )ra   
__future__r   rH  enum	functoolsr   rA   r/   r   r  r}   rL   r2  rP  r   r   typingr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  rG  r   r   _has_cyr   r   r    r!   r"   r$   r&   r'   r(   r)   py310r0   rF   rH   ro   rs   r   r   r   r   r   r   r   r   r   r   r   r   r
  r  r   r.  r   rK  rU  rX  r\  r{  r}  r  r  r  r  r  r  r  r  r  r  non_memoized_propertypropertyro_memoized_propertyro_non_memoized_propertyr  r  !HasMemoized_ro_memoized_attributer  r  r/  r6  r9  r>  rD  rH  rM  rX  r_  r  rj  rs  r  r  r   r  r7   r  r  r  FastIntFlagEnumr  r  r  r  r  r  r>   r  r  r  r  r5   r  compiler  r  r  _SQLA_RE_UNITTEST_REr  NoneTyper  r  r  r!  r(  r/  r6  rC  rL  r.  rX  r\  rc   r3   r2   <module>rn     s     # " " " " "      $ $ $ $ $ $        				 



                                                                                                                                                  $ $ $ $ $ $            WT]]4(((WT#s(+,,,ge3444ge@AAAge0111ge./// 
< 2, , , , ,
2 2 2 2"   82 82 82 82 82 82 82 82v   6 6 6 6   , , , ,$   M M M M     ge/000
=, =, =, =,@  *    genngenn%  %  %  %  %  %  %  % P
 
 
( 
  $!	     
 
-1E     
 .2E2 2 2 2 2 2j2 2 2 2 EJ7; 7; 7; 7; 7;v HLr
 r
 r
 r
 r
j   F #% "    06 6 6$	 	 	 028< "	KB KB KB KB KB\; ; ; ; ; ; ; ;<# # #L  & 
		@/ @/ @/ @/F  S S S Sl wv9:::,$ ,$ ,$ ,$ ,$GEN ,$ ,$ ,$^" " " " "259 " " ""% % % % %.u5 % % %<  N .1
 $' 0BA,7MM4' ' ' '.M+ M+ M+ M+ M+ M+ M+ M+`  G(0%%(3(F%*/ */ */ */ */ */ */ */\	 	 	 	       %)' ' ' ' '4          37         F   $C C C0    H   *    WR[   "       4    72;   $9( 9( 9( 9( 9(S 9( 9( 9(x
 
 
 
 
4 
 
 
@    \      KKK WT### "'	D D D D DD 
 
 
 
7 7 7 7   ) ) ) ) ) ) ) )<
+ 
+ 
+ 
+ 
+' ' ' ' <> = = = =    "*FGG
 )-0: 0: 0: 0: 0:f   4 2:>??rz.//
 '3&.    4 4::  $ $ $ $ $ $ $ $6&( &( &( &( &( &( &( &(R  0)0 )0 )0X
 
 
 
	% 	% 	% 	%   ( RZ-..
( ( ( (V> > > >	 	 	 	 	 	r3   