
    ,h                       S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSKJ"r"  SSKJ#r#  SS KJ$r$  SS!K%J&r&  SS"K%J'r'  SS#K%J(r(  SS$K%J)r)  SS%K*J+r+  SS&K*J,r,  SS'K*J-r-  SS(K*J.r.  SS)K*J/r/  SS*K*J0r0  SS+K*J1r1  SS,K2J3r3  SS-K2J4r4  SS-K2J4r5  SS.K6J7r7  SS/K8J9r9  SS0K:J;r;  SS1K<J=r=  S2S3KJ>r>  S2S4KJ?r?  S2S5KJ@r@  S2S6KAJBrB  S2S7KCJDrD  S2S8KEJFrF  S2S9KGJHrH  S2S:KIJJrJ  S2S;K@JKrK  S2S<K@JLrL  S2S=K@JrM  S2S>K@JNrN  S2S?KOJPrP  S2S@KOJQrQ  S2SAKOJRrR  S2SBKOJSrS  S2SCKOJTrT  S2SDKOJUrU  S2SEKOJVrV  S2SFKOJWrW  S2SGKOJXrX  S2SHKOJYrY  \(       a0  SSIKZJ[r[  SSJKZJ\r\  SSKK*J]r]  SSLKJ^r^  SSMKJ_r_  SS1K<J=r=  S2SNK`Jara  S2SOKbJcrc  \" SP\SQ9rd\" SR\SQ9re\\SS4   rf\	\SS4   rg\ST\\(\d   \)\d   \F\d   4   4   rhSzSU jri " SV SW\j5      rk " SX SY\k\?R                  \7\      5      rm\MR                  " \9\;\3\4\!\"\\#\ 4	SZ9 " S[ S\\m5      5       ro " S] S^\m5      rp S{     S|S_ jjrq " S` Sa5      rr " Sb Sc\r\\d   5      rs " Sd Se\R                  \d   \r5      ru " Sf Sg\u\d   5      rvS}Sh jrwS~Si jrx " Sj Sk\oSl9ry " Sm Sn\?R                  \=\      \mSl9rzSSo jr{ " Sp Sq\?R                  \=\      5      r|        SSr jr}SS\~SsSS\.\pSt.                 SSu jjr " Sv Sw5      r\r\(       d  \r\SSx jr\?GR                  " \p\z\m5      SSy j5       rg)z1Public API functions and helpers for declarative.    )annotationsN)Any)Callable)ClassVar)Dict)	FrozenSet)Generic)Iterable)Iterator)Mapping)Optional)overload)Set)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )
attributes)clsregistry)instrumentation)
interfaces)	mapperlib)	composite)deferred)mapped_column)relationship)synonym)InstrumentedAttribute)_inspect_mapped_class)_is_mapped_class)Mapped)ORMDescriptor_add_attribute)_as_declarative)_ClassScanMapperConfig)_declarative_constructor)_DeferredMapperConfig)_del_attribute_mapper)	Composite)Synonym)Mapper)MappedColumn)RelationshipProperty)InstanceState   )exc)
inspection)util)sqltypes)_NoArg)SQLCoreOperations)MetaData)
FromClause)hybridmethod)hybridproperty)typing)warn_deprecated)CallableReference)de_optionalize_union_types)flatten_newtype)
is_generic)
is_literal)
is_newtype)	is_pep695)Literal)LITERAL_TYPES)Self)_O)_RegistryType)_DataclassArguments)ClassManager)MapperProperty)_TypeEngineArgument)_MatchedOnType_T)bound_TTz_TypeEngineArgument[Any].c                P    U R                   SS  H  n[        USS5      c  M    g   g)a/  Given a class, return True if any of the classes it inherits from has a
mapped table, otherwise return False.

This is used in declarative mixins to build attributes that behave
differently for the base class vs. a subclass in an inheritance
hierarchy.

.. seealso::

    :ref:`decl_mixin_inheritance`

