
    g                      d Z ddlm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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.m0Z0 dd-l1m2Z2 dd.l3m4Z4 dd/l3m5Z5 dd0l3m6Z6 dd1l3m7Z7 dd2l3m8Z8 ejr                  rdd3l*m:Z: dd4l*m;Z; dd5l<m=Z= dd6l>m?Z? dd7l>m@Z@  ed8e9      ZA ed:ed;<      ZB ed=ed;>      ZC ed?e9      ZD ed@e9      ZE edAe9      ZFddddddBdBe2j                  e2j                  e2j                  e2j                  e2j                  e2j                  e2j                  dC	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dydDZH G dE dFe%      ZI G dG dHe5eB         ZJ G dI dJe5      ZK G dK dLeKe5eC         ZL G dM dNeKe5eC         ZM G dO dPe5      ZN G dQ dReNe5eC         ZO G dS dTeNe5eC         ZP G dU dVe5eA         ZQ G dW dXe5      ZR G dY dZe5      ZS G d[ d\e5      ZT G d] d^e5eA         ZU G d_ d`e&j                  e'eA   e,eUeA         ZW edadb9      ZX G dc dde)eA         ZY G de dfeYeA         ZZ G dg dheYeA         Z[ G di djeYeA         Z\ G dk dleQeA         Z] edmdn9      Z^	  G do dpee^         Z_ G dq dre_eA         Z` G ds dte`eA   eeA         Za G du dve_eF   eeEeFf         Zb G dw dxe`eA   eeA         Zcy)zzContain the ``AssociationProxy`` class.

The ``AssociationProxy`` is a Python property object which provides
transparent proxied access to the endpoint of an association object.

See the example ``examples/association/proxied_association.py``.

    )annotationsN)AbstractSet)Any)Callable)cast)
Collection)Dict)Generic	ItemsView)Iterable)Iterator)KeysView)List)Mapping)MutableMapping)MutableSequence)
MutableSet)NoReturn)Optional)overload)Set)Tuple)Type)TypeVar)Union
ValuesView   )ColumnElement)exc)inspect)orm)util)collections)InspectionAttrExtensionType)
interfaces)ORMDescriptor)SQLORMOperations)_AttributeOptions)_DCAttributeOptions)_DEFAULT_ATTRIBUTE_OPTIONS)	operators)or_)_NoArg)Literal)Protocol)Self)SupportsIndex)SupportsKeysAndGetItem)MapperProperty)PropComparator)Mapper)_ColumnExpressionArgument)	_InfoType_T)bound_T_coT)r;   	covariant_T_con)r;   contravariant_S_KT_VTF)creatorgetset_factoryproxy_factoryproxy_bulk_setinfocascade_scalar_deletescreate_on_none_assignmentinitreprdefaultdefault_factorycomparekw_onlyhashc               J    t        | ||||||||t        |	|
|||||      
      S )a  Return a Python property implementing a view of a target
    attribute which references an attribute on members of the
    target.

    The returned value is an instance of :class:`.AssociationProxy`.

    Implements a Python property representing a relationship as a collection
    of simpler values, or a scalar value.  The proxied property will mimic
    the collection type of the target (list, dict or set), or, in the case of
    a one to one relationship, a simple scalar value.

    :param target_collection: Name of the attribute that is the immediate
      target.  This attribute is typically mapped by
      :func:`~sqlalchemy.orm.relationship` to link to a target collection, but
      can also be a many-to-one or non-scalar relationship.

    :param attr: Attribute on the associated instance or instances that
      are available on instances of the target object.

    :param creator: optional.

      Defines custom behavior when new items are added to the proxied
      collection.

      By default, adding new items to the collection will trigger a
      construction of an instance of the target object, passing the given
      item as a positional argument to the target constructor.  For cases
      where this isn't sufficient, :paramref:`.association_proxy.creator`
      can supply a callable that will construct the object in the
      appropriate way, given the item that was passed.

      For list- and set- oriented collections, a single argument is
      passed to the callable. For dictionary oriented collections, two
      arguments are passed, corresponding to the key and value.

      The :paramref:`.association_proxy.creator` callable is also invoked
      for scalar (i.e. many-to-one, one-to-one) relationships. If the
      current value of the target relationship attribute is ``None``, the
      callable is used to construct a new object.  If an object value already
      exists, the given attribute value is populated onto that object.

      .. seealso::

        :ref:`associationproxy_creator`

    :param cascade_scalar_deletes: when True, indicates that setting
        the proxied value to ``None``, or deleting it via ``del``, should
        also remove the source object.  Only applies to scalar attributes.
        Normally, removing the proxied target will not remove the proxy
        source, as this object may have other state that is still to be
        kept.

        .. versionadded:: 1.3

        .. seealso::

            :ref:`cascade_scalar_deletes` - complete usage example

    :param create_on_none_assignment: when True, indicates that setting
      the proxied value to ``None`` should **create** the source object
      if it does not exist, using the creator.  Only applies to scalar
      attributes.  This is mutually exclusive
      vs. the :paramref:`.assocation_proxy.cascade_scalar_deletes`.

      .. versionadded:: 2.0.18

    :param init: Specific to :ref:`orm_declarative_native_dataclasses`,
     specifies if the mapped attribute should be part of the ``__init__()``
     method as generated by the dataclass process.

     .. versionadded:: 2.0.0b4

    :param repr: Specific to :ref:`orm_declarative_native_dataclasses`,
     specifies if the attribute established by this :class:`.AssociationProxy`
     should be part of the ``__repr__()`` method as generated by the dataclass
     process.

     .. versionadded:: 2.0.0b4

    :param default_factory: Specific to
     :ref:`orm_declarative_native_dataclasses`, specifies a default-value
     generation function that will take place as part of the ``__init__()``
     method as generated by the dataclass process.

     .. versionadded:: 2.0.0b4

    :param compare: Specific to
     :ref:`orm_declarative_native_dataclasses`, indicates if this field
     should be included in comparison operations when generating the
     ``__eq__()`` and ``__ne__()`` methods for the mapped class.

     .. versionadded:: 2.0.0b4

    :param kw_only: Specific to :ref:`orm_declarative_native_dataclasses`,
     indicates if this field should be marked as keyword-only when generating
     the ``__init__()`` method as generated by the dataclass process.

     .. versionadded:: 2.0.0b4

    :param hash: Specific to
     :ref:`orm_declarative_native_dataclasses`, controls if this field
     is included when generating the ``__hash__()`` method for the mapped
     class.

     .. versionadded:: 2.0.36

    :param info: optional, will be assigned to
     :attr:`.AssociationProxy.info` if present.


    The following additional parameters involve injection of custom behaviors
    within the :class:`.AssociationProxy` object and are for advanced use
    only:

    :param getset_factory: Optional.  Proxied attribute access is
        automatically handled by routines that get and set values based on
        the `attr` argument for this proxy.

        If you would like to customize this behavior, you may supply a
        `getset_factory` callable that produces a tuple of `getter` and
        `setter` functions.  The factory is called with two arguments, the
        abstract type of the underlying collection and this proxy instance.

    :param proxy_factory: Optional.  The type of collection to emulate is
        determined by sniffing the target collection.  If your collection
        type can't be determined by duck typing or you'd like to use a
        different collection implementation, you may supply a factory
        function to produce those collections.  Only applicable to
        non-scalar relationships.

    :param proxy_bulk_set: Optional, use with proxy_factory.


    rC   rD   rE   rF   rG   rH   rI   attribute_options)AssociationProxyr*   )target_collectionattrrC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   s                   ^/var/www/html/AdoubleTech/venv/lib/python3.12/site-packages/sqlalchemy/ext/associationproxy.pyassociation_proxyrX   T   sD    r %#%5";+$'7D
     c                      e Zd ZdZy)AssociationProxyExtensionTypeASSOCIATION_PROXYN)__name__
