Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
decl_api.cpython-313.pyc1020 linesDownload Raw Back to __pycache__
1�

2��j���*�SrSSKJr SSKrSSKrSSKrSSKJr SSKJr SSKJr SSKJ	r	 SSKJ3r4 SS	KJr SS5KJr SSKJ
r
 SSKJr SS
KJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKrSSKJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJ r  SSKJ!r! SSKJ"r" SSKJ#r# SS KJ$r$ SS!K%J&r& SS"K%J'r' SS#K%J(r( SS$K%J)r) SS%K*J+r+ SS&K*J,r, SS'K*J-r- SS(K*J.r. SS)K*J/r/ SS*K*J0r0 SS+K*J1r1 SS,K2J3r3 SS-K2J4r4 SS-K2J4r5 SS.K6J7r7 SS/K8J9r9 SS0K:J;r; SS1K<J=r= S2S3KJ>r> S2S4KJ?r? S2S5KJ@r@ S2S6KAJBrB S2S7KCJDrD S2S8KEJFrF S2S9KGJHrH S2S:KIJJrJ S2S;K@JKrK S2S<K@JLrL S2S=K@JrM S2S>K@JNrN S2S?KOJPrP S2S@KOJQrQ S2SAKOJRrR S2SBKOJSrS S2SCKOJTrT S2SDKOJUrU S2SEKOJVrV S2SFKOJWrW S2SGKOJXrX S2SHKOJYrY S2SIKOJZrZ \(a0SSJK[J\r\ SSKK[J]r] SSLK*J^r^ SSMKJ_r_ SSNKJ`r` SS1K<J=r= S2SOKaJbrb S2SPKcJdrd \"SQ\SR9re\"SS\SR9rf\\ST4rg\	\ST4rh\SU\\(\e\)\e\F\e44riS}SVjrj"SWSX\k5rl"SYSZ\l\?R�\7\5rn\MR�"\9\;\3\4\!\"\\#\ 4	S[9"S\S]\n55rp"S^S_\n5rqS~SS`jjrr"SaSb5rs"ScSd\s\\e5rt"SeSf\R�\e\s5rv"SgSh\v\e5rwS�SijrxS�Sjjry"SkSl\pSm9rz"SnSo\?R�\=\\nSm9r{S�Spjr|"SqSr\?R�\=\5r}S�Ssjr~SS\StSS\.\qSu.S�Svjjr�"SwSx5r�\�r�\(d\�r]S�Syjr�\MR�"\9\;\3\4\!\"\\#\ 4	S[9\DGR\DGR\DGR\DGR\DGR\DGR\DGR\DGRSz.S�S{jj5r�\?GR"\q\{\n5S�S|j5r�g)�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�)�6attributes)�clsregistry)�instrumentation)�7interfaces)�	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)�8inspection)�util)�sqltypes)�_NoArg)�SQLCoreOperations)�MetaData)�9FromClause)�hybridmethod)�hybridproperty)�typing)�warn_deprecated)�CallableReference)�de_optionalize_union_types)�flatten_newtype)�10is_generic)�11is_literal)�12is_newtype)�	is_pep593)�	is_pep695)�Literal)�
LITERAL_TYPES)�Self)�_O)�
_RegistryType)�_DataclassArguments)�ClassManager)�MapperProperty)�_TypeEngineArgument)�_MatchedOnType�_T)�bound�_TTz_TypeEngineArgument[Any].c�P�URSSHn[USS5cM g g)a/Given a class, return True if any of the classes it inherits from has a13mapped table, otherwise return False.14 15This is used in declarative mixins to build attributes that behave16differently for the base class vs. a subclass in an inheritance17hierarchy.18 19.. seealso::20 21    :ref:`decl_mixin_inheritance`22 23rN�	__table__TF)�__mro__�getattr)�cls�class_s  �]D:\code\apps\devtools\python\user_packages\Python313\site-packages\sqlalchemy/orm/decl_api.py�has_inherited_tabler]os/���+�+�a�b�/���6�;��-�9��"��c�(�\rSrSrSSjrSSjrSrg)�_DynamicAttributesType�c�j�SUR;a
[XU5 g[RXU5 g�N�24__mapper__)�__dict__r&�type�__setattr__)rZ�key�values   r\rg�"_DynamicAttributesType.__setattr__�s(���3�<�<�'��3�U�+����S�u�-r^c�f�SUR;a[X5 g[RX5 grc)rer+rf�__delattr__�rZrhs  r\rl�"_DynamicAttributesType.__delattr__�s$���3�<�<�'��3�$����S�&r^�N)rh�strrir�return�None)rhrprqrr)�__name__�25__module__�__qualname__�__firstlineno__rgrl�__static_attributes__ror^r\r`r`�s��.�'r^r`c��\rSrSrSrSrg)�DeclarativeAttributeIntercept�z�Metaclass that may be used in conjunction with the26:class:`_orm.DeclarativeBase` class to support addition of class27attributes dynamically.28 29roN�rsrtrurv�__doc__rwror^r\ryry�s��30r^ry��field_specifiersc��\rSrSrSrSrg)�DCTransformDeclarative�z-metaclass that includes @dataclass_transformsroNr{ror^r\r�r��s��8r^r�c�H�\rSrSr%S\S'S\S'S	SjrSrg)31�DeclarativeMeta�r;�metadata�RegistryType�registryc�H�URn[USS5nUcCURSS5n[U[5(d[32R"S5eXPlURRSS5(d[XPU5 [RXX#5 g)N�_sa_registryr�ziDeclarative base class has no 'registry' attribute, or registry is not a sqlalchemy.orm.registry() object�__abstract__F)rerY�get�33isinstancer�r5�InvalidRequestErrorr�r'rf�__init__)rZ�	classname�bases�dict_�kw�regs      r\r��DeclarativeMeta.__init__�s���34����35�c�>�4�0���;��)�)�J��-�C��c�8�,�,��-�-�L���36$'� ��|�|�����6�6��C�e�,��
�
�c�e�3r^roN)37r�rr�rr�rr�rrqrr)rsrtrurv�__annotations__r�rwror^r\r�r��s;������4��4�$'�4�03�4�;>�4�	
�4r^r�c�^^�SUU4SjjnU$)a�Decorator that produces an :func:`_orm.synonym`38attribute in conjunction with a Python descriptor.39 40The function being decorated is passed to :func:`_orm.synonym` as the41:paramref:`.orm.synonym.descriptor` parameter::42 43    class MyClass(Base):44        __tablename__ = "my_table"45 46        id = Column(Integer, primary_key=True)47        _job_status = Column("job_status", String(50))48 49        @synonym_for("job_status")50        @property51        def job_status(self):52            return "Status: %s" % self._job_status53 54The :ref:`hybrid properties <mapper_hybrids>` feature of SQLAlchemy55is typically preferred instead of synonyms, which is a more legacy56feature.57 58.. seealso::59 60    :ref:`synonyms` - Overview of synonyms61 62    :func:`_orm.synonym` - the mapper-level function63 64    :ref:`mapper_hybrids` - The Hybrid Attribute extension provides an65    updated approach to augmenting attribute behavior more flexibly than66    can be achieved with synonyms.67 68c�>�[TTUS9$)N)�69map_column�70descriptor)�_orm_synonym)�fnr��names ��r\�decorate�synonym_for.<locals>.decorate�s����D�Z�B�G�Gr^)r��Callable[..., Any]rqzSynonym[Any]ro)r�r�r�s`` r\�synonym_forr��s���HH�H��Or^c�D�\rSrSrSSSjjrS	SjrS71SjrSrg)�_declared_attr_common��c��[U[5(aURnXlX lX0lURUlg�N)r��classmethod�__func__�fget�72_cascading�_quietr|)�selfr��	cascading�quiets    r\r��_declared_attr_common.__init__�s4���b�+�&�&����B��	�#�����z�z��r^c�`�[R"UR5RS5$)Nrq)r7�get_annotationsr�r��r�s r\�_collect_return_annotation�0_declared_attr_common._collect_return_annotations"���#�#�D�I�I�.�2�2�8�<�<r^c���Un[R"U5nUc}[R"SURR735(d<[R"SURR74<SUR75<35 UR	U5$UR(aUR	U5$UR5nUceURnX;aX`$UR	U5=X`'nU$)Nz^__.+__$z*Unmanaged access of declarative attribute z from non-mapped class )r�opt_manager_of_class�re�matchr�rsr7�warn�	is_mapped�declarative_scan�declared_attr_reg)r��instance�ownerrZ�managerr�r��objs        r\�__get__�_declared_attr_common.__get__s������1�1�#�6���?��8�8�K����);�);�<�<��	�	�-1�Y�Y�-?�-?����O���9�9�S�>�!�
�
�
��9�9�S�>�!�#�3�3�5�� �+�+�+��0�0���;��9��"�i�i��n�,�C�I���Jr^)r|r�r�r�N)FF)r�r�r��boolr�r�)rqzOptional[Type[Any]])r��Optional[object]r�rrqr)rsrtrurvr�r�r�rwror^r\r�r��s5�� ��	"��"��"��	"�*=�%r^r�c�z�\rSrSr\R76(a"S	S77SjjrSSjrSSjrS
Sjr	SSjr78SrgSrg)�_declared_directivei6c��gr�ro�r�r�r�s   r\r��_declared_directive.__init__;���r^c��gr�ro�r�r�r�s   r\r��_declared_directive.__get__As��r^c��gr�ro�r�r�ris   r\�__set__�_declared_directive.__set__C���cr^c��gr�ro�r�r�s  r\�79__delete__�_declared_directive.__delete__E���Sr^c��gr�ro�r�r�s  r\�__call__�_declared_directive.__call__Gs��r^roN�F)r�zCallable[..., _T]r�r�)r�r�r�rrqrS�r�rrirrqrr�r�rrqrr)r�zCallable[..., _TT]rqz_declared_directive[_TT])rsrtrurvr?rr�r�r�r�r�rwror^r\r�r�6s?�����80$�	�!�	��	�	M�A�8�	�r^r�c���\rSrSrSr\R(a:SSSjjrSSjrSSjr	\81SSj5r\82SSj5rSSjr\SS	j5r
\SS83j5r\SSj5rSrg
)�
declared_attriLa
Mark a class-level method as representing the definition of84a mapped property or Declarative directive.85 86:class:`_orm.declared_attr` is typically applied as a decorator to a class87level method, turning the attribute into a scalar-like property that can be88invoked from the uninstantiated class. The Declarative mapping process89looks for these :class:`_orm.declared_attr` callables as it scans classes,90and assumes any attribute marked with :class:`_orm.declared_attr` will be a91callable that will produce an object specific to the Declarative mapping or92table configuration.93 94:class:`_orm.declared_attr` is usually applicable to95:ref:`mixins <orm_mixins_toplevel>`, to define relationships that are to be96applied to different implementors of the class. It may also be used to97define dynamically generated column expressions and other Declarative98attributes.99 100Example::101 102    class ProvidesUserMixin:103        "A mixin that adds a 'user' relationship to classes."104 105        user_id: Mapped[int] = mapped_column(ForeignKey("user_table.id"))106 107        @declared_attr108        def user(cls) -> Mapped["User"]:109            return relationship("User")110 111When used with Declarative directives such as ``__tablename__``, the112:meth:`_orm.declared_attr.directive` modifier may be used which indicates113to :pep:`484` typing tools that the given method is not dealing with114:class:`_orm.Mapped` attributes::115 116    class CreateTableName:117        @declared_attr.directive118        def __tablename__(cls) -> str:119            return cls.__name__.lower()120 121:class:`_orm.declared_attr` can also be applied directly to mapped122classes, to allow for attributes that dynamically configure themselves123on subclasses when using mapped inheritance schemes.   Below124illustrates :class:`_orm.declared_attr` to create a dynamic scheme125for generating the :paramref:`_orm.Mapper.polymorphic_identity` parameter126for subclasses::127 128    class Employee(Base):129        __tablename__ = "employee"130 131        id: Mapped[int] = mapped_column(primary_key=True)132        type: Mapped[str] = mapped_column(String(50))133 134        @declared_attr.directive135        def __mapper_args__(cls) -> Dict[str, Any]:136            if cls.__name__ == "Employee":137                return {138                    "polymorphic_on": cls.type,139                    "polymorphic_identity": "Employee",140                }141            else:142                return {"polymorphic_identity": cls.__name__}143 144 145    class Engineer(Employee):146        pass147 148:class:`_orm.declared_attr` supports decorating functions that are149explicitly decorated with ``@classmethod``. This is never necessary from a150runtime perspective, however may be needed in order to support :pep:`484`151typing tools that don't otherwise recognize the decorated function as152having class-level behaviors for the ``cls`` parameter::153 154    class SomethingMixin:155        x: Mapped[int]156        y: Mapped[int]157 158        @declared_attr159        @classmethod160        def x_plus_y(cls) -> Mapped[int]:161            return column_property(cls.x + cls.y)162 163.. versionadded:: 2.0 - :class:`_orm.declared_attr` can accommodate a164   function decorated with ``@classmethod`` to help with :pep:`484`165   integration where needed.166 167 168.. seealso::169 170    :ref:`orm_mixins_toplevel` - Declarative Mixin documentation with171    background on use patterns for :class:`_orm.declared_attr`.172 173c��gr�ror�s   r\r��declared_attr.__init__�r�r^c��gr�ror�s   r\r��declared_attr.__set__�r�r^c��gr�ror�s  r\r��declared_attr.__delete__�r�r^c��gr�ror�s   r\r��declared_attr.__get__�s��),r^c��gr�ror�s   r\r�r��s��?Br^c��gr�ror�s   r\r�r��s��36r^c��[S0UD6$�Nro)�_stateful_declared_attr)rZr�s  r\�	_stateful�declared_attr._stateful�s��&�,��,�,r^c��[$r�)r��rZs r\�	directive�declared_attr.directive�s174��#�"r^c� �URSS9$)NT)r�)r�r�s r\r��declared_attr.cascading�s���}�}�t�}�,�,r^roNr�)r��_DeclaredAttrDecorated[_T]r�r�r�r�)r�rrr�rrqzInstrumentedAttribute[_T])r��objectr�rrqrS)r�r�r�rrqz$Union[InstrumentedAttribute[_T], _T]�r�rrq�_stateful_declared_attr[_T])rqz_declared_directive[Any])rqr�)rsrtrurvr|r?rr�r�r�rr�r=r�r>r�r�rwror^r\r�r�Ls���Z�x���175$�	�*�	��	�	B�8�176�	,� �	,�),�	,�
&�	,�177�	,�178�B�179�B�	7�,�	7�58�	7�
1�	7��-��-��#��#��-��-r^r�c�H�\rSrSr%S\S'S	Sjr\S180Sj5rSSjrSr	g)r�i�zDict[str, Any]r�c��Xlgr��r��r�r�s  r\r�� _stateful_declared_attr.__init__�s���r^c�n�URR5nURU5 [S0UD6$r�)r��copy�updater�)r�r��new_kws   r\r��!_stateful_declared_attr._stateful�s+����������
�
�b��&�0��0�0r^c�.�[U40URD6$r�)r�r�r�s  r\r�� _stateful_declared_attr.__call__�s���R�+�4�7�7�+�+r^r�N�r�rr�)r�r�rqzdeclared_attr[_T])181rsrtrurvr�r�r=r�r�rwror^r\r�r��s&������1��1�182,r^r�c��U$)a6Mark a class as providing the feature of "declarative mixin".183 184E.g.::185 186    from sqlalchemy.orm import declared_attr187    from sqlalchemy.orm import declarative_mixin188 189 190    @declarative_mixin191    class MyMixin:192 193        @declared_attr194        def __tablename__(cls):195            return cls.__name__.lower()196 197        __table_args__ = {"mysql_engine": "InnoDB"}198        __mapper_args__ = {"always_refresh": True}199 200        id = Column(Integer, primary_key=True)201 202 203    class MyModel(MyMixin, Base):204        name = Column(String(1000))205 206The :func:`_orm.declarative_mixin` decorator currently does not modify207the given class in any way; it's current purpose is strictly to assist208the :ref:`Mypy plugin <mypy_toplevel>` in being able to identify209SQLAlchemy declarative mixin classes when no other context is present.210 211.. versionadded:: 1.4.6212 213.. legacy:: This api is considered legacy and will be deprecated in the next214  SQLAlchemy version.215 216.. seealso::217 218    :ref:`orm_mixins_toplevel`219 220    :ref:`mypy_declarative_mixins` - in the221    :ref:`Mypy plugin documentation <mypy_toplevel>`222 223ror�s r\�declarative_mixinr�s224��X�Jr^c�d�SUR;aURSnOSnSUR;aURSnOSnURRSS5nUbE[U[5(d[R225"S5eUb[R226"S5eO[XS9nX0lX0lSUR;aURRUl[US[R5[RLaURRUl227gg)Nr��type_annotation_mapr�zfDeclarative base class has a 'registry' attribute that is not an instance of sqlalchemy.orm.registry()z�Declarative 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�)rer�r�r�r5r�r�r�rYr�r��constructor)rZr�r	r�s    r\�_setup_declarative_basers���S�\�\�!��<�<�228�+��������,�!�l�l�+@�A��"��229
�,�,�230�231�:�t�232,�C�233���#�x�(�(��)�)�?��
�!�
,��)�)�-��
�-���234����������%��|�|�,�,����s�J����0�F�O�O�C��|�|�/�/���Dr^c�235^�\rSrSrSr\R\R\R\R\R\R\R\R4SU4SjjjrSrU=r	$)�MappedAsDataclassi<z�Mixin class to indicate when mapping this class, also convert it to be236a dataclass.237 238.. seealso::239 240    :ref:`orm_declarative_native_dataclasses` - complete background241    on SQLAlchemy native dataclass mapping242 243.. versionadded:: 2.0244 245c		��>�UUUUUUUUS.n246[US5(a�URn[R"U5 U247R	5VV
s0sH:up�X�[248RLa URU[249R5OU
_M< sn
n=UlnO	U250=Uln[TU]$"S0U	D6 [U5(d.[R"U5n[R"X�U5 ggs sn
nf)N��init�repr�eq�order�unsafe_hash�251match_args�kw_only�dataclass_callable�_sa_apply_dc_transformsro)
�hasattrrr(�_assert_dc_arguments�itemsr9�NO_ARGr��super�__init_subclass__r"�(_update_annotations_for_non_mapped_class�_apply_dataclasses_to_any_class)rZrrrrrrrrr��apply_dc_transforms�current�k�v�current_transforms�new_anno�	__class__s                �r\r�#MappedAsDataclass.__init_subclass__Is�������&�$��"4�	4252���3�1�2�2��1�1�G�"�7�7��@�0�5�5�7�@�7�D�A�����4F�7�;�;�q�&�-�-�0�A�M�7�@�
�C�'�*<�$�
�C�'�*<�	��!�'�B�'���$�$�&�O�O���H�
#�B�B�"��
�	%��@s�AC8ro)r�Union[_NoArg, bool]rr)rr)rr)rr)rr)rr)r�'Union[_NoArg, Callable[..., Type[Any]]]r�rrqrr)253rsrtrurvr|r9rrrw�
__classcell__�r's@r\r
r
<s����254�%+�M�M�$*�M�M�"(�-�-�%+�]�]�+1�=�=�*0�-�-�'-�}�}�
�M�M�1�!�1�"�1�
 �	1�255#�1�)�
1�(�1�%�1�256�1��1�257�1�1r^r
)�	metaclassc��^�\rSrSr%Sr\R(aCSSjrSSjrS\	S'S\	S'S\	S	'S258\	S'S\	S
'S\	S'S\	S'S\	S'S\	S'SSjr259SU4SjjrSrU=r
$)�DeclarativeBasei}a�Base class used for declarative class definitions.260 261The :class:`_orm.DeclarativeBase` allows for the creation of new262declarative bases in such a way that is compatible with type checkers::263 264 265    from sqlalchemy.orm import DeclarativeBase266 267 268    class Base(DeclarativeBase):269        pass270 271The above ``Base`` class is now usable as the base for new declarative272mappings.  The superclass makes use of the ``__init_subclass__()``273method to set up new classes and metaclasses aren't used.274 275When first used, the :class:`_orm.DeclarativeBase` class instantiates a new276:class:`_orm.registry` to be used with the base, assuming one was not277provided explicitly. The :class:`_orm.DeclarativeBase` class supports278class-level attributes which act as parameters for the construction of this279registry; such as to indicate a specific :class:`_schema.MetaData`280collection as well as a specific value for281:paramref:`_orm.registry.type_annotation_map`::282 283    from typing_extensions import Annotated284 285    from sqlalchemy import BigInteger286    from sqlalchemy import MetaData287    from sqlalchemy import String288    from sqlalchemy.orm import DeclarativeBase289 290    bigint = Annotated[int, "bigint"]291    my_metadata = MetaData()292 293 294    class Base(DeclarativeBase):295        metadata = my_metadata296        type_annotation_map = {297            str: String().with_variant(String(255), "mysql", "mariadb"),298            bigint: BigInteger(),299        }300 301Class-level attributes which may be specified include:302 303:param metadata: optional :class:`_schema.MetaData` collection.304 If a :class:`_orm.registry` is constructed automatically, this305 :class:`_schema.MetaData` collection will be used to construct it.306 Otherwise, the local :class:`_schema.MetaData` collection will supersede307 that used by an existing :class:`_orm.registry` passed using the308 :paramref:`_orm.DeclarativeBase.registry` parameter.309:param type_annotation_map: optional type annotation map that will be310 passed to the :class:`_orm.registry` as311 :paramref:`_orm.registry.type_annotation_map`.312:param registry: supply a pre-existing :class:`_orm.registry` directly.313 314.. versionadded:: 2.0  Added :class:`.DeclarativeBase`, so that declarative315   base classes may be constructed in such a way that is also recognized316   by :pep:`484` type checkers.   As a result, :class:`.DeclarativeBase`317   and other subclassing-oriented APIs should be seen as318   superseding previous "class returned by a function" APIs, namely319   :func:`_orm.declarative_base` and :meth:`_orm.registry.generate_base`,320   where the base class returned cannot be recognized by type checkers321   without using plugins.322 323**__init__ behavior**324 325In a plain Python class, the base-most ``__init__()`` method in the class326hierarchy is ``object.__init__()``, which accepts no arguments. However,327when the :class:`_orm.DeclarativeBase` subclass is first declared, the328class is given an ``__init__()`` method that links to the329:paramref:`_orm.registry.constructor` constructor function, if no330``__init__()`` method is already present; this is the usual declarative331constructor that will assign keyword arguments as attributes on the332instance, assuming those attributes are established at the class level333(i.e. are mapped, or are linked to a descriptor). This constructor is334**never accessed by a mapped class without being called explicitly via335super()**, as mapped classes are themselves given an ``__init__()`` method336directly which calls :paramref:`_orm.registry.constructor`, so in the337default case works independently of what the base-most ``__init__()``338method does.339 340.. versionchanged:: 2.0.1  :class:`_orm.DeclarativeBase` has a default341   constructor that links to :paramref:`_orm.registry.constructor` by342   default, so that calls to ``super().__init__()`` can access this343   constructor. Previously, due to an implementation mistake, this default344   constructor was missing, and calling ``super().__init__()`` would invoke345   ``object.__init__()``.346 347The :class:`_orm.DeclarativeBase` subclass may also declare an explicit348``__init__()`` method which will replace the use of the349:paramref:`_orm.registry.constructor` function at this level::350 351    class Base(DeclarativeBase):352        def __init__(self, id=None):353            self.id = id354 355Mapped classes still will not invoke this constructor implicitly; it356remains only accessible by calling ``super().__init__()``::357 358    class MyClass(Base):359        def __init__(self, id=None, name=None):360            self.name = name361            super().__init__(id=id)362 363Note that this is a different behavior from what functions like the legacy364:func:`_orm.declarative_base` would do; the base created by those functions365would always install :paramref:`_orm.registry.constructor` for366``__init__()``.367 368 369c��gr�ror�s r\�_sa_inspect_type� DeclarativeBase._sa_inspect_type����Cr^c��gr�ror�s r\�_sa_inspect_instance�$DeclarativeBase._sa_inspect_instance����sr^�ClassVar[_RegistryType]r�r��ClassVar[MetaData]r�z
ClassVar[str]rs�ClassVar[Mapper[Any]]rdzClassVar[FromClause]rWr�
__tablename__�__mapper_args__�__table_args__c��gr�ror�s  r\r��DeclarativeBase.__init__G���sr^c��>�[UR;a[U[5 [U5 O [	UR370XR5 [TU] "S0UD6 gr�)	r/�	__bases__�_check_not_declarativerr'r�rerr�rZr�r's  �r\r�!DeclarativeBase.__init_subclass__IsE����c�m�m�+�"�3��8�#�C�(��C�,�,�c�<�<�@�
��!�'�B�'r^ro�rqzMapper[Self]�rqzInstanceState[Self]r�r�rrqrr)rsrtrurvr|r?rr1r5r�r�rrwr+r,s@r\r/r/}s����371n�`���7�B�-�-�)�)�	<�%�$�	� ��372*�)�	�(�'�	���	���	���		�	+�(�(r^r/c�373�URnSU;a'[US5(d[USS5(a%[UR	SS5[3745(a%[R"SUR<S35eg)NrWr�r;zCannot use zR directly as a declarative base class. Create a Base by creating a subclass of it.)	re�callablerr�r�rpr5r�rs)rZ�base�cls_dicts   r\rCrCRs}���|�|�H��x���X�k�*�+�+��x��,�i�8�8�	�H�L�L��$�7��	=�	=��%�%��$�-�-�*�+A�
A�375�	376�377>r^c��^�\rSrSr%SrS\S'S\S'S\S'S\S	'S378\S'\R(a!SSjrSS
jr	S\S'S\S'S\S'SSjr379SU4SjjrSrU=r
$)�DeclarativeBaseNoMetaiaz�Same as :class:`_orm.DeclarativeBase`, but does not use a metaclass380to intercept new attributes.381 382The :class:`_orm.DeclarativeBaseNoMeta` base may be used when use of383custom metaclasses is desirable.384 385.. versionadded:: 2.0386 387 388r8r�r�r9r�r:rd�Optional[FromClause]rWc��gr�ror�s r\r1�&DeclarativeBaseNoMeta._sa_inspect_type�r3r^c��gr�ror�s r\r5�*DeclarativeBaseNoMeta._sa_inspect_instance�r7r^rr;r<r=c��gr�ror�s  r\r��DeclarativeBaseNoMeta.__init__�r@r^c��>�[UR;a[U[5 [U5 O [	UR389XR5 [TU] "S0UD6 gr�)	rNrBrCrr'r�rerrrDs  �r\r�'DeclarativeBaseNoMeta.__init_subclass__�sF��� �C�M�M�1�"�3�(=�>�#�C�(��C�,�,�c�<�<�@�
��!�'�B�'r^rorFrGrrH)rsrtrurvr|r�r?rr1r5r�rrwr+r,s@r\rNrNas����	�*�)�%�%�8�!� ��&�%��$�#�����7�B���	���	���		�	+�(�(r^rNc��[XU5 g)aAdd a new mapped attribute to an ORM mapped class.390 391E.g.::392 393    add_mapped_attribute(User, "addresses", relationship(Address))394 395This may be used for ORM mappings that aren't using a declarative396metaclass that intercepts attribute set operations.397 398.. versionadded:: 2.0399 400 401Nr%)�targetrh�attrs   r\�add_mapped_attributer[�s�� �6��%r^�Base�r��mapperrZr��class_registryr	r402r-c�:�[UUUUS9RUUUUS9$)a�
Construct a base class for declarative class definitions.403 404The new base class will be given a metaclass that produces405appropriate :class:`~sqlalchemy.schema.Table` objects and makes406the appropriate :class:`_orm.Mapper` calls based on the407information provided declaratively in the class and any subclasses408of the class.409 410.. versionchanged:: 2.0 Note that the :func:`_orm.declarative_base`411   function is superseded by the new :class:`_orm.DeclarativeBase` class,412   which generates a new "base" class using subclassing, rather than413   return value of a function.  This allows an approach that is compatible414   with :pep:`484` typing tools.415 416The :func:`_orm.declarative_base` function is a shorthand version417of using the :meth:`_orm.registry.generate_base`418method.  That is, the following::419 420    from sqlalchemy.orm import declarative_base421 422    Base = declarative_base()423 424Is equivalent to::425 426    from sqlalchemy.orm import registry427 428    mapper_registry = registry()429    Base = mapper_registry.generate_base()430 431See the docstring for :class:`_orm.registry`432and :meth:`_orm.registry.generate_base`433for more details.434 435.. versionchanged:: 1.4  The :func:`_orm.declarative_base`436   function is now a specialization of the more generic437   :class:`_orm.registry` class.  The function also moves to the438   ``sqlalchemy.orm`` package from the ``declarative.ext`` package.439 440 441:param metadata:442  An optional :class:`~sqlalchemy.schema.MetaData` instance.  All443  :class:`~sqlalchemy.schema.Table` objects implicitly declared by444  subclasses of the base will share this MetaData.  A MetaData instance445  will be created if none is provided.  The446  :class:`~sqlalchemy.schema.MetaData` instance will be available via the447  ``metadata`` attribute of the generated declarative base class.448 449:param mapper:450  An optional callable, defaults to :class:`_orm.Mapper`. Will451  be used to map subclasses to their Tables.452 453:param cls:454  Defaults to :class:`object`. A type to use as the base for the generated455  declarative base class. May be a class or tuple of classes.456 457:param name:458  Defaults to ``Base``.  The display name for the generated459  class.  Customizing this is not required, but can improve clarity in460  tracebacks and debugging.461 462:param constructor:463  Specify the implementation for the ``__init__`` function on a mapped464  class that has no ``__init__`` of its own.  Defaults to an465  implementation that assigns \**kwargs for declared466  fields and relationships to an instance.  If ``None`` is supplied,467  no __init__ will be provided and construction will fall back to468  cls.__init__ by way of the normal Python semantics.469 470:param class_registry: optional dictionary that will serve as the471  registry of class names-> mapped classes when string names472  are used to identify classes inside of :func:`_orm.relationship`473  and others.  Allows two or more declarative base classes474  to share the same registry of class names for simplified475  inter-base relationships.476 477:param type_annotation_map: optional dictionary of Python types to478    SQLAlchemy :class:`_types.TypeEngine` classes or instances.  This479    is used exclusively by the :class:`_orm.MappedColumn` construct480    to produce column types based on annotations within the481    :class:`_orm.Mapped` type.482 483 484    .. versionadded:: 2.0485 486    .. seealso::487 488        :ref:`orm_declarative_mapped_column_type_map`489 490:param metaclass:491  Defaults to :class:`.DeclarativeMeta`.  A metaclass or __metaclass__492  compatible callable to use as the meta type of the generated493  declarative base class.494 495.. seealso::496 497    :class:`_orm.registry`498 499)r�r_r500r	)r^rZr�r-)r��
generate_baser]s        r\�declarative_baserb�s;��\��%��/�	�501�m���
��	��502r^c�f�\rSrSr%SrS\S'S\S'S\S'S	\S503'S\S'S
\S'S\S'S\S'S\S'SSS\S.S2SjjrS3SjrS4S5Sjjr	\504S6Sj5rS7SjrS8Sjr
\S9Sj5r\S9Sj5rS:SjrS;SjrS<S jrS=S!jrS4S>S"jjrS4S>S#jjrS=S$jrS\S%\4S?S&jjr\R8"\\\\ \!\"\#\$\%4	S'9\&S@S(j55r'\&SAS)S)S)S)S)S)S)S)S*.SBS+jjj5r'SC\(RR\(RR\(RR\(RR\(RR\(RR\(RR\(RRS*.SDS,jjjr'SES-jr*SFS.jr+SGS/jr,SCSHS0jjr-S1r.g)Ir�iZa\Generalized registry for mapping classes.505 506The :class:`_orm.registry` serves as the basis for maintaining a collection507of mappings, and provides configurational hooks used to map classes.508 509The three general kinds of mappings supported are Declarative Base,510Declarative Decorator, and Imperative Mapping.   All of these mapping511styles may be used interchangeably:512 513* :meth:`_orm.registry.generate_base` returns a new declarative base514  class, and is the underlying implementation of the515  :func:`_orm.declarative_base` function.516 517* :meth:`_orm.registry.mapped` provides a class decorator that will518  apply declarative mapping to a class without the use of a declarative519  base class.520 521* :meth:`_orm.registry.map_imperatively` will produce a522  :class:`_orm.Mapper` for a class without scanning the class for523  declarative class attributes. This method suits the use case historically524  provided by the ``sqlalchemy.orm.mapper()`` classical mapping function,525  which is removed as of SQLAlchemy 2.0.526 527.. versionadded:: 1.4528 529.. seealso::530 531    :ref:`orm_mapping_classes_toplevel` - overview of class mapping532    styles.533 534zclsregistry._ClsRegistryType�_class_registryz;weakref.WeakKeyDictionary[ClassManager[Any], Literal[True]]�	_managersz5weakref.WeakKeyDictionary[Mapper[Any], Literal[True]]�_non_primary_mappersr;r�z&CallableReference[Callable[..., None]]r535�_MutableTypeAnnotationMapTyper	zSet[_RegistryType]�_dependents�
_dependenciesr��_new_mappersN)r�r_r	r536c���U=(d537 [5nUc[R"5nX l[R"5Ul[R"5UlXPlX@l0Ul	UbURU5 [5Ul[5Ul
SUl[R  S[R"U'SSS5 g!,(df   g=f)aConstruct a new :class:`_orm.registry`538 539:param metadata:540  An optional :class:`_schema.MetaData` instance.  All541  :class:`_schema.Table` objects generated using declarative542  table mapping will make use of this :class:`_schema.MetaData`543  collection.  If this argument is left at its default of ``None``,544  a blank :class:`_schema.MetaData` collection is created.545 546:param constructor:547  Specify the implementation for the ``__init__`` function on a mapped548  class that has no ``__init__`` of its own.  Defaults to an549  implementation that assigns \**kwargs for declared550  fields and relationships to an instance.  If ``None`` is supplied,551  no __init__ will be provided and construction will fall back to552  cls.__init__ by way of the normal Python semantics.553 554:param class_registry: optional dictionary that will serve as the555  registry of class names-> mapped classes when string names556  are used to identify classes inside of :func:`_orm.relationship`557  and others.  Allows two or more declarative base classes558  to share the same registry of class names for simplified559  inter-base relationships.560 561:param type_annotation_map: optional dictionary of Python types to562  SQLAlchemy :class:`_types.TypeEngine` classes or instances.563  The provided dict will update the default type mapping.  This564  is used exclusively by the :class:`_orm.MappedColumn` construct565  to produce column types based on annotations within the566  :class:`_orm.Mapped` type.567 568  .. versionadded:: 2.0569 570  .. seealso::571 572      :ref:`orm_declarative_mapped_column_type_map`573 574 575NFT)r;�weakref�WeakValueDictionaryrd�WeakKeyDictionaryrerfr�r576r	�update_type_annotation_map�setrhrirjr�_CONFIGURE_MUTEX�_mapper_registries)r�r�r_r	r577�lcl_metadatas      r\r��registry.__init__�s���^ �-�8�:���!�$�8�8�:�N�-�� �2�2�4���$+�$=�$=�$?��!�$�
�&��#%�� ��*��+�+�,?�@��5��� �U���!���
�
'�
'�15�I�(�(��.�(�
'�
'�s�C�578C-c	��URRUR5VVs0sHup#[U5U_M snn5 gs snnf)zIupdate the :paramref:`_orm.registry.type_annotation_map` with new579values.N)r	rrrB)r�r	�typ�sqltypes    r\ro�#registry.update_type_annotation_map�sO��	
� � �'�'�%8�$=�$=�$?�
�$?�L�C�+�3�/��8�$?�
�	580��
s�A581 582c�^�[U5(a;[U5(aUmUT4/U4Sj[5Q7nODURmUT44nO2[	U[5835(aUmSTR5nOUmUT44nUHnupEURRU5nUc[R"U5nUcM>[R"U5nURTUU5nUcMlUs $ U(a�Sn	Sn584[U5(a]Un	[U	5(a>[U	5(d.U	Rn	[U	5(a[U	5(dM.[!U	5n	Sn585[#U5(a
[%U5n	Sn586U	bJUR'U	S5nUb5U587ceU588S:Xa[)SU589SUS3S	5 U$[)S590U591SUS3S	5 U$g)Nc3�*># �UHoT4v� M592 g7fr�ro)�.0�lt�python_type_types  �r\�	<genexpr>�)registry._resolve_type.<locals>.<genexpr>�s����E�}��+�,�}�s�c3�(# �UHoU4v� M593 g7fr�ro)r{�pts  r\r~r�s���B�)A�2�2�h�)A�s�zpep-695 type�NewTypeFzMatching to z 'z�' in a recursive fashion without the recursed type being present in the type_annotation_map is deprecated; add this type or its recursed value to the type_annotation_map to allow it to match explicitly.z2.0zMatching the provided 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.)rDrErJ�594__origin__r�rfrXr	r�r8�
_type_map_get�to_instance�_resolve_for_python_typerHrG�	__value__rBrFrC�
_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���595$/�#9�#9� �&�(8�9�;��
��T�
*�
*�*��B�)9�)A�)A�B�F�*��"�$4�5�7�F�#�M�B��/�/�3�3�B�7�H���#�1�1�"�5���#� (� 4� 4�X� >�
�%2�$J�$J�$���%�!�596%�0�,�,�)$�.�(,� ��D���%�%�'2�$�� 4�5�5�i�(�?�?�,@�+I�+I�(� � 4�5�5�i�(�?�?�(B�(�(�$�&���+�&�&�'6�{�'C�$� ��#�/�%)�%7�%7�(�%�&�"�&�1��+�+�+��~�-�'�*�4�&��;�-�@*�*�"�	�(.�-�(�4�T�F�"�[�M�J*�*�"��.�-�r^c�l�[SUR55RUR5$)z9read only collection of all :class:`_orm.Mapper` objects.c3�8# �UHoRv� M g7fr�)r^�r{r�s  r\r~�#registry.mappers.<locals>.<genexpr>;s���F�~�G���~�s�)�	frozensetre�unionrfr�s r\�mappers�registry.mappers7s/���F�t�~�~�F�F�L�L��%�%�597�	598r^c�z�XLagURRU5 URRU5 gr�)rh�addri)r�r�s  r\�_set_depends_on�registry._set_depends_on?s3�������� � ��&������x�(r^c�v�SUlUR(agURU15H599nSUlM g�NT)�_ready_for_configurerj�_recurse_with_dependents)r�r^r�s   r\�_flag_new_mapper�registry._flag_new_mapperEs5��&*��#������0�0�$��8�C�#�C��9r^c#�8# �Un[5nU(a�UR5nURU5 URURRU55 Uv� URURRU55 U(aM�gg7fr�)rp�popr�rrh�600difference�rZ�601registries�todo�doner�s     r\r��!registry._recurse_with_dependentsMsr������u����(�(�*�C��H�H�S�M�
�K�K����2�2�4�8�9��I�
�K�K����2�2�4�8�9��d���BB�Bc#�8# �Un[5nU(a�UR5nURU5 URURRU55 Uv� URURRU55 U(aM�gg7fr�)rpr�r�rrir�r�s     r\�_recurse_with_dependencies�#registry._recurse_with_dependencies`sv������u����(�(�*�C��H�H�S�M�
�K�K��)�)�4�4�T�:�;��I�
�K�K��)�)�4�4�T�:�;��d�r�c��[R"S[UR55S[UR555$)Nc3��# �UH^nUR(dMURR(aM3URR(dMPURv� M` g7fr�)r�r^�602configuredr�r�s  r\r~�1registry._mappers_to_configure.<locals>.<genexpr>vsN���
�3�G��$�$�� ���1�1���N�N�7�7�	����3�s�A(�A(�A(�A(c3�r# �UH-nUR(aMUR(dM)Uv� M/ g7fr�)r�r�)r{�npms  r\r~r�}s.���
�:�C��~�~��*-�*B�*B���:�s�7�7�	7)�	itertools�chain�listrerfr�s r\�_mappers_to_configure�registry._mappers_to_configuretsA�����
�#�D�N�N�3�
�
��� 9� 9�:�
�
603�
	604r^c�"�SURU'gr�)rf)r��	np_mappers  r\�_add_non_primary_mapper� registry._add_non_primary_mapper�s��/3��!�!�)�,r^c�Z�[R"URXR5 gr�)r�remove_classrsrd�r�rZs  r\�_dispose_cls�registry._dispose_cls�s��� � ����s�4H�4H�Ir^c��SURU'UR(a#[R"SUR-5eUR605beXlg)NTz1Class '%s' already has a primary mapper defined. )rer�r5�
ArgumentErrorr[r�)r�r�s  r\�_add_manager�registry._add_manager�sU��"&����w������#�#�C��.�.�!��
����'�'�'��r^c�0�[R"U1US9 g)auConfigure all as-yet unconfigured mappers in this606:class:`_orm.registry`.607 608The configure step is used to reconcile and initialize the609:func:`_orm.relationship` linkages between mapped classes, as well as610to invoke configuration events such as the611:meth:`_orm.MapperEvents.before_configured` and612:meth:`_orm.MapperEvents.after_configured`, which may be used by ORM613extensions or user-defined extension hooks.614 615If one or more mappers in this registry contain616:func:`_orm.relationship` constructs that refer to mapped classes in617other registries, this registry is said to be *dependent* on those618registries. In order to configure those dependent registries619automatically, the :paramref:`_orm.registry.configure.cascade` flag620should be set to ``True``. Otherwise, if they are not configured, an621exception will be raised.  The rationale behind this behavior is to622allow an application to programmatically invoke configuration of623registries while controlling whether or not the process implicitly624reaches other registries.625 626As an alternative to invoking :meth:`_orm.registry.configure`, the ORM627function :func:`_orm.configure_mappers` function may be used to ensure628configuration is complete for all :class:`_orm.registry` objects in629memory. This is generally simpler to use and also predates the usage of630:class:`_orm.registry` objects overall. However, this function will631impact all mappings throughout the running Python process and may be632more memory/time consuming for an application that has many registries633in use for different purposes that may not be needed immediately.634 635.. seealso::636 637    :func:`_orm.configure_mappers`638 639 640.. versionadded:: 1.4.0b2641 642��cascadeN)r�_configure_registries�r�r�s  r\�	configure�registry.configure�s��N	�'�'����@r^c�0�[R"U1US9 g)a6Dispose of all mappers in this :class:`_orm.registry`.643 644After invocation, all the classes that were mapped within this registry645will no longer have class instrumentation associated with them. This646method is the per-:class:`_orm.registry` analogue to the647application-wide :func:`_orm.clear_mappers` function.648 649If this registry contains mappers that are dependencies of other650registries, typically via :func:`_orm.relationship` links, then those651registries must be disposed as well. When such registries exist in652relation to this one, their :meth:`_orm.registry.dispose` method will653also be called, if the :paramref:`_orm.registry.dispose.cascade` flag654is set to ``True``; otherwise, an error is raised if those registries655were not already disposed.656 657.. versionadded:: 1.4.0b2658 659.. seealso::660 661    :func:`_orm.clear_mappers`662 663r�N)r�_dispose_registriesr�s  r\�dispose�registry.dispose�s��0	�%�%�t�f�g�>r^c���SUR;aURnUR5 URnUR	U5 [664RRU5 g)Nr^)rer^�_set_dispose_flagsr[r�r�_instrumentation_factory�665unregister)r�r�r^r[s    r\�_dispose_manager_and_mapper�$registry._dispose_manager_and_mapper�sP���w�'�'�'��^�^�F��%�%�'��������&�!��0�0�;�;�F�Cr^r\c�b�URn[U[5(+=(a U4=(d Un[XS9n[U[5(aUR666US'URbURUS'SUS'U(aXS'[US5(a	S	SjnX�S'U"X6U5$)667aOGenerate a declarative base class.668 669Classes that inherit from the returned class object will be670automatically mapped using declarative mapping.671 672E.g.::673 674    from sqlalchemy.orm import registry675 676    mapper_registry = registry()677 678    Base = mapper_registry.generate_base()679 680 681    class MyClass(Base):682        __tablename__ = "my_table"683        id = Column(Integer, primary_key=True)684 685The above dynamically generated class is equivalent to the686non-dynamic example below::687 688    from sqlalchemy.orm import registry689    from sqlalchemy.orm.decl_api import DeclarativeMeta690 691    mapper_registry = registry()692 693 694    class Base(metaclass=DeclarativeMeta):695        __abstract__ = True696        registry = mapper_registry697        metadata = mapper_registry.metadata698 699        __init__ = mapper_registry.constructor700 701.. versionchanged:: 2.0 Note that the702   :meth:`_orm.registry.generate_base` method is superseded by the new703   :class:`_orm.DeclarativeBase` class, which generates a new "base"704   class using subclassing, rather than return value of a function.705   This allows an approach that is compatible with :pep:`484` typing706   tools.707 708The :meth:`_orm.registry.generate_base` method provides the709implementation for the :func:`_orm.declarative_base` function, which710creates the :class:`_orm.registry` and base class all at once.711 712See the section :ref:`orm_declarative_mapping` for background and713examples.714 715:param mapper:716  An optional callable, defaults to :class:`_orm.Mapper`.717  This function is used to generate new :class:`_orm.Mapper` objects.718 719:param cls:720  Defaults to :class:`object`. A type to use as the base for the721  generated declarative base class. May be a class or tuple of classes.722 723:param name:724  Defaults to ``Base``.  The display name for the generated725  class.  Customizing this is not required, but can improve clarity in726  tracebacks and debugging.727 728:param metaclass:729  Defaults to :class:`.DeclarativeMeta`.  A metaclass or __metaclass__730  compatible callable to use as the meta type of the generated731  declarative base class.732 733.. seealso::734 735    :ref:`orm_declarative_mapping`736 737    :func:`_orm.declarative_base`738 739)r�r�r|r�Tr��__mapper_cls__�__class_getitem__c��U$r�rorms  r\r��1registry.generate_base.<locals>.__class_getitem__Bs���740r^)rZ�Type[_T]rhrrqr�)r�r��tuple�dictrfr|r741r)	r�r^rZr�r-r�r��742class_dictr�s	         r\ra�registry.generate_base�s���`�=�=���s�E�*�*�5��v�<���%)�4�%K�743��c�4� � �$'�K�K�J�y�!����'�%)�%5�%5�J�z�"�%)�744�>�"��+1�'�(��3�+�,�,�
�/@�*�+���j�1�1r^r}c��gr�ro)r��_registry__clss  r\�mapped_as_dataclass�registry.mapped_as_dataclassJs	��ADr^.rc��gr�ro)745r�r�rrrrrrrrs746          r\r�r�Zs��*-r^c747�V^^^^^^^^^	�SU	UUUUUUUU4	Sjjn748U(aU749"U5$U750$)a�Class decorator that will apply the Declarative mapping process751to a given class, and additionally convert the class to be a752Python dataclass.753 754.. seealso::755 756    :ref:`orm_declarative_native_dataclasses` - complete background757    on SQLAlchemy native dataclass mapping758 759    :func:`_orm.mapped_as_dataclass` - functional version that may760    provide better compatibility with mypy761 762.. versionadded:: 2.0763 764 765c
�`>	�[USTTTTT	TTTS.5 [TXR5 U$)Nrr)�setattrr're)766rZrrrrrrrr�rs767 ���������r\r��.registry.mapped_as_dataclass.<locals>.decorate�sC�����)� � ��"�#.�",�&�*<�	�

�
�D�#�|�|�4��Jr^�rZ�Type[_O]rqr�ro)r�r�rrrrrrrrr�s` ```````` r\r�r�is#����@	�	�$��E�?�"��Or^c�2�[XUR5 U$)a�Class decorator that will apply the Declarative mapping process768to a given class.769 770E.g.::771 772    from sqlalchemy.orm import registry773 774    mapper_registry = registry()775 776 777    @mapper_registry.mapped778    class Foo:779        __tablename__ = "some_table"780 781        id = Column(Integer, primary_key=True)782        name = Column(String)783 784See the section :ref:`orm_declarative_mapping` for complete785details and examples.786 787:param cls: class to be mapped.788 789:return: the class that was passed.790 791.. seealso::792 793    :ref:`orm_declarative_mapping`794 795    :meth:`_orm.registry.generate_base` - generates a base class796    that will apply Declarative mapping to subclasses automatically797    using a Python metaclass.798 799.. seealso::800 801    :meth:`_orm.registry.mapped_as_dataclass`802 803)r'rer�s  r\�mapped�registry.mapped�s��L	��3�<�<�0��804r^c�^^�SUU4SjjnU$)a(805Class decorator which will invoke806:meth:`_orm.registry.generate_base`807for a given base class.808 809E.g.::810 811    from sqlalchemy.orm import registry812 813    mapper_registry = registry()814 815 816    @mapper_registry.as_declarative_base()817    class Base:818        @declared_attr819        def __tablename__(cls):820            return cls.__name__.lower()821 822        id = Column(Integer, primary_key=True)823 824 825    class MyMappedClass(Base): ...826 827All keyword arguments passed to828:meth:`_orm.registry.as_declarative_base` are passed829along to :meth:`_orm.registry.generate_base`.830 831c�P>�UTS'URTS'TR"S0TD6$)NrZr�ro)rsra)rZr�r�s ��r\r��.registry.as_declarative_base.<locals>.decorate�s-����B�u�I����B�v�J��%�%�+��+�+r^�rZr�rqr�ro)r�r�r�s`` r\�as_declarative_base�registry.as_declarative_base�s���<	,�	,�832�r^c�F�[XUR5 UR$)aMap a class declaratively.833 834In this form of mapping, the class is scanned for mapping information,835including for columns to be associated with a table, and/or an836actual table object.837 838Returns the :class:`_orm.Mapper` object.839 840E.g.::841 842    from sqlalchemy.orm import registry843 844    mapper_registry = registry()845 846 847    class Foo:848        __tablename__ = "some_table"849 850        id = Column(Integer, primary_key=True)851        name = Column(String)852 853 854    mapper = mapper_registry.map_declaratively(Foo)855 856This function is more conveniently invoked indirectly via either the857:meth:`_orm.registry.mapped` class decorator or by subclassing a858declarative metaclass generated from859:meth:`_orm.registry.generate_base`.860 861See the section :ref:`orm_declarative_mapping` for complete862details and examples.863 864:param cls: class to be mapped.865 866:return: a :class:`_orm.Mapper` object.867 868.. seealso::869 870    :ref:`orm_declarative_mapping`871 872    :meth:`_orm.registry.mapped` - more common decorator interface873    to this function.874 875    :meth:`_orm.registry.map_imperatively`876 877)r'rerdr�s  r\�map_declaratively�registry.map_declaratively�s��^	��3�<�<�0��~�~�r^c��[XX#5$)a�Map a class imperatively.878 879In this form of mapping, the class is not scanned for any mapping880information.  Instead, all mapping constructs are passed as881arguments.882 883This method is intended to be fully equivalent to the now-removed884SQLAlchemy ``mapper()`` function, except that it's in terms of885a particular registry.886 887E.g.::888 889    from sqlalchemy.orm import registry890 891    mapper_registry = registry()892 893    my_table = Table(894        "my_table",895        mapper_registry.metadata,896        Column("id", Integer, primary_key=True),897    )898 899 900    class MyClass:901        pass902 903 904    mapper_registry.map_imperatively(MyClass, my_table)905 906See the section :ref:`orm_imperative_mapping` for complete background907and usage examples.908 909:param class\_: The class to be mapped.  Corresponds to the910 :paramref:`_orm.Mapper.class_` parameter.911 912:param local_table: the :class:`_schema.Table` or other913 :class:`_sql.FromClause` object that is the subject of the mapping.914 Corresponds to the915 :paramref:`_orm.Mapper.local_table` parameter.916 917:param \**kw: all other keyword arguments are passed to the918 :class:`_orm.Mapper` constructor directly.919 920.. seealso::921 922    :ref:`orm_imperative_mapping`923 924    :ref:`orm_declarative_mapping`925 926r,)r�r[�local_tabler�s    r\�map_imperatively�registry.map_imperatively s��p�t�[�5�5r^)	rdrirhrerjrfr927r�r	)r��Optional[MetaData]r_�&Optional[clsregistry._ClsRegistryType]r	� Optional[_TypeAnnotationMapType]r928�Callable[..., None])r	�_TypeAnnotationMapTyperqrrr�)r�rRr�r�rqz"Optional[sqltypes.TypeEngine[Any]])rqzFrozenSet[Mapper[Any]])r�r�rqrr)r^�Mapper[Any]rqrr)r�zSet[RegistryType]rqzIterator[RegistryType])rqzIterator[Mapper[Any]])r�rrqrr)rZr�rqrr)r�zClassManager[Any]rqrr)r�r�rqrr)929r^�$Optional[Callable[..., Mapper[Any]]]rZ�	Type[Any]r�rpr-rrqr)r�r�rqr�).)r�z
Literal[None]rr)rr)rr)rr)rr)rr)rr)rr*rq�Callable[[Type[_O]], Type[_O]]r�)r�zOptional[Type[_O]]rr)rr)rr)rr)rr)rr)rr)rr*rqz/Union[Type[_O], Callable[[Type[_O]], Type[_O]]]r��r�rrqzCallable[[Type[_T]], Type[_T]])rZr�rq�930Mapper[_O])r[r�r�rOr�rrqr931)/rsrtrurvr|r�r)r�ror��propertyr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�ra�
compat_typing�dataclass_transformr1r2r.r/rrrrrrr�r9rr�r�r�r�rwror^r\r�r�Zsn���@2�1�J�J�O�O���7�7�6�6�#�#�%�%���932(,�AE�@D�+C�
B6�%�B6�?�	B6�933>�B6�)�
B6�H934�3�935�936�937�BG�^�)�^�:>�^�	+�^�@�938��939�)�$��:�*�:�	�:��:�$�<�*�<�	�<��<�&940� 4�J� �'A�R?�4D�8<���.�g2�4�g2��g2��	g2�941�g2�942
�
g2�R�&�&�� ��������943944���C���D�
� #�-�%(�$'�"%�%(�+.�*-�'*�FI�-��-�"�	-�945"�-�
 �
-�#�-�)�-�(�-�%�-�D�-�946(�-��-� %)�5�%+�M�M�$*�M�M�"(�-�-�%+�]�]�+1�=�=�*0�-�-�'-�}�}�
�M�M�5�!�5�"�	5�947"�5�
 �
5�#�5�)�5�(�5�%�5�948�5�9499�5�n'�R#�J0�j-1�86��86�*�86��	86�950951�86�86r^r�c�z�URSS5URSS5p![XS9R"S0UD6$)aS952Class decorator which will adapt a given class into a953:func:`_orm.declarative_base`.954 955This function makes use of the :meth:`_orm.registry.as_declarative_base`956method, by first creating a :class:`_orm.registry` automatically957and then invoking the decorator.958 959E.g.::960 961    from sqlalchemy.orm import as_declarative962 963 964    @as_declarative()965    class Base:966        @declared_attr967        def __tablename__(cls):968            return cls.__name__.lower()969 970        id = Column(Integer, primary_key=True)971 972 973    class MyMappedClass(Base): ...974 975.. seealso::976 977    :meth:`_orm.registry.as_declarative_base`978 979r�Nr_)r�r_ro)r�r�r�)r�r�r_s   r\�as_declarativerbsP��>	���z�4� �980�����&��981������ �� � r^rc�.�URUUUUUUUUS9$)a�Standalone function form of :meth:`_orm.registry.mapped_as_dataclass`982which may have better compatibility with mypy.983 984The :class:`_orm.registry` is passed as the first argument to the985decorator.986 987e.g.::988 989    from sqlalchemy.orm import Mapped990    from sqlalchemy.orm import mapped_as_dataclass991    from sqlalchemy.orm import mapped_column992    from sqlalchemy.orm import registry993 994    some_registry = registry()995 996 997    @mapped_as_dataclass(some_registry)998    class Relationships:999        __tablename__ = "relationships"1000 1001        entity_id1: Mapped[int] = mapped_column(primary_key=True)1002        entity_id2: Mapped[int] = mapped_column(primary_key=True)1003        level: Mapped[int] = mapped_column(Integer)1004 1005.. versionadded:: 2.0.441006 1007r)r�)	r�rrrrrrrrs	         r\r�r��s5��l�'�'�
�
�
�����-�(�	�	r^c��[U5nUc1[R"U5(a[R"U5 U$r�)r!r*�has_cls�raise_unmapped_for_cls)rZ�mps  r\�_inspect_decl_metar�s7��!6�c� :�B�	�z� �(�(��-�-�!�8�8��=�
�Ir^)rZr�rqr�r�)r�rpr�r�rqz,Callable[[Callable[..., Any]], Synonym[Any]]r�)rZrrqrr)rZrrKrrqrr)rYr�rhrprZzMapperProperty[Any]rqrr)r�rr^rrZrr�rpr_rr	rr1008rr-rrqrr	)r�r�rr)rr)rr)rr)rr)rr)rr)rr*rqr)rZrrqzOptional[Mapper[Any]])�r|�1009__future__rr�r�r?rrrrrr	r1010rrr
rrrrrrrrl�rrrrr�_orm_constructorsrrrrrr rKr!r"r#r$�	decl_baser&r'r(r)r*r+r-�descriptor_propsr.r/r�r^r0�1011propertiesr1�
relationshipsr2�stater3r5r6r7�sqlr8�sql.baser9�sql.elementsr:�1012sql.schemar;�sql.selectabler<r=r>rr@�util.typingrArBrCrDrErFrGrHrIrJrK�_typingrLrMrNrOrP�sql._typingrQ�sql.type_apirRrSrUrrg�_DeclaredAttrDecoratedr]rfr`�Inspectableryr
r�r�r�r�r��_MappedAttributer�r�rrr
r/rCrNr[r�rbr�r�rrr��	_inspectsrror^r\�<module>r+s���8�"��	�
��������������� ���������(�'�,�+�&�-�'�"���%�&�-�/�,�%��'�%�5��$�/� ������,�!�'��!�*�"�+�4�)�$�$�$�#�#�!�'����&�.�-�*�$�1�-��T����
�e�3���!��&@�!@�A�� $�S�*D�%D� E��!���v�b�z�=��,�.?��.C�C�	D�D���1013�&'�T�'�	�����6�#�;�'�	��"�"����������1014��8�:�8��8�4�3�4�>#(�'�1015
�'��'�1�'�T>�>�B�/�����,E-�J�/�/��3�5J�E-�P
,�m�B�/�
,� ,�^&0�R>�"8�>�BR(����=��-�.�+�R(�j1016�h(����=��-�.�h(�V&��&��&�&9�&�	�&�*$(�37���=A�<@�'?�*�x� �x�
1�x�1017�	x�1018�x�;�
x�:�x�%�x��x�	�x�v~6�~6�B����M�% �P�"�"����������1019�� !'�
�
� &�
�
�$�m�m�!'���'-�}�}�&,�m�m�#)�=�=�	�
�
�2��2��2��	2�1020	�2��
2�%�2�$�2�!�2��2�$�2��2�j����_�&C����r^
codekingpro/portable-devtools · Team Ai