r   N	__table__TF)__mro__getattr)clsclass_s     O/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/orm/decl_api.pyhas_inherited_tabler\   n   s/     ++ab/6;-9 "     c                  (    \ rS rSrSS jrSS jrSrg)_DynamicAttributesType   c                j    SU R                   ;   a  [        XU5        g [        R                  XU5        g N
__mapper__)__dict__r&   type__setattr__)rY   keyvalues      r[   rf   "_DynamicAttributesType.__setattr__   s(    3<<'3U+Su-r]   c                f    SU R                   ;   a  [        X5        g [        R                  X5        g rb   )rd   r+   re   __delattr__rY   rg   s     r[   rk   "_DynamicAttributesType.__delattr__   s$    3<<'3$S&r]    N)rg   strrh   r   returnNone)rg   ro   rp   rq   )__name__
__module____qualname____firstlineno__rf   rk   __static_attributes__rn   r]   r[   r_   r_      s    .'r]   r_   c                      \ rS rSrSrSrg)DeclarativeAttributeIntercept   zMetaclass that may be used in conjunction with the
:class:`_orm.DeclarativeBase` class to support addition of class
attributes dynamically.

rn   Nrr   rs   rt   ru   __doc__rv   rn   r]   r[   rx   rx      s    
r]   rx   field_specifiersc                      \ rS rSrSrSrg)DCTransformDeclarative   z-metaclass that includes @dataclass_transformsrn   Nrz   rn   r]   r[   r   r      s     8r]   r   c                  H    \ rS rSr% S\S'   S\S'             S	S jrSrg)
DeclarativeMeta   r;   metadataRegistryTyperegistryc                H   U R                   n[        U SS 5      nUcC  UR                  SS 5      n[        U[        5      (       d  [
        R                  " S5      eXPl        U R                   R                  SS5      (       d  [        XPU5        [        R                  XX#5        g )N_sa_registryr   ziDeclarative base class has no 'registry' attribute, or registry is not a sqlalchemy.orm.registry() object__abstract__F)rd   rX   get
isinstancer   r5   InvalidRequestErrorr   r'   re   __init__)rY   	classnamebasesdict_kwregs         r[   r   DeclarativeMeta.__init__   s    
 
 c>40;))J-Cc8,,--L 
 $' ||66Ce,ce3r]   rn   N)
r   r   r   r   r   r   r   r   rp   rq   )rr   rs   rt   ru   __annotations__r   rv   rn   r]   r[   r   r      s;    44$'4034;>4	4r]   r   c                   ^ ^ SUU 4S jjnU$ )a  Decorator that produces an :func:`_orm.synonym`
attribute in conjunction with a Python descriptor.

The function being decorated is passed to :func:`_orm.synonym` as the
:paramref:`.orm.synonym.descriptor` parameter::

    class MyClass(Base):
        __tablename__ = "my_table"

        id = Column(Integer, primary_key=True)
        _job_status = Column("job_status", String(50))

        @synonym_for("job_status")
        @property
        def job_status(self):
            return "Status: %s" % self._job_status

The :ref:`hybrid properties <mapper_hybrids>` feature of SQLAlchemy
is typically preferred instead of synonyms, which is a more legacy
feature.

.. seealso::

    :ref:`synonyms` - Overview of synonyms

    :func:`_orm.synonym` - the mapper-level function

    :ref:`mapper_hybrids` - The Hybrid Attribute extension provides an
    updated approach to augmenting attribute behavior more flexibly than
    can be achieved with synonyms.

c                   > [        TTU S9$ )N)
map_column
descriptor)_orm_synonym)fnr   names    r[   decoratesynonym_for.<locals>.decorate   s    DZBGGr]   )r   Callable[..., Any]rp   zSynonym[Any]rn   )r   r   r   s   `` r[   synonym_forr      s    HH H Or]   c                  D    \ rS rSr  S     SS jjrS	S jrS
S jrSrg)_declared_attr_common   c                    [        U[        5      (       a  UR                  nXl        X l        X0l        UR                  U l        g N)r   classmethod__func__fget
_cascading_quietr{   )selfr   	cascadingquiets       r[   r   _declared_attr_common.__init__   s4     b+&&B	#zzr]   c                `    [         R                  " U R                  5      R                  S5      $ )Nrp   )r7   get_annotationsr   r   r   s    r[   _collect_return_annotation0_declared_attr_common._collect_return_annotation
  s"    ##DII.228<<r]   c                   Un[         R                  " U5      nUc}  [        R                  " SU R                  R
                  5      (       d<  [        R                  " SU R                  R
                  < SUR
                  < 35        U R	                  U5      $ UR                  (       a  U R	                  U5      $ UR                  5       nUc   eUR                  nX;   a  X`   $ U R	                  U5      =X`'   nU$ )Nz^__.+__$z*Unmanaged access of declarative attribute z from non-mapped class )r   opt_manager_of_classrematchr   rr   r7   warn	is_mappeddeclarative_scandeclared_attr_reg)r   instanceownerrY   managerr   r   objs           r[   __get___declared_attr_common.__get__  s     11#6?88K););<< 		-1YY-?-?O 99S>! 99S>! #335  +++00;9"iin,CIJr]   )r{   r   r   r   N)FF)r   r   r   boolr   r   )rp   zOptional[Type[Any]])r   Optional[object]r   r   rp   r   )rr   rs   rt   ru   r   r   r   rv   rn   r]   r[   r   r      s5      	"" " 	"*=%r]   r   c                  z    \ rS rSr\R
                  (       a"   S	   S
S jjrSS jrSS jrSS jr	SS jr
SrgSrg)_declared_directivei5  c                    g r   rn   r   r   r   s      r[   r   _declared_directive.__init__:       r]   c                    g r   rn   r   r   r   s      r[   r   _declared_directive.__get__@  s    r]   c                    g r   rn   r   r   rh   s      r[   __set___declared_directive.__set__B      cr]   c                    g r   rn   r   r   s     r[   
__delete___declared_directive.__delete__D      Sr]   c                    g r   rn   r   r   s     r[   __call___declared_directive.__call__F  s    r]   rn   NF)r   zCallable[..., _T]r   r   )r   r   r   r   rp   rR   r   r   rh   r   rp   rq   r   r   rp   rq   )r   zCallable[..., _TT]rp   z_declared_directive[_TT])rr   rs   rt   ru   r?   r   r   r   r   r   r   rv   rn   r]   r[   r   r   5  s?     
 $	!	 	 	MA8	 r]   r   c                      \ rS rSrSr\R                  (       a:   S   SS jjrSS jrSS jr	\
      SS j5       r\
SS j5       r      SS jr\SS	 j5       r\SS
 j5       r\SS j5       rSrg)declared_attriK  a  Mark a class-level method as representing the definition of
a mapped property or Declarative directive.

:class:`_orm.declared_attr` is typically applied as a decorator to a class
level method, turning the attribute into a scalar-like property that can be
invoked from the uninstantiated class. The Declarative mapping process
looks for these :class:`_orm.declared_attr` callables as it scans classes,
and assumes any attribute marked with :class:`_orm.declared_attr` will be a
callable that will produce an object specific to the Declarative mapping or
table configuration.

:class:`_orm.declared_attr` is usually applicable to
:ref:`mixins <orm_mixins_toplevel>`, to define relationships that are to be
applied to different implementors of the class. It may also be used to
define dynamically generated column expressions and other Declarative
attributes.

Example::

    class ProvidesUserMixin:
        "A mixin that adds a 'user' relationship to classes."

        user_id: Mapped[int] = mapped_column(ForeignKey("user_table.id"))

        @declared_attr
        def user(cls) -> Mapped["User"]:
            return relationship("User")

When used with Declarative directives such as ``__tablename__``, the
:meth:`_orm.declared_attr.directive` modifier may be used which indicates
to :pep:`484` typing tools that the given method is not dealing with
:class:`_orm.Mapped` attributes::

    class CreateTableName:
        @declared_attr.directive
        def __tablename__(cls) -> str:
            return cls.__name__.lower()

:class:`_orm.declared_attr` can also be applied directly to mapped
classes, to allow for attributes that dynamically configure themselves
on subclasses when using mapped inheritance schemes.   Below
illustrates :class:`_orm.declared_attr` to create a dynamic scheme
for generating the :paramref:`_orm.Mapper.polymorphic_identity` parameter
for subclasses::

    class Employee(Base):
        __tablename__ = "employee"

        id: Mapped[int] = mapped_column(primary_key=True)
        type: Mapped[str] = mapped_column(String(50))

        @declared_attr.directive
        def __mapper_args__(cls) -> Dict[str, Any]:
            if cls.__name__ == "Employee":
                return {
                    "polymorphic_on": cls.type,
                    "polymorphic_identity": "Employee",
                }
            else:
                return {"polymorphic_identity": cls.__name__}


    class Engineer(Employee):
        pass

:class:`_orm.declared_attr` supports decorating functions that are
explicitly decorated with ``@classmethod``. This is never necessary from a
runtime perspective, however may be needed in order to support :pep:`484`
typing tools that don't otherwise recognize the decorated function as
having class-level behaviors for the ``cls`` parameter::

    class SomethingMixin:
        x: Mapped[int]
        y: Mapped[int]

        @declared_attr
        @classmethod
        def x_plus_y(cls) -> Mapped[int]:
            return column_property(cls.x + cls.y)

.. versionadded:: 2.0 - :class:`_orm.declared_attr` can accommodate a
   function decorated with ``@classmethod`` to help with :pep:`484`
   integration where needed.


.. seealso::

    :ref:`orm_mixins_toplevel` - Declarative Mixin documentation with
    background on use patterns for :class:`_orm.declared_attr`.

c                    g r   rn   r   s      r[   r   declared_attr.__init__  r   r]   c                    g r   rn   r   s      r[   r   declared_attr.__set__  r   r]   c                    g r   rn   r   s     r[   r   declared_attr.__delete__  r   r]   c                    g r   rn   r   s      r[   r   declared_attr.__get__  s     ),r]   c                    g r   rn   r   s      r[   r   r     s    ?Br]   c                    g r   rn   r   s      r[   r   r     s    36r]   c                    [        S0 UD6$ Nrn   )_stateful_declared_attr)rY   r   s     r[   	_statefuldeclared_attr._stateful  s    &,,,r]   c                    [         $ r   )r   rY   s    r[   	directivedeclared_attr.directive  s
     #"r]   c                     U R                  SS9$ )NT)r   )r   r   s    r[   r   declared_attr.cascading  s     }}t},,r]   rn   Nr   )r   _DeclaredAttrDecorated[_T]r   r   r   r   )r   rq   r   r   rp   zInstrumentedAttribute[_T])r   objectr   r   rp   rR   )r   r   r   r   rp   z$Union[InstrumentedAttribute[_T], _T]r   r   rp   _stateful_declared_attr[_T])rp   z_declared_directive[Any])rp   r   )rr   rs   rt   ru   r{   r?   r   r   r   r   r   r   r=   r   r>   r   r   rv   rn   r]   r[   r   r   K  s    Zx 
 $	*	 	 	B8 
	, 	,),	,&	, 
	, 