__module____qualname__r\    rY   rW   r[   r[      s    +rY   r[   c                      e Zd ZddZy)_GetterProtocolc                     y Nr`   )selfinstances     rW   __call__z_GetterProtocol.__call__	      rY   N)rf   r   returnr<   r]   r^   r_   rg   r`   rY   rW   rb   rb     s    3rY   rb   c                      e Zd Zy)_SetterProtocolNr]   r^   r_   r`   rY   rW   rl   rl         rY   rl   c                      e Zd ZddZy)_PlainSetterProtocolc                     y rd   r`   )re   rf   values      rW   rg   z_PlainSetterProtocol.__call__  rh   rY   N)rf   r   rr   r>   ri   Nonerj   r`   rY   rW   rp   rp     s    ArY   rp   c                      e Zd ZddZy)_DictSetterProtocolc                     y rd   r`   )re   rf   keyrr   s       rW   rg   z_DictSetterProtocol.__call__  rh   rY   N)rf   r   rw   r   rr   r>   ri   rs   rj   r`   rY   rW   ru   ru     s    KrY   ru   c                      e Zd Zy)_CreatorProtocolNrm   r`   rY   rW   ry   ry     rn   rY   ry   c                      e Zd ZddZy)_PlainCreatorProtocolc                     y rd   r`   re   rr   s     rW   rg   z_PlainCreatorProtocol.__call__  rh   rY   N)rr   r>   ri   r   rj   r`   rY   rW   r{   r{     s    1rY   r{   c                      e Zd ZddZy)_KeyCreatorProtocolc                     y rd   r`   re   rw   rr   s      rW   rg   z_KeyCreatorProtocol.__call__!  rh   rY   N)rw   r   rr   zOptional[_T_con]ri   r   rj   r`   rY   rW   r   r      s    ErY   r   c                      e Zd Z	 	 ddZy)_LazyCollectionProtocolc                     y rd   r`   re   s    rW   rg   z _LazyCollectionProtocol.__call__%  s     rY   Nri   zCUnion[MutableSet[_T], MutableMapping[Any, _T], MutableSequence[_T]]rj   r`   rY   rW   r   r   $  s    
rY   r   c                       e Zd Z	 	 	 	 	 	 ddZy)_GetSetFactoryProtocolc                     y rd   r`   )re   collection_classassoc_instances      rW   rg   z_GetSetFactoryProtocol.__call__-  s     8;rY   N)r   Optional[Type[Any]]r   AssociationProxyInstance[Any]ri   ,Tuple[_GetterProtocol[Any], _SetterProtocol]rj   r`   rY   rW   r   r   ,  s#    ;-; 6; 
6	;rY   r   c                  (    e Zd Z	 	 	 	 	 	 	 	 	 	 ddZy)_ProxyFactoryProtocolc                     y rd   r`   )re   lazy_collectionrC   
value_attrparents        rW   rg   z_ProxyFactoryProtocol.__call__5  s     rY   N)
r   z_LazyCollectionProtocol[Any]rC   ry   r   strr   r   ri   r   rj   r`   rY   rW   r   r   4  s7    5 " 	
 . 
rY   r   c                       e Zd Z	 	 	 	 	 	 ddZy)_ProxyBulkSetProtocolc                     y rd   r`   )re   proxy
collections      rW   rg   z_ProxyBulkSetProtocol.__call__?  s    rY   N)r   _AssociationCollection[Any]r   Iterable[Any]ri   rs   rj   r`   rY   rW   r   r   >  s    0>K	rY   r   c                      e Zd ZU dZded<   ded<   ded<   ded<   ded	<   ded
<   ded<   ded<   ded<   ej                  dd       Z	 d	 	 	 	 	 ddZ	 	 	 	 ddZ	y)_AssociationProxyProtocolzpdescribes the interface of :class:`.AssociationProxy`
    without including descriptor methods in the interface.Optional[_CreatorProtocol]rC   r   rw   rU   r   boolrH   rI    Optional[_GetSetFactoryProtocol]rD   Optional[_ProxyFactoryProtocol]rE   Optional[_ProxyBulkSetProtocol]rF   c                     y rd   r`   r   s    rW   rG   z_AssociationProxyProtocol.infoR  s    !$rY   Nc                     y rd   r`   re   class_objs      rW   	for_classz#_AssociationProxyProtocol.for_classU  s    '*rY   c                     y rd   r`   )re   r   s     rW   _default_getsetz)_AssociationProxyProtocol._default_getsetY  s    7:rY   ri   r9   rd   r   	Type[Any]r   zOptional[object]ri   AssociationProxyInstance[_T]r   r   ri   r   )
