Ë
    r™ãjé7  ã                  óà  — 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 e	r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$  G d„ dee   «      Z% G d „ d!ee&d"f   «      Z' ed#ee&d$f   d%ee&d$f   ¬&«      Z( ed'ee&d(f   d%ee&d(f   ¬&«      Z) ed)ee&d"f   d%ee&d"f   ¬&«      Z* ed*e'¬+«      Z+ ed,e'd%¬-«      Z, G d.„ d/eee      «      Z- ej\                  d0«      	 	 	 	 d5d1„«       Z/ ej\                  d0«      	 	 	 	 	 	 	 	 	 	 d6d2„«       Z0d7d3„Z1y4)8é    )Úannotations)ÚAny)ÚGeneric)ÚLiteral)ÚNoReturn)Úoverload)ÚProtocol)ÚTYPE_CHECKINGé   )Úsqltypes)Ú_T)Ú_Ts)Ú_NoArg)ÚReadOnlyColumnCollectioné   )Úutil)ÚArgumentError©ÚInvalidRequestError)Ú
dunders_re)Útyping)ÚNever)ÚSelf)ÚTypeVar)ÚUnpack)ÚColumnClause)ÚKeyedColumnElement)ÚColumn)Ú
TypeEngine)Ú_AnnotationScanTypec                  óp   — e Zd ZU dZdZded<   er&ed
d„«       Ze	 	 	 	 	 	 dd„«       Zedd„«       Zdd„Zy	y	)ÚNamedzÖA named descriptor that is interpreted by SQLAlchemy in various ways.

    .. seealso::

        :class:`_schema.TypedColumns` Define table columns using this
        descriptor.

    .. versionadded:: 2.1.0b2
    © ÚstrÚkeyc                 ó   — y ©Nr#   ©ÚselfÚinstanceÚowners      úi/var/www/html/python-recuperauto-other/env/lib/python3.12/site-packages/sqlalchemy/sql/_annotated_cols.pyÚ__get__zNamed.__get__:   s   € Ø@Có    c                 ó   — y r'   r#   r(   s      r,   r-   zNamed.__get__=   s   € ð r.   c                 ó   — y r'   r#   r(   s      r,   r-   zNamed.__get__A   s   € Ø>Ar.   c                 ó   — y r'   r#   r(   s      r,   r-   zNamed.__get__D   s   � r.   N)r*   ÚNoner+   r   Úreturnr   )r*   ÚTypedColumnsr+   r   r3   z
Column[_T])r*   r   r+   r   r3   r   )r*   zobject | Noner+   r   r3   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Ú__annotations__r
   r   r-   r#   r.   r,   r"   r"   (   sh   … ñð €Ià	ƒHÙð 