B 
B	7,	758	71	7 - - # # - -r]   r   c                  H    \ rS rSr% S\S'   S	S jr\S
S j5       rSS jrSr	g)r   i  zDict[str, Any]r   c                    Xl         g r   r   r   r   s     r[   r    _stateful_declared_attr.__init__  s    r]   c                n    U R                   R                  5       nUR                  U5        [        S0 UD6$ r   )r   copyupdater   )r   r   new_kws      r[   r   !_stateful_declared_attr._stateful  s+    b&000r]   c                .    [        U40 U R                  D6$ r   )r   r   r   s     r[   r    _stateful_declared_attr.__call__  s    R+477++r]   r   Nr   r   r   )r   r   rp   zdeclared_attr[_T])
rr   rs   rt   ru   r   r   r=   r   r   rv   rn   r]   r[   r   r     s&     1 1
,r]   r   c                    U $ )a  Mark a class as providing the feature of "declarative mixin".

E.g.::

    from sqlalchemy.orm import declared_attr
    from sqlalchemy.orm import declarative_mixin


    @declarative_mixin
    class MyMixin:

        @declared_attr
        def __tablename__(cls):
            return cls.__name__.lower()

        __table_args__ = {"mysql_engine": "InnoDB"}
        __mapper_args__ = {"always_refresh": True}

        id = Column(Integer, primary_key=True)


    class MyModel(MyMixin, Base):
        name = Column(String(1000))

The :func:`_orm.declarative_mixin` decorator currently does not modify
the given class in any way; it's current purpose is strictly to assist
the :ref:`Mypy plugin <mypy_toplevel>` in being able to identify
SQLAlchemy declarative mixin classes when no other context is present.

.. versionadded:: 1.4.6

.. seealso::

    :ref:`orm_mixins_toplevel`

    :ref:`mypy_declarative_mixins` - in the
    :ref:`Mypy plugin documentation <mypy_toplevel>`

rn   r   s    r[   declarative_mixinr    s
    R Jr]   c                d   SU R                   ;   a  U R                   S   nOS nSU R                   ;   a  U R                   S   nOS nU R                   R                  SS 5      nUbE  [        U[        5      (       d  [        R
                  " S5      eUb  [        R
                  " S5      eO[        XS9nX0l        X0l        SU R                   ;  a  U R                  R                  U l        [        U S[        R                  5      [        R                  L a  U R                  R                  U l
        g g )Nr   type_annotation_mapr   zfDeclarative base class has a 'registry' attribute that is not an instance of sqlalchemy.orm.registry()zDeclarative base class has both a 'registry' attribute and a type_annotation_map entry.  Per-base type_annotation_maps are not supported.  Please apply the type_annotation_map to this registry directly.)r   r  r   )rd   r   r   r   r5   r   r   r   rX   r   r   constructor)rY   r   r  r   s       r[   _setup_declarative_baser
    s   S\\!<<
+,!ll+@A"
,,

:t
,C
#x(())?  !,))-  - 
 %||,,sJ0FOOC||// Dr]   c                  
  ^  \ rS rSrSr\R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  4                   SU 4S jjjrSrU =r	$ )MappedAsDataclassi8  zMixin class to indicate when mapping this class, also convert it to be
a dataclass.

.. seealso::

    :ref:`orm_declarative_native_dataclasses` - complete background
    on SQLAlchemy native dataclass mapping

.. versionadded:: 2.0