r]   r^   r_   __doc____annotations__r$   ro_memoized_propertyrG   r   r   r`   rY   rW   r   r   D  s    > ('	HO  ##442233	$ $ :>++&6+	%+; #;	5;rY   r   c            	      *   e Zd ZdZdZej                  Zddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZe		 	 	 	 	 	 dd       Z
e		 	 	 	 	 	 dd       Z
e	dd	       Z
	 	 	 	 	 	 dd
Z
ddZddZ	 d	 	 	 	 	 ddZ	 	 	 	 	 	 ddZddZ	 	 	 	 ddZddZy)rT   zDA descriptor that presents a read/write view of an object attribute.TNFrR   c               h   || _         || _        || _        || _        || _        || _        |r|	rt        j                  d      || _        |	| _	        dt        |       j                  d|dt        |       | _        |r|| _        |
r|
t        k7  rd| _        |
| _        yd| _        t        | _        y)a(  Construct a new :class:`.AssociationProxy`.

        The :class:`.AssociationProxy` object is typically constructed using
        the :func:`.association_proxy` constructor function. See the
        description of :func:`.association_proxy` for a description of all
        parameters.


        z[The cascade_scalar_deletes and create_on_none_assignment parameters are mutually exclusive._TFN)rU   r   rC   rD   rE   rF   r!   ArgumentErrorrH   rI   typer]   idrw   rG   r,   _has_dataclass_arguments_attribute_options)re   rU   rV   rC   rD   rE   rF   rG   rH   rI   rS   s              rW   __init__zAssociationProxy.__init__i  s    . "3,*,!&?##5  '=#)B& JtH

 DI !%??,0D)&7D#,1D)&@D#rY   c                     y rd   r`   re   rf   owners      rW   __get__zAssociationProxy.__get__       rY   c                     y rd   r`   r   s      rW   r   zAssociationProxy.__get__  s     (+rY   c                     y rd   r`   r   s      rW   r   zAssociationProxy.__get__  s    ;>rY   c                `    || S | j                  ||      }|r|j                  |      S |J | S rd   )_as_instanceget)re   rf   r   insts       rW   r   zAssociationProxy.__get__  sC     =K  188H%%rY   c                ^    t        |      }| j                  ||      j                  ||       y rd   )r   r   set)re   rf   valuesr   s       rW   __set__zAssociationProxy.__set__  s(    h&(+//&ArY   c                \    t        |      }| j                  ||      j                  |       y rd   )r   r   delete)re   rf   r   s      rW   
__delete__zAssociationProxy.__delete__  s&    h&(+228<rY   c                &    | j                  ||      S )a  Return the internal state local to a specific mapped class.

        E.g., given a class ``User``::

            class User(Base):
                # ...

                keywords = association_proxy("kws", "keyword")

        If we access this :class:`.AssociationProxy` from
        :attr:`_orm.Mapper.all_orm_descriptors`, and we want to view the
        target class for this proxy as mapped by ``User``::

            inspect(User).all_orm_descriptors["keywords"].for_class(User).target_class

        This returns an instance of :class:`.AssociationProxyInstance` that
        is specific to the ``User`` class.   The :class:`.AssociationProxy`
        object remains agnostic of its parent class.

        :param class\_: the class that we are returning state for.

        :param obj: optional, an instance of the class that is required
         if the attribute refers to a polymorphic target, e.g. where we have
         to look at the type of the actual destination object to get the
         complete path.

        .. versionadded:: 1.3 - :class:`.AssociationProxy` no longer stores
           any state specific to a particular parent class; the state is now
           stored in per-class :class:`.AssociationProxyInstance` objects.


        )r   r   s      rW   r   zAssociationProxy.for_class  s    F   --rY   c                2   	 |j                   | j                  dz      }|G| j                  |      }|2t        j                  | ||      }t        || j                  dz   |       nd }||j                  s|j                  |      S |S # t        $ r d }Y ww xY w)N_inst)	__dict__rw   KeyError_calc_ownerAssociationProxyInstance	for_proxysetattr_is_canonical_non_canonical_get_for_object)re   r   r   r   r   s        rW   r   zAssociationProxy._as_instance  s    	??488g#56D
 <$$V,E /99$sK7 2D9D$6$6 55c::K)  	D	s   B BBc                    	 t        |      }|j                  j                  j                  S # t        j
                  $ r Y y w xY wrd   )r"   mapperclass_managerr   r!   NoInspectionAvailable)re   
target_clsinsps      rW   r   zAssociationProxy._calc_owner  sE    		4:&D ;;,,333 (( 	
 	s   - AAc                    | j                   t        j                        dfd}|t        u r
dfd}||fS dfd}||fS )Nc                    |  |       S d S rd   r`   rf   _getters    rW   getterz0AssociationProxy._default_getset.<locals>.getter      (0(<78$F$FrY   c                     t        | |       y rd   r   rf   krr   rV   s      rW   dict_setterz5AssociationProxy._default_getset.<locals>.dict_setter      $.rY   c                     t        | |       y rd   r   ovrV   s     rW   plain_setterz6AssociationProxy._default_getset.<locals>.plain_setter$      4#rY   )rf   r   ri   Optional[Any])rf   r   r   r   rr   r   ri   rs   )r   r   r   r   ri   rs   r   operator
attrgetterdictre   r   r   r   r   r   rV   s        @@rW   r   z AssociationProxy._default_getset  sR     %%d+	G t#/ ;&&$ <''rY   c                <    d| j                   d| j                  dS )NzAssociationProxy(z, ))rU   r   r   s    rW   __repr__zAssociationProxy.__repr__)  s    ""OO
 	
rY   )rU   r   rV   r   rC   r   rD   r   rE   r   rF   r   rG   Optional[_InfoType]rH   r   rI   r   rS   zOptional[_AttributeOptions])rf   Literal[None]r   r   ri   r2   )rf   r   r   r   ri   r   )rf   objectr   r   ri   r:   )rf   r   r   r   ri   z=Union[AssociationProxyInstance[_T], _T, AssociationProxy[_T]])rf   r   r   r:   ri   rs   )rf   r   ri   rs   rd   r   )r   r   r   r   ri   r   )r   r   ri   r   r   ri   r   )r]   r^   r_   r   is_attributer[   r\   extension_typer   r   r   r   r   r   r   r   r   r   r`   rY   rW   rT   rT   ^  s    OL2DDN /3;?9=:>$(',*/9=6A6A 6A
 ,6A 96A 76A 86A "6A !%6A $(6A 76Ap %.;	  +%+.1+	%+ + > >'*	FB=
 :>#.#.&6#.	%#.J #	%64( #(	5(.
rY   rT   _Selfr   c                     e Zd ZU dZded<   ded<   	 	 	 	 	 	 	 	 d*dZded<   	 e	 	 	 	 	 	 	 	 d+d	       Ze	 	 	 	 	 	 	 	 	 	 	 	 d,d
       Zd-dZ	e
d.d       Zd/dZe	 	 	 	 	 	 d0d       Zej                  	 	 d1d       Ze
d2d       Ze
d3d       Ze
d4d       Zej                  d5d       Zej                  d5d       Ze
d5d       Zded<   ded<   d6dZ	 	 	 	 d7dZej2                  d8d       Zed9d       Zed:d       Z	 	 	 	 d;dZd<d Zd=d!Z	 	 	 	 d>d"Z	 	 	 	 	 	 d?d#Z d@d$Z!	 dA	 	 	 	 	 dBd&Z"	 dA	 	 	 	 	 dBd'Z#	 dA	 	 	 	 	 dBd(Z$dCd)Z%y%)Dr   a  A per-class object that serves class- and object-specific results.

    This is used by :class:`.AssociationProxy` when it is invoked
    in terms of a specific class or instance of a class, i.e. when it is
    used as a regular Python descriptor.

    When referring to the :class:`.AssociationProxy` as a normal Python
    descriptor, the :class:`.AssociationProxyInstance` is the object that
    actually serves the information.   Under normal circumstances, its presence
    is transparent::

        >>> User.keywords.scalar
        False

    In the special case that the :class:`.AssociationProxy` object is being
    accessed directly, in order to get an explicit handle to the
    :class:`.AssociationProxyInstance`, use the
    :meth:`.AssociationProxy.for_class` method::

        proxy_state = inspect(User).all_orm_descriptors["keywords"].for_class(User)

        # view if proxy object is scalar or not
        >>> proxy_state.scalar
        False

    .. versionadded:: 1.3

    r   r   _AssociationProxyProtocol[_T]r   r   target_classc                    || _         |j                  | _        || _        |j                  | _        d | _        || _        || _        y rd   )r   rw   owning_classrU   r   r  r   )re   r   r  r  r   s        rW   r   z!AssociationProxyInstance.__init__W  sC     ::(!'!9!9 $($rY   c                <   |j                   }|j                  }t        dt        j                  |      j                  |            }t        |t        j                        st        d      d |j                  j                  }	 t        d| j                  ||            }| j                  |||||      S # t        $ r t        ||||      cY S t        $ rE}	t!        j"                  d|j$                   d|j                   d|j$                   d|	       |	d }	~	ww xY w)Nzorm.RelationshipProperty[_T]zEassociation proxy to a non-relationship intermediary is not supportedr   zRAssociation proxy received an unexpected error when trying to retreive attribute ".z" from class "z": )rU   r   r   r#   class_mapperget_property
isinstanceRelationshipPropertyNotImplementedErrorr   r   _cls_unwrap_target_assoc_proxy_construct_for_assocAttributeError!AmbiguousAssociationProxyInstance	Exceptionr!   InvalidRequestErrorr]   )
clsr   r  parent_instancerU   r   propr  target_assocerrs
             rW   r   z"AssociationProxyInstance.for_proxyo  sD    #44&&
*\*778IJ
 $ 8 89%0 
 {{))	.22<LL& ++flL*   	 5lJ   	)) ))*!F,=,=+> ?&//0C5:
 	s   B5 5DDA DDc                    |t        ||||      S t        ||      }t        |d      st        ||||      S |j                  }|rt        ||||      S t        ||||      S )N_is_internal_proxy)ObjectAssociationProxyInstancegetattrhasattrr  _impl_uses_objectsColumnAssociationProxyInstance)r  r  r   r  r  r   rV   	is_objects           rW   r  z-AssociationProxyInstance._construct_for_assoc  s     #1lJ  |Z0t124lJ  ++	1lJ  2lJ rY   c                r    t        j                  | j                        j                  | j                        S rd   )r#   r	  r  r
  rU   r   s    rW   _get_propertyz&AssociationProxyInstance._get_property  s/     1 12??""
 	
rY   c                V    t        | j                  | j                        j                  S rd   )r  r  rU   
comparatorr   s    rW   _comparatorz$AssociationProxyInstance._comparator  s%    t55

*	rY   c                    t        d      )NzqThe association proxy can't be used as a plain column expression; it only works inside of a comparison expressionr  r   s    rW   __clause_element__z+AssociationProxyInstance.__clause_element__  s    !J
 	
rY   c                d    t        ||      }t        |t              rJ t        |t              r|S y rd   )r  r  rT   r   )r  r  r   rV   s       rW   r  z7AssociationProxyInstance._cls_unwrap_target_assoc_proxy  s4     |Z0d$4555d45KrY   c                N    | j                  | j                  | j                        S rd   )r  r  r   r   s    rW   _unwrap_target_assoc_proxyz3AssociationProxyInstance._unwrap_target_assoc_proxy  s&     22t
 	
rY   c                V    t        dt        | j                  | j                              S )zThe 'remote' class attribute referenced by this
        :class:`.AssociationProxyInstance`.

        .. seealso::

            :attr:`.AssociationProxyInstance.attr`

            :attr:`.AssociationProxyInstance.local_attr`

        SQLORMOperations[_T])r   r  r  r   r   s    rW   remote_attrz$AssociationProxyInstance.remote_attr  s'     "GD,=,=t$O
 	
rY   c                V    t        dt        | j                  | j                              S )zThe 'local' class attribute referenced by this
        :class:`.AssociationProxyInstance`.

        .. seealso::

            :attr:`.AssociationProxyInstance.attr`

            :attr:`.AssociationProxyInstance.remote_attr`

        SQLORMOperations[Any])r   r  r  rU   r   s    rW   
local_attrz#AssociationProxyInstance.local_attr  s*     #D%%t'='=>
 	
rY   c                2    | j                   | j                  fS )a  Return a tuple of ``(local_attr, remote_attr)``.

        This attribute was originally intended to facilitate using the
        :meth:`_query.Query.join` method to join across the two relationships
        at once, however this makes use of a deprecated calling style.

        To use :meth:`_sql.select.join` or :meth:`_orm.Query.join` with
        an association proxy, the current method is to make use of the
        :attr:`.AssociationProxyInstance.local_attr` and
        :attr:`.AssociationProxyInstance.remote_attr` attributes separately::

            stmt = (
                select(Parent)
                .join(Parent.proxied.local_attr)
                .join(Parent.proxied.remote_attr)
            )

        A future release may seek to provide a more succinct join pattern
        for association proxy attributes.

        .. seealso::

            :attr:`.AssociationProxyInstance.local_attr`

            :attr:`.AssociationProxyInstance.remote_attr`

        )r1  r.  r   s    rW   rV   zAssociationProxyInstance.attr  s    : !1!122rY   c                `    | j                         j                   }|r| j                          |S )zsReturn ``True`` if this :class:`.AssociationProxyInstance`
        proxies a scalar relationship on the local side.)r"  uselist_initialize_scalar_accessors)re   scalars     rW   r6  zAssociationProxyInstance.scalar  s/    
 '')111--/rY   c                ~    | j                         j                  j                  | j                        j                   S rd   )r"  r   r
  r   r4  r   s    rW   _value_is_scalarz)AssociationProxyInstance._value_is_scalar(  s1     ""$VLL1W	
rY   c                    t               rd   r'  r   s    rW   _target_is_objectz*AssociationProxyInstance._target_is_object0  s    !##rY   z_GetterProtocol[_T]_scalar_get_PlainSetterProtocol[_T]_scalar_setc                    | j                   j                  r | j                   j                  d |       \  }}n| j                   j                  d       \  }}|t        d|      c| _        | _        y )Nr<  )r   rD   r   r   r;  r=  )re   r   set_s      rW   r5  z5AssociationProxyInstance._initialize_scalar_accessors7  s]    ;;%%224>IC33D9IC-0$&3
*$*rY   c                    | j                   t        j                        dfd}|t        u r
dfd}||fS dfd}||fS )Nc                    |  |       S d S rd   r`   r   s    rW   r   z8AssociationProxyInstance._default_getset.<locals>.getterF  r   rY   c                     t        | |       y rd   r   r   s      rW   r   z=AssociationProxyInstance._default_getset.<locals>.dict_setterK  r   rY   c                     t        | |       y rd   r   r   s     rW   r   z>AssociationProxyInstance._default_getset.<locals>.plain_setterQ  r   rY   )rf   r   ri   zOptional[_T])rf   r   r   r   rr   r:   ri   rs   )r   r   r   r:   ri   rs   r   r   s        @@rW   r   z(AssociationProxyInstance._default_getset@  sR     %%d+	G t#/ ;&&$ <''rY   c                .    | j                   j                  S rd   )r   rG   r   s    rW   rG   zAssociationProxyInstance.infoV  s    {{rY   c                     y rd   r`   re   r   s     rW   r   zAssociationProxyInstance.getZ  s    7:rY   c                     y rd   r`   rF  s     rW   r   zAssociationProxyInstance.get]  s    #&rY   c                   || S | j                   r't        || j                        }| j                  |      S 	 t	        dt        || j
                              \  }}}t        |      |k(  rt        |       |k(  r| j                  J |S | j                  t        || j                              \  | _        }t        || j
                  t        |      t        |       |f       |S # t        $ r Y fw xY w)NzTuple[int, int, _T])r6  r  rU   r;  r   rw   r   r   r  _new_lazy_collectionr   )re   r   target
creator_idself_idr   s         rW   r   zAssociationProxyInstance.get`  s     ;K ;;S$"8"89F##F++! .2)73+A.*
GU c7j(RX-@00<<< L+/99 d&<&<=,(D!5 CBsGRXu#=>L " s   $C$ $	C0/C0c                2   | j                   rt        d| j                  j                  r| j                  j                  n| j                        }t        || j                        }|7|| j                  j                  sy t        || j                   ||             y | j                  ||       |/| j                  j                  rt        || j                  d        y y y | j                  |      }| j                  J ||ur|j                  | |       y y )N_PlainCreatorProtocol[_T])r6  r   r   rC   r  r  rU   rI   r   r=  rH   r   r   _bulk_replace)re   r   r   rC   rK  r   s         rW   r   zAssociationProxyInstance.set  s    ;;+ {{** KK''**G S$"8"89F~N KKAAT33WV_E  0>dkk&H&HC!7!7> 'I> HHSME((444F"##D&1 #rY   c                    | j                   | j                  |d        | j                  r.t        || j                        }|t        || j                         t        || j                         y rd   )r  r   r6  r  rU   delattrr   re   r   rK  s      rW   r   zAssociationProxyInstance.delete  s[    $S$';;S$"8"89F!0T++,rY   c                `   | j                   j                  | j                   j                  nt        d| j                        }t	        j
                   |             }|t        j                  d|       | j                   j                  r*|| j                   j                  ||| j                  |       fS | j                   j                  r | j                   j                  ||       \  }}n| j                   j                  |      \  }}|t        u r|t        t        t        |||||             fS |t        u r|t        t        t!        |||||             fS |t"        u r|t        t        t%        |||||             fS t        j&                  d| j(                  d| j*                  d      )Nry   zDlazy collection factory did not return a valid collection type, got z=could not guess which interface to use for collection_class "z" backing "z6"; specify a proxy_factory and proxy_bulk_set manually)r   rC   r   r  r$   duck_type_collectionr!   r  rE   r   rD   r   listr:   _AssociationListr   _AssociationDictr   _AssociationSetr   r   rU   )re   r   rC   r   r   setters         rW   rI  zAssociationProxyInstance._new  s   
 {{"". KK($*;*;< 	
  44_5FG#))..>-?A  ;;$$ ))#Wdoot  ;;%%![[778H$ONFF![[889IJNFFt# $'&&$  % $'&&$  $ #'&&$  ## (($*@*@B rY   c                   | j                   j                  r| j                   j                  ||       y | j                  t        u rt	        d|      j                  |       y | j                  t        u rt	        d|      j                  |       y | j                  t        u rt	        d|      j                  |       y t        j                  d      )Nz_AssociationList[Any]z_AssociationDict[Any, Any]z_AssociationSet[Any]zEno proxy_bulk_set supplied for custom collection_class implementation)r   rF   r   rV  r   extendr   updater   r!   r   )re   r   r   s      rW   _setzAssociationProxyInstance._set  s     ;;%%KK&&uf5""d*(%077?""d*-u5<<VD""c)'/66v>##2 rY   c                   | j                   j                  xr | j                   j                  xs t        t        | j                        }| j                   j
                  r*| j                   j                  | j                  |       \  }}n(| j                   j                  | j                        \  }}||_        ||_        ||_	        y rd   )