ÚCó 
ØCà	ð	Ø(ð	Ø14ð	àò	ó 
ð	ð 
ÚAó 
ØAäJð r.   r"   c                  ó(   — e Zd ZdZdZesdd„Zdd„Zy)r4   aÓ  Class that generally represent the typed columns of a :class:`.Table`,
    but can be used with most :class:`_sql.FromClause` subclasses with the
    :meth:`_sql.FromClause.with_cols` method.

    This is a "typing only" class that is never instantiated at runtime: the
    type checker will think that this class is exposed as the ``table.c``
    attribute, but in reality a normal :class:`_schema.ColumnCollection` is
    used at runtime.

    Subclasses should just list the columns as class attributes, without
    specifying method or other non column members.

    To resolve the columns, a simplified version of the ORM logic is used,
    in particular, columns can be declared by:

    * directly instantiating :class:`_schema.Column`, to declare constraint,
      custom SQL types and additional column options. The annotation is
      usually inferred by type checkers from the column instance;
    * using only a :class:`.Named` or :class:`_schema.Column` type annotation,
      where nullability and SQL type will be inferred by the python type
      provided.
      Type inference is available for a common subset of python types.
    * a mix of both, where the instance can be used to declare
      constraints and other column options while the annotation will be used
      to set the SQL type and nullability if not provided by the instance.
      The information provided in the instance will take precedence over
      the annotation when they are conflicting, for example if setting
      nullable=True with an annotation tha does not include ``None``.

    In all cases the name is inferred from the attribute name, unless
    explicitly provided.

    .. note::

        The generated table will create a copy of any column instance assigned
        as attributes of this class, so columns should be accessed only via
        the ``table.c`` collection, not using this class directly.

    Example of the inference behavior::

        from sqlalchemy import Column, Integer, Named, String, TypedColumns


        class tbl_cols(TypedColumns):
            # the name will be set to ``id``, type is inferred as Column[int]
            # from the Integer SQL type.
            id = Column(Integer, primary_key=True)

            # not null String column is generated
            name: Named[str]

            # nullable Double column is generated
            weight: Named[float | None]

            # nullable Integer column, with SQL name 'user_age'
            age: Named[int | None] = Column("user_age")

            # not null column with type String(42)
            middle_name: Named[str] = Column(String(42))

    Mixins and subclasses are also supported::

        class with_id(TypedColumns):
            id = Column(Integer, primary_key=True)


        class named_cols(TypedColumns):
            name: Named[str]
            description: Named[str | None]


        class product_cols(named_cols, with_id):
            ean: Named[str] = Column(unique=True)


        product = Table("product", metadata, product_cols)


        class office_cols(named_cols, with_id):
            address: Named[str]


        office = Table("office", metadata, office_cols)

    The positional types returned when selecting the table can
    be optionally declared by specifying a :attr:`.HasRowPos.__row_pos__`
    annotation::

        from sqlalchemy import select


        class some_cols(TypedColumns):
            id = Column(Integer, primary_key=True)
            name: Named[str]
            weight: Named[float | None]

            __row_pos__: tuple[int, str, float | None]


        some_table = Table("st", metadata, some_cols)

        # both will be typed as Select[int, str, float | None]
        stmt1 = some_table.select()
        stmt2 = select(some_table)

    .. seealso::

        :class:`.Table` for usage details on how to use this class to
        create a table instance.

        :meth:`_sql.FromClause.with_cols` to apply a :class:`.TypedColumns`
        to a from clause.

    .. versionadded:: 2.1.0b2
    r#   c                ó   — t        d«      ‚)Nz)Cannot instantiate a TypedColumns object.r   )ÚclsÚargsÚkwargss      r,   Ú__new__zTypedColumns.__new__Á   s   € Ü%Ø;óð r.   c                óÚ   — | j                   j                  «       D ��ch c]'  \  }}t        j                  |«      st	        |«      r|’Œ) }}}|rt        dt        |«      › �«      ‚y c c}}w )Nz6TypedColumns subclasses may not define methods. Found )Ú__dict__Úitemsr   ÚmatchÚcallabler   Úsorted)r=   ÚnameÚvalueÚmethodss       r,   Ú__init_subclass__zTypedColumns.__init_subclass__Æ   sv   € ð  #Ÿ|™|×1Ñ1Ó3÷
á��eÜ×#Ñ# DÔ)¬h°u¬oò ð
ˆñ 
ñ
 Ü%ðÜ ›Ð)ð+óð ð ùó
s   ž,A'N)r>   r   r?   r   r3   r   )r3   r2   )r5   r6   r7   r8   r9   r
   r@   rJ   r#   r.   r,   r4   r4   H   s   „ ñrðh €Iáó	ô