c	           	       > UUUUUUUUS.n
[        U S5      (       a  U R                  n[        R                  " U5        U
R	                  5        VVs0 s H:  u  pX[
        R                  L a   UR                  U[
        R                  5      OU_M<     snn=U l        nO	U
=U l        n[        TU ]$  " S0 U	D6  [        U 5      (       d.  [        R                  " U 5      n[        R                  " XU5        g g s  snnf )Ninitrepreqorderunsafe_hash
match_argskw_onlydataclass_callable_sa_apply_dc_transformsrn   )hasattrr  r(   _assert_dc_argumentsitemsr9   NO_ARGr   super__init_subclass__r"   (_update_annotations_for_non_mapped_class_apply_dataclasses_to_any_class)rY   r  r  r  r  r  r  r  r  r   apply_dc_transformscurrentkvcurrent_transformsnew_anno	__class__s                   r[   r  #MappedAsDataclass.__init_subclass__E  s    &$"4	4
 312211G"77@ 0557@7DA 4F7;;q&--0AM7@ C'*< $C'*< 	!'B'$$&OOH #BB"	 %@s   AC8rn   )r  Union[_NoArg, bool]r  r(  r  r(  r  r(  r  r(  r  r(  r  r(  r  'Union[_NoArg, Callable[..., Type[Any]]]r   r   rp   rq   )
rr   rs   rt   ru   r{   r9   r  r  rv   __classcell__r&  s   @r[   r  r  8  s    
 %+MM$*MM"(--%+]]+1==*0--'-}} MM1!1 "1  	1
 #1 )1 (1 %1
1 1 
1 1r]   r  )	metaclassc                     ^  \ rS rSr% Sr\R                  (       aC  SS jrSS jrS\	S'   S\	S'    S\	S	'    S
\	S'   S\	S'    S\	S'    S\	S'    S\	S'    S\	S'    SS jr
SU 4S jjrSrU =r$ )DeclarativeBaseiy  a  Base class used for declarative class definitions.

The :class:`_orm.DeclarativeBase` allows for the creation of new
declarative bases in such a way that is compatible with type checkers::


    from sqlalchemy.orm import DeclarativeBase


    class Base(DeclarativeBase):
        pass

The above ``Base`` class is now usable as the base for new declarative
mappings.  The superclass makes use of the ``__init_subclass__()``
method to set up new classes and metaclasses aren't used.

When first used, the :class:`_orm.DeclarativeBase` class instantiates a new
:class:`_orm.registry` to be used with the base, assuming one was not
provided explicitly. The :class:`_orm.DeclarativeBase` class supports
class-level attributes which act as parameters for the construction of this
registry; such as to indicate a specific :class:`_schema.MetaData`
collection as well as a specific value for
:paramref:`_orm.registry.type_annotation_map`::

    from typing_extensions import Annotated

    from sqlalchemy import BigInteger
    from sqlalchemy import MetaData
    from sqlalchemy import String
    from sqlalchemy.orm import DeclarativeBase

    bigint = Annotated[int, "bigint"]
    my_metadata = MetaData()


    class Base(DeclarativeBase):
        metadata = my_metadata
        type_annotation_map = {
            str: String().with_variant(String(255), "mysql", "mariadb"),
            bigint: BigInteger(),
        }

Class-level attributes which may be specified include:

:param metadata: optional :class:`_schema.MetaData` collection.
 If a :class:`_orm.registry` is constructed automatically, this
 :class:`_schema.MetaData` collection will be used to construct it.
 Otherwise, the local :class:`_schema.MetaData` collection will supercede
 that used by an existing :class:`_orm.registry` passed using the
 :paramref:`_orm.DeclarativeBase.registry` parameter.
:param type_annotation_map: optional type annotation map that will be
 passed to the :class:`_orm.registry` as
 :paramref:`_orm.registry.type_annotation_map`.
:param registry: supply a pre-existing :class:`_orm.registry` directly.

.. versionadded:: 2.0  Added :class:`.DeclarativeBase`, so that declarative
   base classes may be constructed in such a way that is also recognized
   by :pep:`484` type checkers.   As a result, :class:`.DeclarativeBase`
   and other subclassing-oriented APIs should be seen as
   superseding previous "class returned by a function" APIs, namely
   :func:`_orm.declarative_base` and :meth:`_orm.registry.generate_base`,
   where the base class returned cannot be recognized by type checkers
   without using plugins.

**__init__ behavior**

In a plain Python class, the base-most ``__init__()`` method in the class
hierarchy is ``object.__init__()``, which accepts no arguments. However,
when the :class:`_orm.DeclarativeBase` subclass is first declared, the
class is given an ``__init__()`` method that links to the
:paramref:`_orm.registry.constructor` constructor function, if no
``__init__()`` method is already present; this is the usual declarative
constructor that will assign keyword arguments as attributes on the
instance, assuming those attributes are established at the class level
(i.e. are mapped, or are linked to a descriptor). This constructor is
**never accessed by a mapped class without being called explicitly via
super()**, as mapped classes are themselves given an ``__init__()`` method
directly which calls :paramref:`_orm.registry.constructor`, so in the
default case works independently of what the base-most ``__init__()``
method does.

.. versionchanged:: 2.0.1  :class:`_orm.DeclarativeBase` has a default
   constructor that links to :paramref:`_orm.registry.constructor` by
   default, so that calls to ``super().__init__()`` can access this
   constructor. Previously, due to an implementation mistake, this default
   constructor was missing, and calling ``super().__init__()`` would invoke
   ``object.__init__()``.

The :class:`_orm.DeclarativeBase` subclass may also declare an explicit
``__init__()`` method which will replace the use of the
:paramref:`_orm.registry.constructor` function at this level::

    class Base(DeclarativeBase):
        def __init__(self, id=None):
            self.id = id

Mapped classes still will not invoke this constructor implicitly; it
remains only accessible by calling ``super().__init__()``::

    class MyClass(Base):
        def __init__(self, id=None, name=None):
            self.name = name
            super().__init__(id=id)

Note that this is a different behavior from what functions like the legacy
:func:`_orm.declarative_base` would do; the base created by those functions
would always install :paramref:`_orm.registry.constructor` for
``__init__()``.


c                    g r   rn   r   s    r[   _sa_inspect_type DeclarativeBase._sa_inspect_type      Cr]   c                    g r   rn   r   s    r[   _sa_inspect_instance$DeclarativeBase._sa_inspect_instance      sr]   ClassVar[_RegistryType]r   r   ClassVar[MetaData]r   zClassVar[str]rr   ClassVar[Mapper[Any]]rc   zClassVar[FromClause]rV   r   __tablename____mapper_args____table_args__c                    g r   rn   r   s     r[   r   DeclarativeBase.__init__C      sr]   c                   > [         U R                  ;   a  [        U [         5        [        U 5        O [	        U R
                  X R                  5        [        TU ]   " S0 UD6  g r   )	r.  	__bases___check_not_declarativer
  r'   r   rd   r  r  rY   r   r&  s     r[   r  !DeclarativeBase.__init_subclass__E  sE    cmm+"38#C(C,,c<<@!'B'r]   rn   rp   zMapper[Self]rp   zInstanceState[Self]r  r   r   rp   rq   )rr   rs   rt   ru   r{   r?   r   r0  r4  r   r   r  rv   r*  r+  s   @r[   r.  r.  y  s    
n` 7B--))	< %$	  
 *)	 ('	 	 	 		 	+( (r]   r.  c                
   U R                   nSU;   a'  [        US   5      (       d  [        US   S5      (       a%  [        UR	                  SS 5      [
        5      (       a%  [        R                  " SUR                  < S35      eg )NrV   r   r:  zCannot use zR directly as a declarative base class. Create a Base by creating a subclass of it.)	rd   callabler  r   r   ro   r5   r   rr   )rY   basecls_dicts      r[   rB  rB  N  s}    ||HxXk*++x,i88	HLL$7	=	=%%$--* +A A
 	
 
>r]   c                     ^  \ rS rSr% SrS\S'   S\S'    S\S'    S\S	'    S
\S'    \R                  (       a!  SS jrSS jr	S\S'    S\S'    S\S'    SS jr
SU 4S jjrSrU =r$ )DeclarativeBaseNoMetai]  zSame as :class:`_orm.DeclarativeBase`, but does not use a metaclass
to intercept new attributes.

The :class:`_orm.DeclarativeBaseNoMeta` base may be used when use of
custom metaclasses is desirable.

.. versionadded:: 2.0


r7  r   r   r8  r   r9  rc   Optional[FromClause]rV   c                    g r   rn   r   s    r[   r0  &DeclarativeBaseNoMeta._sa_inspect_type  r2  r]   c                    g r   rn   r   s    r[   r4  *DeclarativeBaseNoMeta._sa_inspect_instance  r6  r]   r   r:  r;  r<  c                    g r   rn   r   s     r[   r   DeclarativeBaseNoMeta.__init__  r?  r]   c                   > [         U R                  ;   a  [        U [         5        [        U 5        O [	        U R
                  X R                  5        [        TU ]   " S0 UD6  g r   )	rM  rA  rB  r
  r'   r   rd   r  r  rC  s     r[   r  'DeclarativeBaseNoMeta.__init_subclass__  sF     CMM1"3(=>#C(C,,c<<@!'B'r]   rn   rE  rF  r  rG  )rr   rs   rt   ru   r{   r   r?   r   r0  r4  r   r  rv   r*  r+  s   @r[   rM  rM  ]  s    	 *)%%8 !  &% $# 7B	 	 		 	+( (r]   rM  c                    [        XU5        g)a  Add a new mapped attribute to an ORM mapped class.

E.g.::

    add_mapped_attribute(User, "addresses", relationship(Address))

This may be used for ORM mappings that aren't using a declarative
metaclass that intercepts attribute set operations.

.. versionadded:: 2.0


Nr%   )targetrg   attrs      r[   add_mapped_attributerZ    s      6%r]   Baser   mapperrY   r   class_registryr  r	  r,  c                :    [        U UUUS9R                  UUUUS9$ )a  Construct a base class for declarative class definitions.

The new base class will be given a metaclass that produces
appropriate :class:`~sqlalchemy.schema.Table` objects and makes
the appropriate :class:`_orm.Mapper` calls based on the
information provided declaratively in the class and any subclasses
of the class.

.. versionchanged:: 2.0 Note that the :func:`_orm.declarative_base`
   function is superseded by the new :class:`_orm.DeclarativeBase` class,
   which generates a new "base" class using subclassing, rather than
   return value of a function.  This allows an approach that is compatible
   with :pep:`484` typing tools.

The :func:`_orm.declarative_base` function is a shorthand version
of using the :meth:`_orm.registry.generate_base`
method.  That is, the following::

    from sqlalchemy.orm import declarative_base

    Base = declarative_base()

Is equivalent to::

    from sqlalchemy.orm import registry

    mapper_registry = registry()
    Base = mapper_registry.generate_base()

See the docstring for :class:`_orm.registry`
and :meth:`_orm.registry.generate_base`
for more details.

.. versionchanged:: 1.4  The :func:`_orm.declarative_base`
   function is now a specialization of the more generic
   :class:`_orm.registry` class.  The function also moves to the
   ``sqlalchemy.orm`` package from the ``declarative.ext`` package.


:param metadata:
  An optional :class:`~sqlalchemy.schema.MetaData` instance.  All
  :class:`~sqlalchemy.schema.Table` objects implicitly declared by
  subclasses of the base will share this MetaData.  A MetaData instance
  will be created if none is provided.  The
  :class:`~sqlalchemy.schema.MetaData` instance will be available via the
  ``metadata`` attribute of the generated declarative base class.

:param mapper:
  An optional callable, defaults to :class:`_orm.Mapper`. Will
  be used to map subclasses to their Tables.

:param cls:
  Defaults to :class:`object`. A type to use as the base for the generated
  declarative base class. May be a class or tuple of classes.

:param name:
  Defaults to ``Base``.  The display name for the generated
  class.  Customizing this is not required, but can improve clarity in
  tracebacks and debugging.

:param constructor:
  Specify the implementation for the ``__init__`` function on a mapped
  class that has no ``__init__`` of its own.  Defaults to an
  implementation that assigns \**kwargs for declared
  fields and relationships to an instance.  If ``None`` is supplied,
  no __init__ will be provided and construction will fall back to
  cls.__init__ by way of the normal Python semantics.

:param class_registry: optional dictionary that will serve as the
  registry of class names-> mapped classes when string names
  are used to identify classes inside of :func:`_orm.relationship`
  and others.  Allows two or more declarative base classes
  to share the same registry of class names for simplified
  inter-base relationships.

:param type_annotation_map: optional dictionary of Python types to
    SQLAlchemy :class:`_types.TypeEngine` classes or instances.  This
    is used exclusively by the :class:`_orm.MappedColumn` construct
    to produce column types based on annotations within the
    :class:`_orm.Mapped` type.


    .. versionadded:: 2.0

    .. seealso::

        :ref:`orm_declarative_mapped_column_type_map`

:param metaclass:
  Defaults to :class:`.DeclarativeMeta`.  A metaclass or __metaclass__
  compatible callable to use as the meta type of the generated
  declarative base class.

.. seealso::

    :class:`_orm.registry`

)r   r^  r	  r  )r]  rY   r   r,  )r   generate_baser\  s           r[   declarative_basera    s;    \ %/	
 m	  
r]   c                  f   \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S\S'   S\S'   S\S'   S\S'   S\S'   SSS\S.       S2S jjr    S3S jr S4     S5S jjr	\
S6S j5       rS7S jrS8S jr\    S9S j5       r\    S9S j5       rS:S jrS;S jrS<S  jrS=S! jrS>S?S" jjrS>S?S# jjrS=S$ jrS\S%\4         S@S& jjr\R8                  " \\\\ \!\"\#\$\%4	S'9\&SAS( j5       5       r'\& SBS)S)S)S)S)S)S)S)S*.                   SCS+ jjj5       r' SD\(RR                  \(RR                  \(RR                  \(RR                  \(RR                  \(RR                  \(RR                  \(RR                  S*.                   SES, jjjr'SFS- jr*SGS. jr+SHS/ jr, SD       SIS0 jjr-S1r.g)Jr   iV  a\  Generalized registry for mapping classes.

The :class:`_orm.registry` serves as the basis for maintaining a collection
of mappings, and provides configurational hooks used to map classes.

The three general kinds of mappings supported are Declarative Base,
Declarative Decorator, and Imperative Mapping.   All of these mapping
styles may be used interchangeably:

* :meth:`_orm.registry.generate_base` returns a new declarative base
  class, and is the underlying implementation of the
  :func:`_orm.declarative_base` function.

* :meth:`_orm.registry.mapped` provides a class decorator that will
  apply declarative mapping to a class without the use of a declarative
  base class.

* :meth:`_orm.registry.map_imperatively` will produce a
  :class:`_orm.Mapper` for a class without scanning the class for
  declarative class attributes. This method suits the use case historically
  provided by the ``sqlalchemy.orm.mapper()`` classical mapping function,
  which is removed as of SQLAlchemy 2.0.

.. versionadded:: 1.4

.. seealso::

    :ref:`orm_mapping_classes_toplevel` - overview of class mapping
    styles.

zclsregistry._ClsRegistryType_class_registryz;weakref.WeakKeyDictionary[ClassManager[Any], Literal[True]]	_managersz5weakref.WeakKeyDictionary[Mapper[Any], Literal[True]]_non_primary_mappersr;   r   z&CallableReference[Callable[..., None]]r	  _MutableTypeAnnotationMapTyper  zSet[_RegistryType]_dependents_dependenciesr   _new_mappersN)r   r^  r  r	  c                  U=(       d
    [        5       nUc  [        R                  " 5       nX l        [        R                  " 5       U l        [        R                  " 5       U l        XPl        X@l        0 U l	        Ub  U R                  U5        [        5       U l        [        5       U l        SU l        [        R                      S[        R"                  U '   SSS5        g! , (       d  f       g= f)a  Construct a new :class:`_orm.registry`

:param metadata:
  An optional :class:`_schema.MetaData` instance.  All
  :class:`_schema.Table` objects generated using declarative
  table mapping will make use of this :class:`_schema.MetaData`
  collection.  If this argument is left at its default of ``None``,
  a blank :class:`_schema.MetaData` collection is created.

:param constructor:
  Specify the implementation for the ``__init__`` function on a mapped
  class that has no ``__init__`` of its own.  Defaults to an
  implementation that assigns \**kwargs for declared
  fields and relationships to an instance.  If ``None`` is supplied,
  no __init__ will be provided and construction will fall back to
  cls.__init__ by way of the normal Python semantics.

:param class_registry: optional dictionary that will serve as the
  registry of class names-> mapped classes when string names
  are used to identify classes inside of :func:`_orm.relationship`
  and others.  Allows two or more declarative base classes
  to share the same registry of class names for simplified
  inter-base relationships.

:param type_annotation_map: optional dictionary of Python types to
  SQLAlchemy :class:`_types.TypeEngine` classes or instances.
  The provided dict will update the default type mapping.  This
  is used exclusively by the :class:`_orm.MappedColumn` construct
  to produce column types based on annotations within the
  :class:`_orm.Mapped` type.

  .. versionadded:: 2.0

  .. seealso::

      :ref:`orm_declarative_mapped_column_type_map`


NFT)r;   weakrefWeakValueDictionaryrc  WeakKeyDictionaryrd  re  r   r	  r  update_type_annotation_mapsetrg  rh  ri  r   _CONFIGURE_MUTEX_mapper_registries)r   r   r^  r  r	  lcl_metadatas         r[   r   registry.__init__  s    ^  -8:!$88:N- 224$+$=$=$?!$&#% *++,?@5 U!''15I((. (''s   C
C-c           	         U R                   R                  UR                  5        VVs0 s H  u  p#[        U5      U_M     snn5        gs  snnf )zIupdate the :paramref:`_orm.registry.type_annotation_map` with new
values.N)r  r   r  rB   )r   r  typsqltypes       r[   rn  #registry.update_type_annotation_map  sO     	  '' %8$=$=$?$?LC +3/8$?	
s   A

c                6  ^ [        U5      (       a;  [        U5      (       a  UmUT4/U4S j[         5       Q7nODUR                  mUT44nO2[	        U[
        5      (       a  UmS TR                   5       nOUmUT44nU Hn  u  pEU R                  R                  U5      nUc  [        R                  " U5      nUc  M>  [        R                  " U5      nUR                  TUU5      nUc  Ml  Us  $    U(       a  S n	S n
[        U5      (       a=  Un	[        U	5      (       a  U	R                  n	[        U	5      (       a  M  [        U	5      n	Sn
[!        U5      (       a  [#        U5      n	Sn
U	b/  U R%                  U	S5      nUb  U
c   e['        SU
 SU S3S	5        U$ g )
Nc              3  *   >#    U  H  oT4v   M
     g 7fr   rn   ).0ltpython_type_types     r[   	<genexpr>)registry._resolve_type.<locals>.<genexpr>  s     E}+,}s   c              3  (   #    U  H  oU4v   M
     g 7fr   rn   )rz  pts     r[   r}  r~    s     B)A22h)As   TypeAliasTypeNewTypeFzMatching the provided z 'z' on its resolved value without matching it in the type_annotation_map is deprecated; add this type to the type_annotation_map to allow it to match explicitly.z2.0)rD   rE   rI   
__origin__r   re   rW   r  r   r8   _type_map_getto_instance_resolve_for_python_typerG   	__value__rB   rF   rC   _resolve_typer@   )r   python_type_do_fallbackssearchr  	flattenedsql_typesql_type_instresolved_sql_typepython_type_to_checkkindres_after_fallbackr|  s               @r[   r  registry._resolve_type  s    k""+&&#.  !"23E}E
 $/#9#9 &(89;T***B)9)A)ABF*"$457F#MB//33B7H#11"5# ( 4 4X > %2$J$J$%!
 %0,,) $. (, D%%'2$ 455+?+I+I(   455'A(($ '+&&'6{'C$ #/%)%7%7(%&" &1+++#0b F& &
  .-r]   c                l    [        S U R                   5       5      R                  U R                  5      $ )z9read only collection of all :class:`_orm.Mapper` objects.c              3  8   #    U  H  oR                   v   M     g 7fr   )r]  rz  r   s     r[   r}  #registry.mappers.<locals>.<genexpr>(  s     F~G~s   )	frozensetrd  unionre  r   s    r[   mappersregistry.mappers$  s/     Ft~~FFLL%%
 	
r]   c                z    XL a  g UR                   R                  U 5        U R                  R                  U5        g r   )rg  addrh  )r   r   s     r[   _set_depends_onregistry._set_depends_on,  s3      &x(r]   c                v    SUl         U R                  (       a  g U R                  U 15       H
  nSUl        M     g NT)_ready_for_configureri  _recurse_with_dependents)r   r]  r   s      r[   _flag_new_mapperregistry._flag_new_mapper2  s5    &*#00$8C#C 9r]   c              #  8  #    Un[        5       nU(       a  UR                  5       nUR                  U5        UR                  UR                  R                  U5      5        Uv   UR                  UR                  R                  U5      5        U(       a  M  g g 7fr   )ro  popr  r   rg  
differencerY   
registriestododoner   s        r[   r  !registry._recurse_with_dependents:  sr      u((*CHHSM KK22489I KK22489 d   BBBc              #  8  #    Un[        5       nU(       a  UR                  5       nUR                  U5        UR                  UR                  R                  U5      5        Uv   UR                  UR                  R                  U5      5        U(       a  M  g g 7fr   )ro  r  r  r   rh  r  r  s        r[   _recurse_with_dependencies#registry._recurse_with_dependenciesM  sv      u((*CHHSM KK))44T:;I KK))44T:; dr  c                    [         R                  " S [        U R                  5       5       S [        U R                  5       5       5      $ )Nc              3     #    U  H^  nUR                   (       d  M  UR                  R                  (       a  M3  UR                  R                  (       d  MP  UR                  v   M`     g 7fr   )r   r]  
configuredr  r  s     r[   r}  1registry._mappers_to_configure.<locals>.<genexpr>c  sN      3G$$   11  NN77	 3s   A(A(A(A(c              3  r   #    U  H-  nUR                   (       a  M  UR                  (       d  M)  Uv   M/     g 7fr   )r  r  )rz  npms     r[   r}  r  j  s.      :C~~ *-*B*B :s   77	7)	itertoolschainlistrd  re  r   s    r[   _mappers_to_configureregistry._mappers_to_configurea  sA    #DNN3 9 9:
 	
r]   c                "    SU R                   U'   g r  )re  )r   	np_mappers     r[   _add_non_primary_mapper registry._add_non_primary_mapperq  s    /3!!),r]   c                Z    [         R                  " UR                  XR                  5        g r   )r   remove_classrr   rc  r   rY   s     r[   _dispose_clsregistry._dispose_clst  s      s4H4HIr]   c                    SU R                   U'   UR                  (       a#  [        R                  " SUR                  -  5      eUR
                  b   eXl        g )NTz1Class '%s' already has a primary mapper defined. )rd  r   r5   ArgumentErrorrZ   r   )r   r   s     r[   _add_managerregistry._add_managerw  sU    "&w##C..!  '''r]   c                0    [         R                  " U 1US9  g)au  Configure all as-yet unconfigured mappers in this
:class:`_orm.registry`.

The configure step is used to reconcile and initialize the
:func:`_orm.relationship` linkages between mapped classes, as well as
to invoke configuration events such as the
:meth:`_orm.MapperEvents.before_configured` and
:meth:`_orm.MapperEvents.after_configured`, which may be used by ORM
extensions or user-defined extension hooks.

If one or more mappers in this registry contain
:func:`_orm.relationship` constructs that refer to mapped classes in
other registries, this registry is said to be *dependent* on those
registries. In order to configure those dependent registries
automatically, the :paramref:`_orm.registry.configure.cascade` flag
should be set to ``True``. Otherwise, if they are not configured, an
exception will be raised.  The rationale behind this behavior is to
allow an application to programmatically invoke configuration of
registries while controlling whether or not the process implicitly
reaches other registries.

As an alternative to invoking :meth:`_orm.registry.configure`, the ORM
function :func:`_orm.configure_mappers` function may be used to ensure
configuration is complete for all :class:`_orm.registry` objects in
memory. This is generally simpler to use and also predates the usage of
:class:`_orm.registry` objects overall. However, this function will
impact all mappings throughout the running Python process and may be
more memory/time consuming for an application that has many registries
in use for different purposes that may not be needed immediately.

.. seealso::

    :func:`_orm.configure_mappers`


.. versionadded:: 1.4.0b2

cascadeN)r   _configure_registriesr   r  s     r[   	configureregistry.configure  s    N 	''@r]   c                0    [         R                  " U 1US9  g)a6  Dispose of all mappers in this :class:`_orm.registry`.

After invocation, all the classes that were mapped within this registry
will no longer have class instrumentation associated with them. This
method is the per-:class:`_orm.registry` analogue to the
application-wide :func:`_orm.clear_mappers` function.

If this registry contains mappers that are dependencies of other
registries, typically via :func:`_orm.relationship` links, then those
registries must be disposed as well. When such registries exist in
relation to this one, their :meth:`_orm.registry.dispose` method will
also be called, if the :paramref:`_orm.registry.dispose.cascade` flag
is set to ``True``; otherwise, an error is raised if those registries
were not already disposed.

.. versionadded:: 1.4.0b2

.. seealso::

    :func:`_orm.clear_mappers`

r  N)r   _dispose_registriesr  s     r[   disposeregistry.dispose  s    0 	%%tfg>r]   c                    SUR                   ;   a  UR                  nUR                  5         UR                  nU R	                  U5        [
        R                  R                  U5        g )Nr]  )rd   r]  _set_dispose_flagsrZ   r  r   _instrumentation_factory
unregister)r   r   r]  rZ   s       r[   _dispose_manager_and_mapper$registry._dispose_manager_and_mapper  sP    w'''^^F%%'&!00;;FCr]   r[  c                b   U R                   n[        U[        5      (       + =(       a    U4=(       d    Un[        XS9n[        U[        5      (       a  UR
                  US'   U R                  b  U R                  US'   SUS'   U(       a  XS'   [        US5      (       a	  S	S jnXS'   U" X6U5      $ )
aO  Generate a declarative base class.

Classes that inherit from the returned class object will be
automatically mapped using declarative mapping.

E.g.::

    from sqlalchemy.orm import registry

    mapper_registry = registry()

    Base = mapper_registry.generate_base()


    class MyClass(Base):
        __tablename__ = "my_table"
        id = Column(Integer, primary_key=True)

The above dynamically generated class is equivalent to the
non-dynamic example below::

    from sqlalchemy.orm import registry
    from sqlalchemy.orm.decl_api import DeclarativeMeta

    mapper_registry = registry()


    class Base(metaclass=DeclarativeMeta):
        __abstract__ = True
        registry = mapper_registry
        metadata = mapper_registry.metadata

        __init__ = mapper_registry.constructor

.. versionchanged:: 2.0 Note that the
   :meth:`_orm.registry.generate_base` method is superseded by the new
   :class:`_orm.DeclarativeBase` class, which generates a new "base"
   class using subclassing, rather than return value of a function.
   This allows an approach that is compatible with :pep:`484` typing
   tools.

The :meth:`_orm.registry.generate_base` method provides the
implementation for the :func:`_orm.declarative_base` function, which
creates the :class:`_orm.registry` and base class all at once.

See the section :ref:`orm_declarative_mapping` for background and
examples.

:param mapper:
  An optional callable, defaults to :class:`_orm.Mapper`.
  This function is used to generate new :class:`_orm.Mapper` objects.

:param cls:
  Defaults to :class:`object`. A type to use as the base for the
  generated declarative base class. May be a class or tuple of classes.

:param name:
  Defaults to ``Base``.  The display name for the generated
  class.  Customizing this is not required, but can improve clarity in
  tracebacks and debugging.

:param metaclass:
  Defaults to :class:`.DeclarativeMeta`.  A metaclass or __metaclass__
  compatible callable to use as the meta type of the generated
  declarative base class.

.. seealso::

    :ref:`orm_declarative_mapping`

    :func:`_orm.declarative_base`

)r   r   r{   r   Tr   __mapper_cls____class_getitem__c                    U $ r   rn   rl   s     r[   r  1registry.generate_base.<locals>.__class_getitem__/  s    
r]   )rY   Type[_T]rg   r   rp   r  )r   r   tupledictre   r{   r	  r  )	r   r]  rY   r   r,  r   r   
class_dictr  s	            r[   r`  registry.generate_base  s    ` ==sE**5v<%)4%K
c4  $'KKJy!'%)%5%5Jz"%)
>"+1'(3+,, /@*+j11r]   r|   c                    g r   rn   )r   _registry__clss     r[   mapped_as_dataclassregistry.mapped_as_dataclass7  s	     ADr]   .r  c                   g r   rn   )
r   r  r  r  r  r  r  r  r  r  s
             r[   r  r  G  s     *-r]   c          
     V   ^ ^^^^^^^^	 SU	UUUUUUU U4	S jjn
U(       a  U
" U5      $ U
$ )a'  Class decorator that will apply the Declarative mapping process
to a given class, and additionally convert the class to be a
Python dataclass.

.. seealso::

    :ref:`orm_declarative_native_dataclasses` - complete background
    on SQLAlchemy native dataclass mapping


.. versionadded:: 2.0


c                `   >	 [        U STTTTT	TTTS.5        [        TX R                  5        U $ )Nr  r  )setattrr'   rd   )
rY   r  r  r  r  r  r  r  r   r  s
    r[   r   .registry.mapped_as_dataclass.<locals>.decoratet  sC    )  "#.",&*<	 D#||4Jr]   rY   Type[_O]rp   r  rn   )r   r  r  r  r  r  r  r  r  r  r   s   ` ```````` r[   r  r  V  s"    <	 	$ E?"Or]   c                2    [        XUR                  5        U$ )a  Class decorator that will apply the Declarative mapping process
to a given class.

E.g.::

    from sqlalchemy.orm import registry

    mapper_registry = registry()


    @mapper_registry.mapped
    class Foo:
        __tablename__ = "some_table"

        id = Column(Integer, primary_key=True)
        name = Column(String)

See the section :ref:`orm_declarative_mapping` for complete
details and examples.

:param cls: class to be mapped.

:return: the class that was passed.

.. seealso::

    :ref:`orm_declarative_mapping`

    :meth:`_orm.registry.generate_base` - generates a base class
    that will apply Declarative mapping to subclasses automatically
    using a Python metaclass.

.. seealso::

    :meth:`_orm.registry.mapped_as_dataclass`

)r'   rd   r  s     r[   mappedregistry.mapped  s    L 	3<<0
r]   c                   ^ ^ SUU 4S jjnU$ )a(  
Class decorator which will invoke
:meth:`_orm.registry.generate_base`
for a given base class.

E.g.::

    from sqlalchemy.orm import registry

    mapper_registry = registry()


    @mapper_registry.as_declarative_base()
    class Base:
        @declared_attr
        def __tablename__(cls):
            return cls.__name__.lower()

        id = Column(Integer, primary_key=True)


    class MyMappedClass(Base): ...

All keyword arguments passed to
:meth:`_orm.registry.as_declarative_base` are passed
along to :meth:`_orm.registry.generate_base`.

c                P   > U TS'   U R                   TS'   TR                  " S0 TD6$ )NrY   r   rn   )rr   r`  )rY   r   r   s    r[   r   .registry.as_declarative_base.<locals>.decorate  s-    BuIBvJ%%+++r]   rY   r  rp   r  rn   )r   r   r   s   `` r[   as_declarative_baseregistry.as_declarative_base  s    <	, 	,
 r]   c                F    [        XUR                  5        UR                  $ )a  Map a class declaratively.

In this form of mapping, the class is scanned for mapping information,
including for columns to be associated with a table, and/or an
actual table object.

Returns the :class:`_orm.Mapper` object.

E.g.::

    from sqlalchemy.orm import registry

    mapper_registry = registry()


    class Foo:
        __tablename__ = "some_table"

        id = Column(Integer, primary_key=True)
        name = Column(String)


    mapper = mapper_registry.map_declaratively(Foo)

This function is more conveniently invoked indirectly via either the
:meth:`_orm.registry.mapped` class decorator or by subclassing a
declarative metaclass generated from
:meth:`_orm.registry.generate_base`.

See the section :ref:`orm_declarative_mapping` for complete
details and examples.

:param cls: class to be mapped.

:return: a :class:`_orm.Mapper` object.

.. seealso::

    :ref:`orm_declarative_mapping`

    :meth:`_orm.registry.mapped` - more common decorator interface
    to this function.

    :meth:`_orm.registry.map_imperatively`

)r'   rd   rc   r  s     r[   map_declarativelyregistry.map_declaratively  s    ^ 	3<<0~~r]   c                    [        XX#5      $ )a  Map a class imperatively.

In this form of mapping, the class is not scanned for any mapping
information.  Instead, all mapping constructs are passed as
arguments.

This method is intended to be fully equivalent to the now-removed
SQLAlchemy ``mapper()`` function, except that it's in terms of
a particular registry.

E.g.::

    from sqlalchemy.orm import registry

    mapper_registry = registry()

    my_table = Table(
        "my_table",
        mapper_registry.metadata,
        Column("id", Integer, primary_key=True),
    )


    class MyClass:
        pass


    mapper_registry.map_imperatively(MyClass, my_table)

See the section :ref:`orm_imperative_mapping` for complete background
and usage examples.

:param class\_: The class to be mapped.  Corresponds to the
 :paramref:`_orm.Mapper.class_` parameter.

:param local_table: the :class:`_schema.Table` or other
 :class:`_sql.FromClause` object that is the subject of the mapping.
 Corresponds to the
 :paramref:`_orm.Mapper.local_table` parameter.

:param \**kw: all other keyword arguments are passed to the
 :class:`_orm.Mapper` constructor directly.

.. seealso::

    :ref:`orm_imperative_mapping`

    :ref:`orm_declarative_mapping`

r,   )r   rZ   local_tabler   s       r[   map_imperativelyregistry.map_imperatively  s    p t[55r]   )	rc  rh  rg  rd  ri  re  r	  r   r  )r   Optional[MetaData]r^  &Optional[clsregistry._ClsRegistryType]r   Optional[_TypeAnnotationMapType]r	  Callable[..., None])r  _TypeAnnotationMapTyperp   rq   )T)r  rQ   r  r   rp   z"Optional[sqltypes.TypeEngine[Any]])rp   zFrozenSet[Mapper[Any]])r   r   rp   rq   )r]  Mapper[Any]rp   rq   )r  zSet[RegistryType]rp   zIterator[RegistryType])rp   zIterator[Mapper[Any]])r  r  rp   rq   )rY   r  rp   rq   )r   zClassManager[Any]rp   rq   r   )r  r   rp   rq   )
r]  $Optional[Callable[..., Mapper[Any]]]rY   	Type[Any]r   ro   r,  r  rp   r   )r  r  rp   r  ).)r  zLiteral[None]r  r(  r  r(  r  r(  r  r(  r  r(  r  r(  r  r(  r  r)  rp   zCallable[[Type[_O]], Type[_O]]r   )r  zOptional[Type[_O]]r  r(  r  r(  r  r(  r  r(  r  r(  r  r(  r  r(  r  r)  rp   z/Union[Type[_O], Callable[[Type[_O]], Type[_O]]]r  r   r   rp   zCallable[[Type[_T]], Type[_T]])rY   r  rp   
Mapper[_O])rZ   r  r  rN  r   r   rp   r	  )/rr   rs   rt   ru   r{   r   r)   r   rn  r  propertyr  r  r  r   r  r  r  r  r  r  r  r  r  r   r   r`  compat_typingdataclass_transformr1   r2   r.   r/   r   r   r   r   r   r   r  r9   r  r  r  r  r  rv   rn   r]   r[   r   r   V  sn   @ 21JJOO7766##%%
 (,AE@D+CB6 %B6 ?	B6
 >B6 )B6H
3
 

 BFO)O:>O	+Ob 
 
)$ :*:	: :$ <*<	< <&
 4J 'AR?4D 8<.g24g2 g2 	g2
 g2 
g2R && 

 C  D  #- %($'"%%(+.*-'*FI-- "	-
 "-  - #- )- (- %- D- 
(- -  %)3 %+MM$*MM"(--%+]]+1==*0--'-}} MM3!3 "	3
 "3  3 #3 )3 (3 %3
3 
93j'R#J0j -18686 *86 	86
 
86 86r]   r   c                 z    U R                  SS5      U R                  SS5      p![        XS9R                  " S0 U D6$ )aS  
Class decorator which will adapt a given class into a
:func:`_orm.declarative_base`.

This function makes use of the :meth:`_orm.registry.as_declarative_base`
method, by first creating a :class:`_orm.registry` automatically
and then invoking the decorator.

E.g.::

    from sqlalchemy.orm import as_declarative


    @as_declarative()
    class Base:
        @declared_attr
        def __tablename__(cls):
            return cls.__name__.lower()

        id = Column(Integer, primary_key=True)


    class MyMappedClass(Base): ...

.. seealso::

    :meth:`_orm.registry.as_declarative_base`

r   Nr^  )r   r^  rn   )r  r   r  )r   r   r^  s      r[   as_declarativer  M  sP    > 	z4 
& 
      r]   c                    [        U 5      nUc1  [        R                  " U 5      (       a  [        R                  " U 5        U$ r   )r!   r*   has_clsraise_unmapped_for_cls)rY   mps     r[   _inspect_decl_metar  u  s7     !6c :B	z ((--!88=Ir]   )rY   r  rp   r   r   )r   ro   r   r   rp   z,Callable[[Callable[..., Any]], Synonym[Any]]r  )rY   r  rp   rq   )rY   r  rJ  r  rp   rq   )rX  r  rg   ro   rY  zMapperProperty[Any]rp   rq   )r   r   r]  r  rY   r  r   ro   r^  r  r  r  r	  r  r,  r  rp   r   r  )rY   r  rp   zOptional[Mapper[Any]])r{   
__future__r   r  r   r?   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   rk   r   r   r   r   r   _orm_constructorsr   r   r   r   r   r    rJ  r!   r"   r#   r$   	decl_baser&   r'   r(   r)   r*   r+   r-   descriptor_propsr.   r/   r   r]  r0   
propertiesr1   relationshipsr2   stater3   r5   r6   r7   sqlr8   sql.baser9   sql.elementsr:   
sql.schemar;   sql.selectabler<   r=   r>   r  r@   util.typingrA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   _typingrK   rL   rM   rN   rO   sql._typingrP   sql.type_apirQ   rR   rT   r  rf  _DeclaredAttrDecoratedr\   re   r_   Inspectablerx   r  r   r   r   r   r   _MappedAttributer   r   r  r
  r  r.  rB  rM  rZ  r   ra  r   r   r  	_inspectsr  rn   r]   r[   <module>r)     s   8 "  	                          ( ' , + & - ' "   % & - / , %  ' % 5  $ /        , ! '  ! * " + 4 ) $ $ $ # ! ' &.-*$1-Te3 !&@!@A  $S*D%D E !vbz=,.?.CC	DD 
&'T '	6#;'	 ""
8: 8843 4> #('
''1'T> >B/ ,E-J//35J E-P,mB/ , )X&0R>"8 >BR(=-.+R(j
h(=-.h(V&&&&9&	&* $(37=A<@'?*x x 1x 
	x
 x ;x :x %x x 	xvm6 m6` M% P _&Cr]   