r   rC   r   ry   r  rD   r   r   r   rZ  )re   r   rC   r   rZ  s        rW   _inflatez!AssociationProxyInstance._inflate  s    KK $##9$d&7&78 	 ;;%%![[77%%tNFF "[[889N9NONFFrY   Nc                   |j                  dd       }| j                  }|/ |j                  dd|i|}| j                  j                  |      S | j                  r>t        | j                  | j                        } |j                  j                  |fi |}n2|rt        j                  d      |r|t        j                  d      |}| j                  j                  |      S )Nis_has	criterionzJCan't apply keyword arguments to column-targeted association proxy; use ==zINon-empty has() not allowed for column-targeted association proxy; use ==r`   )popr+  _criterion_existsr%  r:  r  r  r   r$  r!   r   )re   rc  kwargsrb  r  innerrV   
value_exprs           rW   re  z*AssociationProxyInstance._criterion_exists
  s    
 Hd+66#2L22 #'-E ##55e<<!!4,,doo>D:::9OOJ''0  I1''@ 
 #J11*==rY   c                    | j                   9| j                  r-| j                  r| j                  rt	        j
                  d       | j                  d|dd|S )a  Produce a proxied 'any' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.Relationship.Comparator.any`
        and/or :meth:`.Relationship.Comparator.has`
        operators of the underlying proxied attributes.

        z9'any()' not implemented for scalar attributes. Use has().Frc  rb  r`   r+  r6  r:  r8  r!   r  re  re   rc  rf  s      rW   anyzAssociationProxyInstance.any+  sg     **2KK++t/D/D))K  &t%% 

17
 	
rY   c                    | j                   9| j                  r| j                  r!| j                  st	        j
                  d       | j                  d|dd|S )a  Produce a proxied 'has' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.Relationship.Comparator.any`
        and/or :meth:`.Relationship.Comparator.has`
        operators of the underlying proxied attributes.

        z3'has()' not implemented for collections. Use any().Trj  r`   rk  rl  s      rW   haszAssociationProxyInstance.hasC  sg     **2&&t/D/D))E  &t%% 

06
 	
rY   c                N    | j                   j                  d| j                  dS )N(r   )	__class__r]   r   r   s    rW   r   z!AssociationProxyInstance.__repr__[  s    >>22DKK@@rY   )r   r  r  r   r  r   r   r   )r   zAssociationProxy[_T]r  r   r  r   ri   r   )r  &Optional[AssociationProxyInstance[_T]]r   r  r  r   r  r   r   r   ri   r   )ri   zMapperProperty[Any])ri   zPropComparator[Any]ri   r   )r  r   r   r   ri   rs  )ri   rs  )ri   r-  )ri   r0  )ri   z2Tuple[SQLORMOperations[Any], SQLORMOperations[_T]]ri   r   ri   rs   r   r   )re   r  r   r   ri   r  )r   r   ri   r:   )r   r   ri   z1Union[Optional[_T], AssociationProxyInstance[_T]])r   r   r   r:   ri   rs   )r   r   ri   rs   )r   z_LazyCollectionProtocol[_T]ri   zTuple[Type[Any], _T])r   r   r   r   ri   rs   )r   r   ri   rs   rd   )rc  )Optional[_ColumnExpressionArgument[bool]]rf  r   ri   ColumnElement[bool]r   )&r]   r^   r_   r   r   r   classmethodr   r  r"  propertyr%  r(  r  r$   memoized_propertyr+  r.  r1  rV   r6  r8  r:  r5  r   ro_non_memoized_propertyrG   r   r   r   r   rI  r^  r`  re  rm  ro  r   r`   rY   rW   r   r   6  s   : *)))%-%  %  	%
 %  ,$,  , 	,
 
&, ,\ < .  	
    
& 8

  

 ,/	/  

	/
 
 
 
 
 
  3 3< 
  

 
 $ $ %$))
( #(	5(, 
""  #  : :& &	:>28-@:@	@D0:G	"( @D><> > 
	>F @D
<
 
 
	
4 @D
<
 
 
	
0ArY   r   c                       e Zd ZdZdZddZd fdZddZddZ	 d	 	 	 	 	 ddZ		 d	 	 	 	 	 ddZ
ej                  dd	       Z	 	 	 	 dd
Z	 	 	 	 	 	 ddZ xZS )r  zcan :class:`.AssociationProxyInstance` where we cannot determine
    the type of target object.
    Fc                    t        d| j                  j                  d| j                  d| j                  d| j
                  d	      )NzAssociation proxy r  z refers to an attribute 'z'' that is not directly mapped on class ze; therefore this operation cannot proceed since we don't know what type of object is referred towards)r  r  r]   rU   r   r  r   s    rW   