r.   r4   zColumn[Any]Ú_KeyColCC_cozKeyedColumnElement[Any]T)ÚboundÚ	covariantÚdefaultÚ_ColClauseCC_cozColumnClause[Any]Ú	_ColCC_coÚ_TC)rL   Ú_TC_co)rL   rM   c                  ó   — e Zd ZU dZded<   y)Ú	HasRowPosz¥Protocol for a :class:`_schema.TypedColumns` used to indicate the
    positional types will be returned when selecting the table.

    .. versionadded:: 2.1.0b2
    ztuple[Unpack[_Ts]]Ú__row_pos__N)r5   r6   r7   r8   r:   r#   r.   r,   rT   rT   ê   s   … ñð $Ó#ðr.   rT   zsqlalchemy.sql.schemac                ó  — i }t         j                  j                  j                  }t         j                  j                  j                  }| j
                  d d d…   D �]  }|t        j
                  v rŒt        j                  |«      }t        |«      }t        j                  t        |«      t        |«      «      D �cg c]:  }t        j                  |«      s#||j                  |«      |j                  |«      f‘Œ< }}|D �]h  \  }	}
}|
€ž|€J ‚t        | |	|j                  |«      }|t         j"                  u rt%        d|› d|j&                  › d|	› d�«      ‚t)        |«      }|€"t%        d|› d|› d|j&                  › d|	› d�	«      ‚ ||	|t+        j,                  |«      ¬	«      ||	<   Œ¨t/        |
|«      �r�|
j0                  D ]A  }|j2                  €Œ|j2                  j4                  �Œ't7        d
|j&                  › d|	› d�«      ‚ |
j9                  «       }|j:                  |j<                  k(  r|j:                  |	k7  r|	|_        |j<                  €|	|_        |j>                  }d }t         j"                  }|�Jt        | |	|j                  |«      }|t         j"                  ur t)        |«      }t+        j,                  |«      }|j@                  r=|€(|j0                  st%        d|j&                  › d|	› d�«      ‚|�|jC                  |«       |t         j"                  ur!|jD                  |u r|jF                  s||_$        |||	<   �ŒDt%        d|j&                  › d|	› dt?        |
«      › �«      ‚ �Œ t        |jK                  «       «      S c c}w )Néÿÿÿÿz7No type information could be extracted from annotation ú for attribute 'ú.ú'z#Could not find a SQL type for type z obtained from annotation z in attribute ')ÚnullablezColumn 'zŽ' with foreign key to non-table-bound columns is not supported when using a TypedColumns. If possible use the qualified string name the columnz4Python typing annotation is required for attribute 'zG' when primary argument(s) for Column construct are None or not presentz Unexpected value for attribute 'z'. Expected a Column, not: )&r   Ú	preloadedÚ
sql_schemar   ÚNULL_UNSPECIFIEDÚ__mro__r4   Úget_annotationsÚvarsÚmerge_lists_w_orderingÚlistr   rD   ÚgetÚ_collect_annotationr6   r   ÚNO_ARGr   r5   Ú_get_sqltypeÚ	sa_typingÚincludes_noneÚ
isinstanceÚforeign_keysÚ_table_columnÚtabler   Ú_copyr%   rG   ÚtypeÚ_isnullÚ	_set_typeÚ_user_defined_nullableÚprimary_keyr[   Úvalues)Útable_columns_clsÚcolumnsr   r^   ÚbaseÚcls_annotationsÚcls_varsÚnrC   rG   ÚobjÚ
annotationÚextracted_typeÚsqltypeÚfkÚcolÚanno_sqltyper[   s                     r,   Ú_extract_columns_from_classr‚   ÷   s°  € ð ')€Gä�^‰^×&Ñ&×-Ñ-€FÜ—~‘~×0Ñ0×AÑAÐà!×)Ñ)©$¨B¨$Ñ/ó aˆØ”<×'Ñ'Ñ'Øô ×.Ñ.¨tÓ4ˆÜ˜“:ˆô ×0Ñ0Ü�X“¤ _Ó 5óö
àô ×#Ñ# AÔ&ð	 �—‘˜Q“ ×!4Ñ!4°QÓ!7Ò8ð
ˆð 
ð &+ó R	Ñ!ˆD�#�zØˆ{Ø!Ð-Ð-Ð-ä!4Ø% t¨T¯_©_¸jó"�ð "¤V§]¡]Ñ2Ü'ð&Ø&0 \ð 2Ø ŸM™M˜?¨!¨D¨6°ð4óð ô
 ' ~Ó6�Ø�?Ü'Ø=¸nÐ=Mð N4Ø4>°<ð @&Ø&*§m¡m _°A°d°V¸1ð>óð ñ
 !'ØØÜ&×4Ñ4°^ÓDô!�˜’ô
 ˜C Õ(ð ×*Ñ*ò 
�Bà×(Ñ(Ñ4Ø×,Ñ,×2Ñ2Ñ:ä1Ø& t§}¡} o°Q°t°fð =?ð ?óð ð
ð —i‘i“k�à—7‘7˜cŸh™hÒ&¨3¯7©7°dª?Ø"�C”GØ—8‘8Ð#Ø#�C”HàŸ(™(�Ø#�Ü:@¿-¹-�ØÐ)ä%8Ø)¨4°·±À*ó&�Nð &¬V¯]©]Ñ:Ü'3°NÓ'C˜Ü#,×#:Ñ#:¸>Ó#J˜à—?’?Ø#Ð+°C×4DÒ4DÜ+ð*Ø*.¯-©-¨¸¸$¸ð @2ð2óð ð &Ð1ØŸ™ lÔ3ð ¤F§M¡MÑ1Ø×2Ñ2Ð6FÑFØŸOšOà#+�C”LØ #�˜“ä#Ø6°t·}±}°oÀQÀtÀfð M1Ü15°c³°ð=óð ò_R	ðaôH �—‘Ó Ó!Ð!ùò{
s   Â>?N	c           
     óF  — t         j                  j                  j                  }|t        dœ}	 t        j                  | |||«      }t        j                  |«      s2t        |t        «      r"t        ||t        f«      rt        j                  S t        j                   ||t        f«      st        d|› d| j                  › d|› d�«      ‚t#        |j$                  «      dk(  sJ ‚|j$                  d	   S # t        $ r%}t        d|› d| j                  › d|› d�«      |‚d }~ww xY w)