_ambiguousz,AmbiguousAssociationProxyInstance._ambiguousf  s>     !!**&&!!	
 	
rY   c                *    || S t         |   |      S rd   )superr   )re   r   rr  s     rW   r   z%AmbiguousAssociationProxyInstance.gett  s    ;K7;s##rY   c                $    | j                          y rd   r  rF  s     rW   __eq__z(AmbiguousAssociationProxyInstance.__eq__z      rY   c                $    | j                          y rd   r  rF  s     rW   __ne__z(AmbiguousAssociationProxyInstance.__ne__}  r  rY   c                $    | j                          y rd   r  rl  s      rW   rm  z%AmbiguousAssociationProxyInstance.any      
 	rY   c                $    | j                          y rd   r  rl  s      rW   ro  z%AmbiguousAssociationProxyInstance.has  r  rY   c                    i S rd   r`   r   s    rW   _lookup_cachez/AmbiguousAssociationProxyInstance._lookup_cache  s	    
 	rY   c                6   |lt        || j                        }|T	 t        |      }|j                  }|j                  }|| j
                  vr| j                  ||       	 | j
                  |   S | S # t        $ r Y | S w xY w# t        j                  $ r Y | S w xY wrd   )
r  rU   r"   r   r   r  _populate_cacher   r!   r   )re   r  
actual_objr   r   instance_classs         rW   r   z?AmbiguousAssociationProxyInstance._non_canonical_get_for_object  s     & $2H2HIJ%":.D "[[F%+]]N%T-?-??,,^VD#11.AA  $   00  s#   B  A1 1	A>=A>BBc                   t        j                  | j                        j                  | j                        }|j                  |j                        rj|}	 | j                  || j                        }| j                  t        d|      | j                  | j                  || j                        | j                  |<   y y # t        $ r Y y w xY w)Nr   )r#   r	  r  r
  rU   isar   r  r   r  r   r   r  r  )re   r  r   r  r  r  s         rW   r  z1AmbiguousAssociationProxyInstance._populate_cache  s      1 12??""
 ::dkk")L#BB $//  6:5N5N7FKK%% OO6"">2 # " s   B? ?	C
Crt  )r   r   ri   r   )r   r   ri   r   rd   )rc  rw  rf  r   ri   r   )ri   z-Dict[Type[Any], AssociationProxyInstance[_T]])r  r   ri   r   )r  r   r   zMapper[Any]ri   rs   )r]   r^   r_   r   r   r  r   r  r  rm  ro  r$   r{  r  r   r  __classcell__)rr  s   @rW   r  r  _  s     M
$
 @D<  
	 @D<  
	 
 "	%2!+6	rY   r  c                  <    e Zd ZU dZdZded<   dZd	dZd
dZd
dZ	y)r  zEan :class:`.AssociationProxyInstance` that has an object as a target.Tr   r:  c                6   | j                   }|?| j                  j                  |j                  s|j	                  |            S ||k(        S | j
                  r`| j                  rT| j                  sH| j                  j                  t        | j                  | j                        j	                  |            S | j
                  r-| j                  r!| j                  rt        j                  d       | j                  j                  di | j                  |iS )aI  Produce a proxied 'contains' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.Relationship.Comparator.any`,
        :meth:`.Relationship.Comparator.has`,
        and/or :meth:`.Relationship.Comparator.contains`
        operators of the underlying proxied attributes.
        z<contains() doesn't apply to a scalar object endpoint; use ==r`   )r+  r%  re  r6  containsr:  r8  ro  r  r  r   r!   r  )re   otherkwr  s       rW   r  z'ObjectAssociationProxyInstance.contains  s    66###55#** %%e,  "U*  ""))##''))4??;DDUK  ##8M8M))N  64##55 ??E* rY   c                    |?t         | j                  j                  di | j                  |i| j                  d k(        S  | j                  j                  di | j                  |iS Nr`   )r.   r%  ro  r   rF  s     rW   r  z%ObjectAssociationProxyInstance.__eq__  sm     ;$  $$>'=>  D( 
 (4##''A4??C*@AArY   c                z    | j                   j                  t        | j                  | j                        |k7        S rd   )r%  ro  r  r  r   rF  s     rW   r  z%ObjectAssociationProxyInstance.__ne__  s6     ##D%%t73>
 	
rY   N)r  r   r  r   ri   rx  )r   r   ri   rx  )
r]   r^   r_   r   r:  r   r   r  r  r  r`   rY   rW   r  r    s&    O"t"M D	B
rY   r  c                  D    e Zd ZU dZdZded<   dZd	dZ	 	 	 	 	 	 	 	 d
dZy)r  zVan :class:`.AssociationProxyInstance` that has a database column as a
    target.
    Fr   r:  Tc                    | j                  | j                  j                  t        j                  |            }|t        || j                  d k(        S |S rd   )re  r.  operater-   eqr.   r%  )re   r  exprs      rW   r  z%ColumnAssociationProxyInstance.__eq__
  sP    %%$$Y\\59
 =tT--566KrY   c                `    | j                   | j                  j                  |g|i |      S rd   )re  r.  r  )re   opr  rf  s       rW   r  z&ColumnAssociationProxyInstance.operate  s7     %%$D$$R:%:6:
 	
rY   N)r  r   ri   rx  )r  zoperators.OperatorTyper  r   rf  r   ri   zColumnElement[Any])	r]   r^   r_   r   r:  r   r   r  r  r`   rY   rW   r  r    sC     $t#M
(
25
AD
	
rY   r  c                  0    e Zd ZddZ	 	 ddZddZd	dZy)
rJ  c                     || _         || _        y rd   r   rK  rS  s      rW   r   z_lazy_collection.__init__  s    rY   c                B    t        | j                  | j                        S rd   )r  r   rK  r   s    rW   rg   z_lazy_collection.__call__!  s     t{{DKK00rY   c                4    | j                   | j                  dS )N)r   rK  r  r   s    rW   __getstate__z_lazy_collection.__getstate__&  s    {{dkk::rY   c                ,    |d   | _         |d   | _        y )Nr   rK  r  re   states     rW   __setstate__z_lazy_collection.__setstate__)  s    ElHorY   N)r   r   rK  r   r   ri   r   r  r   ri   rs   )r]   r^   r_   r   rg   r  r  r`   rY   rW   rJ  rJ    s    1	L1
;&rY   rJ  _ITr   c                      e Zd ZU ded<   	 ded<   	 ded<   ded<   	 d	ed
<   	 	 	 	 	 	 	 	 	 	 	 ddZej                  rded<   n	 ed       ZddZ	ddZ
ddZddZddZy)_AssociationCollection_GetterProtocol[_IT]r   ry   rC   AssociationProxyInstance[_IT]r   rl   rZ  _LazyCollectionProtocol[_IT]r   c                J    || _         || _        || _        || _        || _        y)zConstructs an _AssociationCollection.

        This will always be a subclass of either _AssociationList,
        _AssociationSet, or _AssociationDict.

        N)r   rC   r   rZ  r   )re   r   rC   r   rZ  r   s         rW   r   z_AssociationCollection.__init__O  s(      /rY   zCollection[_IT]colc                "    | j                         S rd   )r   r   s    rW   <lambda>z_AssociationCollection.<lambda>f  s    D$8$8$: rY   c                ,    t        | j                        S rd   lenr  r   s    rW   __len__z_AssociationCollection.__len__h      488}rY   c                ,    t        | j                        S rd   )r   r  r   s    rW   __bool__z_AssociationCollection.__bool__k  s    DHH~rY   c                4    | j                   | j                  dS )Nr   r   r  r   s    rW   r  z#_AssociationCollection.__getstate__n  s    ++$:N:NOOrY   c                b    |d   | _         |d   | _        | j                   j                  |        y )Nr   r   )r   r   r`  r  s     rW   r  z#_AssociationCollection.__setstate__q  s-    Ho$%67T"rY   c                    t               rd   r'  r   s    rW   clearz_AssociationCollection.clearv  s    !##rY   N)
r   r  rC   ry   r   r  rZ  rl   r   r  ri   intru  r  r  rv  )r]   r^   r_   r   r   typingTYPE_CHECKINGrz  r  r  r  r  r  r  r`   rY   rW   r  r  8  s      F *) 21F5 " %	
   .( :;P#
$rY   r  c                  F    e Zd ZU ded<   ded<   d	dZd
dZ	 	 	 	 	 	 ddZy)_AssociationSingleItemr<  rZ  rO  rC   c                $    | j                  |      S rd   rC   r}   s     rW   _createz_AssociationSingleItem._create~  s    ||E""rY   c                $    | j                  |      S rd   r   re   object_s     rW   _getz_AssociationSingleItem._get      {{7##rY   c                H    | j                          |j                  | |       y rd   )r  r^  )re   assoc_proxyr   s      rW   rP  z$_AssociationSingleItem._bulk_replace  s     	

v&rY   N)rr   r:   ri   r   )r  r   ri   r:   )r  r   r   zIterable[_IT]ri   rs   )r]   r^   r_   r   r  r  rP  r`   rY   rW   r  r  z  s5    $$&&#$'8'BO'	'rY   r  c                     e Zd ZU dZded<   d+dZed,d       Zed-d       Z	 	 	 	 d.dZed/d       Zed0d	       Z	 	 	 	 	 	 d1d
Zed2d       Z	ed3d       Z	d4dZ	d5dZ
d6dZd7dZd8dZd9dZd/dZd:d,dZd7dZd;dZd;dZd<dZd=dZd=dZd>dZd>dZd>dZd>dZd?dZd?d Zd@d!Zd@d"ZdAd#ZdBd$Z e!jD                  r	 dC	 	 	 	 	 	 	 dDd%Z#nd8d&Z#dEd'Z$dFd(Z%d;d)Z&e!jD                  sn e' e(       jS                               D ]M  \  Z*Z+ e,e+      se+j                   e*k(  se+j                  r, e-e'e*      s6 e.e'e*      j                  e+_        O [*[+y*y*)GrW  z(Generic, converting, list-to-list proxy.MutableSequence[_T]r  c                (    | j                  ||       y rd   rZ  )re   r  rr   s      rW   r^  z_AssociationList._set  s    GU#rY   c                     y rd   r`   re   indexs     rW   __getitem__z_AssociationList.__getitem__      -0rY   c                     y rd   r`   r  s     rW   r  z_AssociationList.__getitem__  s    @CrY   c                    t        |t              s| j                  | j                  |         S | j                  |   D cg c]  }| j                  |       c}S c c}w rd   )r  slicer  r  )re   r  members      rW   r  z_AssociationList.__getitem__  sJ     %'99TXXe_--48HHUOD&DIIf%DDDs    Ac                     y rd   r`   re   r  rr   s      rW   __setitem__z_AssociationList.__setitem__  s    :=rY   c                     y rd   r`   r  s      rW   r  z_AssociationList.__setitem__  s    FIrY   c                   t        |t              s*| j                  | j                  |   t	        d|             y |j
                  t        |       }n4|j
                  dk  rt        |       |j
                  z   }n|j
                  }|j                  xs d}|j                  xs d}t        t        |j                  xs d||            }t        |      }|dk(  r+|D ]  }| |=  |}|D ]  }	| j                  ||	       |dz  } y t        |      t        |      k7  r#t        dt        |      dt        |            t        ||      D ]$  \  }}	| j                  | j                  |   |	       & y )Nr:   r      z#attempt to assign sequence of size z to extended slice of size )r  r  r^  r  r   stopr  stepstartrV  rangeinsert
ValueErrorzip)
re   r  rr   r  r  r  rngsized_valueiitems
             rW   r  z_AssociationList.__setitem__  sR    %'IIdhhuotD%'89zz!4ya4y5::-zz::?DKK$1EuU[[-AtT:;Cu+Kqy $AU$' DKK4(FA {#s3x/$ {+SX7 
  #3 1GAtIIdhhqk401rY   c                     y rd   r`   r  s     rW   __delitem__z_AssociationList.__delitem__  s    /2rY   c                     y rd   r`   r  s     rW   r  z_AssociationList.__delitem__  s    14rY   c                    | j                   |= y rd   r  r  s     rW   r  z_AssociationList.__delitem__  s    HHUOrY   c                R    | j                   D ]  }| j                  |      |k(  s y yNTFr  r  )re   rr   r  s      rW   __contains__z_AssociationList.__contains__  s.    hh 	Fyy E)	 rY   c              #  T   K   | j                   D ]  }| j                  |        yw)zIterate over proxied values.

        For the actual domain objects, iterate over .col instead or
        just use the underlying collection directly from its property
        on the parent.
        Nr  re   r  s     rW   __iter__z_AssociationList.__iter__  s-      hh 	$F))F##	$   &(c                `    | j                   }| j                  |      }|j                  |       y rd   )r  r  append)re   rr   r  r  s       rW   r  z_AssociationList.append  s%    hh||E"

4rY   c                .    d}| D ]  }||k(  s	|dz  } |S Nr   r  r`   )re   rr   countr   s       rW   r  z_AssociationList.count  s-     	AEz
	 rY   c                4    |D ]  }| j                  |        y rd   )r  )re   r   r   s      rW   r\  z_AssociationList.extend  s     	AKKN	rY   c                B    | j                  |      g| j                  || y rd   )r  r  r  s      rW   r  z_AssociationList.insert  s    !%e!4 5urY   c                V    | j                  | j                  j                  |            S rd   )r   r  rd  r  s     rW   rd  z_AssociationList.pop  s    {{488<<.//rY   c                f    t        |       D ]  \  }}||k(  s| j                  |=  y  t        d      )Nzvalue not in list)	enumerater  r  )re   rr   r  vals       rW   removez_AssociationList.remove  s<    o 	FAse|HHQK	 ,--rY   c                    t               )z#Not supported, use reversed(mylist)r'  r   s    rW   reversez_AssociationList.reverse       "##rY   c                    t               )z!Not supported, use sorted(mylist)r'  r   s    rW   sortz_AssociationList.sort	  r  rY   c                H    | j                   dt        | j                         = y )Nr   )r  r  r   s    rW   r  z_AssociationList.clear  s    HHQTXX&'rY   c                    t        |       |k(  S rd   rV  re   r  s     rW   r  z_AssociationList.__eq__      DzU""rY   c                    t        |       |k7  S rd   r  r  s     rW   r  z_AssociationList.__ne__  r  rY   c                    t        |       |k  S rd   r  r  s     rW   __lt__z_AssociationList.__lt__      DzE!!rY   c                    t        |       |k  S rd   r  r  s     rW   __le__z_AssociationList.__le__  r  rY   c                    t        |       |kD  S rd   r  r  s     rW   __gt__z_AssociationList.__gt__  r  rY   c                    t        |       |k\  S rd   r  r  s     rW   __ge__z_AssociationList.__ge__   r  rY   c                `    	 t        |      }t        |       |z   S # t        $ r	 t        cY S w xY wrd   rV  	TypeErrorNotImplementedr  s     rW   __add__z_AssociationList.__add__#  s8    	"KE DzE!!  	"!!	"    --c                `    	 t        |      }|t        |       z   S # t        $ r	 t        cY S w xY wrd   r"  r  s     rW   __radd__z_AssociationList.__radd__*  s8    	"KE tDz!!  	"!!	"r&  c                J    t        |t              st        S t        |       |z  S rd   r  r  r$  rV  re   ns     rW   __mul__z_AssociationList.__mul__1  s     !S!!!DzA~rY   c                J    t        |t              st        S |t        |       z  S rd   r*  r+  s     rW   __rmul__z_AssociationList.__rmul__6  s     !S!!!4:~rY   c                (    | j                  |       | S rd   )r\  )re   iterables     rW   __iadd__z_AssociationList.__iadd__;  s    HrY   c                    t        |t              s
t               |dk(  r| j                          | S |dkD  r | j	                  t        |       |dz
  z         | S r  )r  r  r  r  r\  rV  r+  s     rW   __imul__z_AssociationList.__imul__?  sU    
 !S!%''6JJL  UKKT
a!e,-rY   c                     y rd   r`   )re   rr   r  r  s       rW   r  z_AssociationList.indexN  s    rY   c                >    t        |       } |j                  |g| S rd   )rV  r  )re   rr   arglss       rW   r  z_AssociationList.indexT  s!    dB288E(C((rY   c                    t        |       S rd   r  r   s    rW   copyz_AssociationList.copyX  s    DzrY   c                *    t        t        |             S rd   )rK   rV  r   s    rW   r   z_AssociationList.__repr__[      DJrY   c                D    t        dt        |       j                  z        Nz%s objects are unhashabler#  r   r]   r   s    rW   __hash__z_AssociationList.__hash__^      3d4j6I6IIJJrY   N)r  r   rr   r:   ri   rs   )r  r  ri   r:   )r  r  ri   r  )r  Union[int, slice]ri   zUnion[_T, MutableSequence[_T]])r  r  rr   r:   ri   rs   )r  r  rr   Iterable[_T]ri   rs   )r  rB  rr   zUnion[_T, Iterable[_T]]ri   rs   )r  r  ri   rs   )r  r  ri   rs   )r  zUnion[slice, int]ri   rs   )rr   r   ri   r   ri   zIterator[_T])rr   r:   ri   rs   )rr   r   ri   r  )r   rC  ri   rs   )rt  rv  r  r   ri   r   )r  List[_T]ri   r   )r  rG  ri   rG  )r,  r3   ri   rG  )r1  rC  ri   r2   )r,  r3   ri   r2   )..)rr   r   r  r  r  r  ri   r  )ri   rG  r   )/r]   r^   r_   r   r   r^  r   r  r  r  r  r  r  r  r\  r  rd  r  r  r  r  r  r  r  r  r  r   r%  r(  r-  r/  r2  r4  r  r  r  r:  r   r@  rV  localsitems	func_namefunccallabler  r  r`   rY   rW   rW  rW    s   2	$ 0 0C CE&E	'E = =I I"1&"1/F"1	"1H 2 24 4