N)r   r"   zCould not interpret annotation rX   rY   rZ   zAnnotation z"' is not of type Named/Column[...]r   r   )r   r\   r]   r   r"   rh   Úde_stringify_annotationÚ	Exceptionr   r5   Ú
is_genericrj   ro   Ú
issubclassr   rf   Úis_origin_of_clsÚlenÚ__args__)r=   rG   ÚmoduleÚraw_annotationr   Ú_localsr|   Úes           r,   re   re   g  s.  € ô �^‰^×&Ñ&×-Ñ-€Fà¬%Ñ0€GðÜ×6Ñ6Ø� ¨ó
ˆ
ô × Ñ  Ô,Ü�z¤4Ô(Ü�z F¬E ?Ô3ô �}‰}ÐÜ×'Ñ'¨
°V¼U°OÔDÜØ˜.Ð)ð *Ø—‘ˆ~˜Q˜t˜fÐ$FðHó
ð 	
ô
 �:×&Ñ&Ó'¨1Ò,Ð,Ð,Ø×"Ñ" 1Ñ%Ð%øô) ò ÜØ-¨nÐ-=ð >ØŸ,™,˜ q¨¨¨að1ó
ð ð	ûðús   ¯C2 Ã2	D Ã; DÄD c                óž   — t        j                  | «      }t        j                  |«      }|�!|j                  st        j
                  |«      S y r'   )rh   Úde_optionalize_union_typesr   Ú_type_map_getrp   Úto_instance)r|   Úour_typeÚsql_types      r,   rg   rg   Š  sF   € Ü×3Ñ3°JÓ?€Hô ×%Ñ% hÓ/€HØÐ H×$4Ò$4Ü×#Ñ# HÓ-Ð-àr.   N)ru   ztype[TypedColumns]r3   zlist[Column[Any]])
r=   z	type[Any]rG   r$   r‹   r$   rŒ   r    r3   z,_AnnotationScanType | Literal[_NoArg.NO_ARG])r|   r    r3   zTypeEngine[Any] | None)2Ú
__future__r   r   r   r   r   r   r   r	   r
   Ú r   Ú_typingr   r   rw   r   r   r   Úexcr   r   r   rh   Úutil.typingr   r   r   r   Úelementsr   r   Úschemar   Útype_apir   r    r"   r$   r4   rK   rO   rP   rQ   rR   rT   Úpreload_moduler‚   re   rg   r#   r.   r,   ú<module>rž      sÈ  ðõ #å Ý Ý Ý Ý Ý Ý  å Ý Ý Ý Ý *Ý Ý Ý %Ý Ý &Ý Ý Ý !Ý  áÝ&Ý,ÝÝ$Ý1ôKˆG�B‰Kô Kô@HÐ+¨C°Ð,>Ñ?ô HñV ØØ
" 3Ð(AÐ#AÑ
BØØ$ SÐ*CÐ%CÑDô	€ñ ØØ
" 3Ð(;Ð#;Ñ
<ØØ$ SÐ*=Ð%=Ñ>ô	€ñ ØØ
" 3¨Ð#5Ñ
6ØØ$ S¨-Ð%7Ñ8ô	€	ñ ˆe˜<Ô(€Ù	� ¸Ô	>€ô
�˜ ™Ñ%ô 
ð €×ÑÐ,Ó-ðl"Ø)ðl"àòl"ó .ðl"ð^ €×ÑÐ,Ó-ð&Ø	ð&Øð&Ø'*ð&Ø<Oð&à1ò&ó .ð&ôDr.   