60.$
$
(##"#"#""

  =@		%(	69			) K #FHNN$45 	@OItMMY.D),&tY7??	@ t  rY   rW  c                     e Zd ZU dZded<   ded<   ded<   d'dZd(d	Zd)d
Zd*dZd+dZ	d,dZ
d-dZd.dZd/dZd0dZd0dZd1dZed2d       Zed3d       Z	 d4	 	 	 	 	 d5dZd4d6dZd7dZd8dZd9dZed:d       Ze	 d;	 	 	 	 	 d3d       Zd<dZd=dZe	 	 	 	 	 	 d>d        Ze	 	 	 	 	 	 d?d!       Zed@d"       ZdAd#Z	 	 	 	 	 	 dBd$ZdCd%ZdDd&Zej<                  sn e e        j+                               D ]M  \  Z!Z" e#e"      se"j                   e!k(  se"j                  r, e$e%e!      s6 e&e%e!      j                  e"_        O [!["yy)ErX  z(Generic, converting, dict-to-dict proxy.z_DictSetterProtocol[_VT]rZ  z_KeyCreatorProtocol[_VT]rC   z"MutableMapping[_KT, Optional[_VT]]r  c                &    | j                  ||      S rd   r  r   s      rW   r  z_AssociationDict._createt  s    ||C''rY   c                $    | j                  |      S rd   r  r  s     rW   r  z_AssociationDict._getw  r  rY   c                (    | j                  |||      S rd   r  )re   r  rw   rr   s       rW   r^  z_AssociationDict._setz  s    {{7C//rY   c                >    | j                  | j                  |         S rd   )r  r  re   rw   s     rW   r  z_AssociationDict.__getitem__}  s    yy#''rY   c                    || j                   v r!| j                  | j                   |   ||       y | j                  ||      | j                   |<   y rd   )r  r^  r  r   s      rW   r  z_AssociationDict.__setitem__  s=    $((?IIdhhsmS%0 LLe4DHHSMrY   c                    | j                   |= y rd   r  rR  s     rW   r  z_AssociationDict.__delitem__  s    HHSMrY   c                    || j                   v S rd   r  rR  s     rW   r  z_AssociationDict.__contains__  s    dhhrY   c                H    t        | j                  j                               S rd   )iterr  keysr   s    rW   r  z_AssociationDict.__iter__  s    DHHMMO$$rY   c                8    | j                   j                          y rd   r  r  r   s    rW   r  z_AssociationDict.clear      rY   c                    t        |       |k(  S rd   r   r  s     rW   r  z_AssociationDict.__eq__  r  rY   c                    t        |       |k7  S rd   r]  r  s     rW   r  z_AssociationDict.__ne__  r  rY   c                *    t        t        |             S rd   )rK   r   r   s    rW   r   z_AssociationDict.__repr__  r<  rY   c                     y rd   r`   re   _AssociationDict__keys     rW   r   z_AssociationDict.get  s    03rY   c                     y rd   r`   re   rb  rL   s      rW   r   z_AssociationDict.get  s    JMrY   Nc                0    	 | |   S # t         $ r |cY S w xY wrd   )r   re   rw   rL   s      rW   r   z_AssociationDict.get  s%    	9 	N	s    c                j    || j                   vr!| j                  ||      | j                   |<   |S | |   S rd   )r  r  rf  s      rW   
setdefaultz_AssociationDict.setdefault  s7     dhh LLg6DHHSMN9rY   c                6    | j                   j                         S rd   )r  rX  r   s    rW   rX  z_AssociationDict.keys  s    xx}}rY   c                    t        |       S rd   r   r   s    rW   rI  z_AssociationDict.items  s    rY   c                    t        |       S rd   r   r   s    rW   r   z_AssociationDict.values  s    $rY   c                     y rd   r`   ra  s     rW   rd  z_AssociationDict.pop  s    &)rY   c                     y rd   r`   rd  s      rW   rd  z_AssociationDict.pop  s     rY   c                d     | j                   j                  |g|i |}| j                  |      S rd   )r  rd  r  )re   rb  r7  r  r  s        rW   rd  z_AssociationDict.pop  s/    e0c0R0yy  rY   c                h    | j                   j                         }|d   | j                  |d         fS r  )r  popitemr  )re   r  s     rW   rp  z_AssociationDict.popitem  s0    xx!Q47+,,rY   c                     y rd   r`   re   _AssociationDict__mrf  s      rW   r]  z_AssociationDict.update  r   rY   c                     y rd   r`   rr  s      rW   r]  z_AssociationDict.update  r   rY   c                     y rd   r`   )re   rf  s     rW   r]  z_AssociationDict.update  r  rY   c                f    i } |j                   |i | |j                         D ]
  \  }}|| |<    y rd   )r]  rI  )re   ar  uprw   rr   s         rW   r]  z_AssociationDict.update  s<    		1((* 	JCDI	rY   c                   t        |       }|j                  |xs d      }t        |xs d      j                  |      }|j                  |      }|j                         xs dD ]  \  }}||v r|| |<   ||v s|| |<    |D ]  }| |=  y r  )r   intersection
differencerI  )	re   r  r   existing	constants	additionsremovalsrw   r  s	            rW   rP  z_AssociationDict._bulk_replace  s    
 t9))&,B7	"%00;	&&y1!<<>/R 	#KCi"S		!"S			#  	CS		rY   c                4    t        | j                               S rd   )r   rI  r   s    rW   r:  z_AssociationDict.copy  s    DJJL!!rY   c                D    t        dt        |       j                  z        r>  r?  r   s    rW   r@  z_AssociationDict.__hash__  rA  rY   )rw   rA   rr   Optional[_VT]ri   r   )r  r   ri   rB   )r  r   rw   rA   rr   rB   ri   rs   )rw   rA   ri   rB   )rw   rA   rr   rB   ri   rs   )rw   rA   ri   rs   )rw   r   ri   r   )ri   zIterator[_KT]rv  rF  r   )rb  rA   ri   r  )rb  rA   rL   Union[_VT, _T]ri   r  rd   )rw   rA   rL   zOptional[Union[_VT, _T]]ri   zUnion[_VT, _T, None])rw   rA   rL   r  ri   rB   )ri   zKeysView[_KT])ri   zItemsView[_KT, _VT])ri   zValuesView[_VT])rb  rA   ri   rB   ).)rb  rA   r7  r   r  r   ri   r  )ri   zTuple[_KT, _VT])rs  z SupportsKeysAndGetItem[_KT, _VT]rf  rB   ri   rs   )rs  zIterable[tuple[_KT, _VT]]rf  rB   ri   rs   )rf  rB   ri   rs   )rw  r   r  r   ri   rs   )r  r   r   zMapping[_KT, _VT]ri   rs   )ri   zDict[_KT, _VT]rt  )'r]   r^   r_   r   r   r  r  r^  r  r  r  r  r  r  r  r  r   r   r   rh  rX  rI  r   rd  rp  r]  rP  r:  r@  r  r  rV  rH  rJ  rK  rL  r  r   r  r`   rY   rW   rX  rX  m  s   2$$%%	++($0(5%##  3 3M M =A!9	
  ) )47#1	 !- 3?B	  ,8;	  0 02 " 
	&"K #FHNN$45 	@OItMMY.D),&tY7??	@ t  rY   rX  c                  H   e Zd ZU dZded<   d+dZd,dZd-dZd.dZd/dZ	d/d	Z
d/d
Zd0dZd1dZd2dZ	 	 	 	 d3dZd4dZd5dZd6dZd7dZd8dZd9dZd:dZd7dZd8dZd9dZd:dZd;dZd<dZd=dZd3dZd>dZd>dZ d?d Z!d@d!Z"dAd"Z#dAd#Z$dBd$Z%dBd%Z&dBd&Z'dBd'Z(dCd(Z)dDd)Z*e+jX                  sn e- e.       j_                               D ]M  \  Z0Z1 e2e1      se1j                   e0k(  se1j                  r, e3e4e0      s6 e5e4e0      j                  e1_        O [0[1y*y*)ErY  z&Generic, converting, set-to-set proxy.MutableSet[_T]r  c                ,    t        | j                        S rd   r  r   s    rW   r  z_AssociationSet.__len__  r  rY   c                    | j                   ryyr  r  r   s    rW   r  z_AssociationSet.__bool__  s    88rY   c                R    | j                   D ]  }| j                  |      |k(  s y yr  r  )re   _AssociationSet__or  s      rW   r  z_AssociationSet.__contains__  s.    hh 	Fyy C'	 rY   c              #  T   K   | j                   D ]  }| j                  |        yw)zIterate over proxied values.

        For the actual domain objects, iterate over .col instead or just use
        the underlying collection directly from its property on the parent.

        Nr  r  s     rW   r  z_AssociationSet.__iter__  s-      hh 	$F))F##	$r   c                b    || vr+| j                   j                  | j                  |             y y rd   )r  addr  )re   _AssociationSet__elements     rW   r  z_AssociationSet.add&  s(    D HHLLi01 !rY   c                    | j                   D ]3  }| j                  |      |k(  s| j                   j                  |        y  y rd   )r  r  discardre   r  r  s      rW   r  z_AssociationSet.discard,  s;    hh 	Fyy I-  (	rY   c                    | j                   D ]3  }| j                  |      |k(  s| j                   j                  |        y  t        |      rd   )r  r  r  r   r  s      rW   r  z_AssociationSet.remove2  sH    hh 	Fyy I-  (	 y!!rY   c                    | j                   st        d      | j                   j                         }| j                  |      S )Nzpop from an empty set)r  r   rd  r  r  s     rW   rd  z_AssociationSet.pop9  s3    xx233yy  rY   c                B    |D ]  }|D ]  }| j                  |         y rd   )r  )re   sr1  rr   s       rW   r]  z_AssociationSet.update?  s+     	 H!   	 rY   c                :   t        |       }|j                  |xs d      }t        |xs d      j                  |      }|j                  |      }| j                  }| j                  }|xs dD ]  }	|	|v r	 ||	       |	|v s ||	        |D ]
  }	 ||	        y r  )r   rz  r{  r  r  )
re   r  r   r|  r}  r~  r  appenderremoverr  s
             rW   rP  z_AssociationSet._bulk_replaceD  s    t9))&,B7	"%00;	&&y188++l 	!F" 9$ 		!  	FFO	rY   c                v    t        j                  | |      s
t               |D ]  }| j                  |        | S rd   )r%   _set_binops_check_strictr  r  )re   r  rr   s      rW   __ior__z_AssociationSet.__ior__V  s<     33D%@%'' 	EHHUO	rY   c                *    t        t        |             S rd   )r   rW  r   s    rW   r^  z_AssociationSet._set_  s    4:rY   c                2     t        |       j                  | S rd   )r   unionre   r  s     rW   r  z_AssociationSet.unionb  s    s4y""rY   c                $    | j                  |      S rd   )r  re   _AssociationSet__ss     rW   __or__z_AssociationSet.__or__e  s    zz#rY   c                2     t        |       j                  | S rd   )r   r{  r  s     rW   r{  z_AssociationSet.differenceh  s    #s4y##Q''rY   c                $    | j                  |      S rd   )r{  r  s     rW   __sub__z_AssociationSet.__sub__k  s    q!!rY   c                B    |D ]  }|D ]  }| j                  |         y rd   )r  )re   r  r  rr   s       rW   difference_updatez!_AssociationSet.difference_updaten  s,     	$E $U#$	$rY   c                v    t        j                  | |      s
t               |D ]  }| j                  |        | S rd   )r%   r  r  r  )re   r  rr   s      rW   __isub__z_AssociationSet.__isub__s  s;    33D!<%'' 	 ELL	 rY   c                2     t        |       j                  | S rd   )r   rz  r  s     rW   rz  z_AssociationSet.intersectionz  s    %s4y%%q))rY   c                $    | j                  |      S rd   )rz  r  s     rW   __and__z_AssociationSet.__and__}  s      ##rY   c                    |D ]X  }| j                  |      t        |       }}||z
  ||z
  }}|D ]  }| j                  |        |D ]  }| j                  |        Z y rd   )rz  r   r  r  )re   r  r  wanthaver  r  rr   s           rW   intersection_updatez#_AssociationSet.intersection_update  so     	 E**513t9$D+td{CF #E"#   	 rY   c                    t        j                  | |      s
t               | j                  |      }t	        |       }||z
  ||z
  }}|D ]  }| j                  |        |D ]  }| j                  |        | S rd   )r%   r  r  rz  r   r  r  )re   r  r  r  r  r  rr   s          rW   __iand__z_AssociationSet.__iand__  s    33D!<%''  #D	Tk4$; 	EKK	 	EHHUO	rY   c                6    t        |       j                  |      S rd   )r   symmetric_differencer  s     rW   r  z$_AssociationSet.symmetric_difference  s    4y--c22rY   c                $    | j                  |      S rd   )r  r  s     rW   __xor__z_AssociationSet.__xor__  s    ((++rY   c                    | j                  |      t        |       }}||z
  ||z
  }}|D ]  }| j                  |        |D ]  }| j                  |        y rd   )r  r   r  r  )re   r  r  r  r  r  rr   s          rW   symmetric_difference_updatez+_AssociationSet.symmetric_difference_update  s`    ..u5s4ydTk4$; 	EKK	 	EHHUO	rY   c                h    t        j                  | |      s
t               | j                  |       | S rd   )r%   r  r  r  r  s     rW   __ixor__z_AssociationSet.__ixor__  s.    33D%@%''((/rY   c                6    t        |       j                  |      S rd   )r   issubsetr  s     rW   r  z_AssociationSet.issubset  s    4y!!#&&rY   c                6    t        |       j                  |      S rd   )r   
issupersetr  s     rW   r  z_AssociationSet.issuperset  s    4y##C((rY   c                8    | j                   j                          y rd   rZ  r   s    rW   r  z_AssociationSet.clear  r[  rY   c                    t        |       S rd   r   r   s    rW   r:  z_AssociationSet.copy  s    4yrY   c                    t        |       |k(  S rd   r  r  s     rW   r  z_AssociationSet.__eq__      4yE!!rY   c                    t        |       |k7  S rd   r  r  s     rW   r  z_AssociationSet.__ne__  r  rY   c                    t        |       |k  S rd   r  r  s     rW   r  z_AssociationSet.__lt__      4y5  rY   c                    t        |       |k  S rd   r  r  s     rW   r  z_AssociationSet.__le__  r  rY   c                    t        |       |kD  S rd   r  r  s     rW   r  z_AssociationSet.__gt__  r  rY   c                    t        |       |k\  S rd   r  r  s     rW   r   z_AssociationSet.__ge__  r  rY   c                *    t        t        |             S rd   )rK   r   r   s    rW   r   z_AssociationSet.__repr__  s    CIrY   c                D    t        dt        |       j                  z        r>  r?  r   s    rW   r@  z_AssociationSet.__hash__  rA  rY   Nr  ru  )r  r   ri   r   rD  )r  r:   ri   rs   )ri   r:   )r  rC  ri   rs   )r  r   r   rC  ri   rs   )r  AbstractSet[_S]ri   MutableSet[Union[_T, _S]])ri   zSet[_T])r  zIterable[_S]ri   r  )r  r  ri   r  )r  r   ri   r  )r  AbstractSet[Any]ri   r  )r  r   ri   rs   )r  r  ri   r2   )r  rC  ri   r  )r  r  ri   r  )r  r   ri   rs   )r  r   ri   r   rv  )ri   zAbstractSet[_T]rF  )r  r  ri   r   r   rt  )6r]   r^   r_   r   r   r  r  r  r  r  r  r  rd  r]  rP  r  r^  r  r  r{  r  r  r  rz  r  r  r  r  r  r  r  r  r  r  r:  r  r  r  r  r  r   r   r@  r  r  rV  rH  rI  rJ  rK  rL  r  r   r  r`   rY   rW   rY  rY    sJ   0		2"! 
$$	"#("$
*$	 3,')""!"!"K #FHNN$45 	?OItMMY.C+&sI6>>	? t  rY   rY  )"rU   r   rV   r   rC   r   rD   r   rE   r   rF   r   rG   r   rH   r   rI   r   rJ   Union[_NoArg, bool]rK   r  rL   r   rM   zUnion[_NoArg, Callable[[], _T]]rN   r  rO   r  rP   zUnion[_NoArg, bool, None]ri   zAssociationProxy[Any])dr   
__future__r   r   r  r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r    r!   r"   r#   r$   r%   r&   r'   r(   orm.baser)   orm.interfacesr*   r+   r,   sqlr-   r.   sql.baser/   util.typingr0   r1   r2   r3   r4   r  r5   r6   
orm.mapperr7   sql._typingr8   r9   r:   r<   r>   r@   rA   rB   NO_ARGrX   r[   rb   rl   rp   ru   ry   r{   r   r   r   r   r   r   InspectionAttrInforT   r  r   r  r  r  rJ  r  r  r  rW  rX  rY  r`   rY   rW   <module>r     s   #                ! "                 -   ' . 0 7    ! "  ' 0	//#7' Tsd3	D	9Te3e3 +/7;596: $#(&+ & &#]]7=}}#)==#)==&,mm#ff
f (	f
 5f 3f 4f f !f  $f f f f 5f !f  !!f" $#f$ %fR$? 4huo 4
 %h $B?HV,< BL/8F+; L
 &x %2,hv.> 2F*HV,< Fhrl ;X ;H H ; ;4O
!!"b!	O
j 	>?fA/3 fARe(@(D eP8
%=b%A 8
v
%=b%A 
4&.r2 &$ e5!?$WS\ ?$D'3B7 '"_-b1?23F _DW-c2N384L WtV,R0*R. VrY   