zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
U
¸ý°düã @sÐdZddlmZddlZddlZddlZddlmZddlmZddlmZddlm    Z    ddlm
Z
dd    lm Z dd
lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#dd lm$Z$dd!lm%Z%dd"l&m'Z'dd#l&m(Z(dd$l&m)Z)dd%l*m+Z+dd&l*m,Z,dd'l*m-Z-dd(l*m.Z.dd)l*m/Z/dd*l*m0Z0dd+l*m1Z1dd,l2m3Z3dd-l2m4Z4dd-l2m4Z5dd.l6m7Z7dd/l8m9Z9dd0l:m;Z;dd1l<m=Z=d2d3lm>Z>d2d4lm?Z?d2d5lm@Z@d2d6lAmBZBd2d7lCmDZDd2d8lEmFZFd2d9lGmHZHd2d:lImJZJd2d;l@mKZKd2d<l@mLZLd2d=l@mZMd2d>lNmOZOd2d?lNmPZPd2d@lNmQZQd2dAlNmRZRd2dBlNmSZSd2dClNmTZTerŠddDlUmVZVddElUmWZWddFl*mXZXddGlmYZYddHlmZZZdd1l<m=Z=d2dIl[m\Z\d2dJl]m^Z^edKedLZ_edMedLZ`eedNfZae
edNfZbedOee)e_eFe_ffZcdPdQdRœdSdT„ZdGdUdV„dVeeƒZfGdWdX„dXefe?jge7eƒZheMjie9e;e3e4e"e#e e$e!f    dYGdZd[„d[ehƒƒZjGd\d]„d]efe?jge7eƒZkd•d_dQd`daœdbdc„ZlGddde„deƒZmGdfdg„dgeme e_ƒZnGdhdi„diejoe_emƒZpGdjdk„dkepe_ƒZqdldldRœdmdn„ZrdodpdRœdqdr„ZsGdsdt„dtejduZtGdvdw„dwe?jge=eehduZudododpdxœdydz„ZvGd{d|„d|e?jge=eƒZwdPd_d}dpd~œdd€„Zxddeyddde.ekd‚œdƒd„dod_d…d†d‡dodˆd‰œ    dŠd‹„ZzGdŒd„dƒZ{e{Z|esže{ZWdˆdŽdœdd‘„Z}e? ~ekeueh¡dod’dRœd“d”„ƒZdS)–z1Public API functions and helpers for declarative.é)Ú annotationsN)ÚAny)ÚCallable)Úcast)Ú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©Ú_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)ÚCallableReference)Úflatten_newtype)Ú
is_generic)Ú
is_literal)Ú
is_newtype)ÚLiteral)Ú_O)Ú _RegistryType)Ú_DataclassArguments)Ú ClassManager)ÚMapperProperty)Ú_TypeEngineArgument)Ú_MatchedOnTypeÚ_T)ÚboundÚ_TTz_TypeEngineArgument[Any].úType[_O]Úbool©ÚclsÚreturncCs.|jdd…D]}t|ddƒdk    rdSqdS)aKGiven 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`
 
    rNÚ    __table__TF)Ú__mro__Úgetattr)rRÚclass_©rXúNd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/orm/decl_api.pyÚhas_inherited_tableis rZc@s.eZdZddddœdd„Zdddœdd    „Zd
S) Ú_DynamicAttributesTypeÚstrrÚNone)ÚkeyÚvaluerScCs*d|jkrt|||ƒnt |||¡dS©NÚ
__mapper__)Ú__dict__r%ÚtypeÚ __setattr__)rRr^r_rXrXrYrd}s
z"_DynamicAttributesType.__setattr__)r^rScCs&d|jkrt||ƒn t ||¡dSr`)rbr*rcÚ __delattr__©rRr^rXrXrYreƒs
 z"_DynamicAttributesType.__delattr__N)Ú__name__Ú
__module__Ú __qualname__rdrerXrXrXrYr[|sr[c@seZdZdZdS)ÚDeclarativeAttributeInterceptz™Metaclass that may be used in conjunction with the
    :class:`_orm.DeclarativeBase` class to support addition of class
    attributes dynamically.
 
    N©rgrhriÚ__doc__rXrXrXrYrjŠsrj©Zfield_specifiersc@seZdZdZdS)ÚDCTransformDeclarativez-metaclass that includes @dataclass_transformsNrkrXrXrXrYrn”srnc@s4eZdZUded<ded<ddddddœdd    „Zd
S) ÚDeclarativeMetar:ÚmetadataÚ RegistryTypeÚregistryrr])Ú    classnameÚbasesÚdict_ÚkwrScKsp|j}t|ddƒ}|dkrB| dd¡}t|tƒs<t d¡‚n||_|j dd¡s\t|||ƒt     
||||¡dS)NÚ _sa_registryrrziDeclarative base class has no 'registry' attribute, or registry is not a sqlalchemy.orm.registry() objectÚ __abstract__F) rbrVÚgetÚ
isinstancerrr4ÚInvalidRequestErrorrwr&rcÚ__init__)rRrsrtrurvÚregrXrXrYr|«s  
ÿ zDeclarativeMeta.__init__N)rgrhriÚ__annotations__r|rXrXrXrYro¥s
roFr\z,Callable[[Callable[..., Any]], Synonym[Any]])ÚnameÚ
map_columnrScsdddœ‡‡fdd„ }|S)aDecorator 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.
 
    úCallable[..., Any]z Synonym[Any]©ÚfnrScstˆˆ|dS)N)r€Z
descriptor)Ú _orm_synonym)rƒ©r€rrXrYÚdecorateészsynonym_for.<locals>.decoraterX)rr€r†rXr…rYÚ synonym_forÅs$r‡c@s@eZdZdddddœdd„Zddœd    d
„Zd d d d œdd„ZdS)Ú_declared_attr_commonFrrP)rƒÚ    cascadingÚquietcCs.t|tƒr|j}||_||_||_|j|_dS©N)rzÚ classmethodÚ__func__ÚfgetZ
_cascadingZ_quietrl)Úselfrƒr‰rŠrXrXrYr|ðs
z_declared_attr_common.__init__zOptional[Type[Any]]©rScCst |j¡ d¡S)NrS)r6Zget_annotationsrŽry©rrXrXrYÚ_collect_return_annotationsz0_declared_attr_common._collect_return_annotationúOptional[object]r©ÚinstanceÚownerrScCsœ|}t |¡}|dkrHt d|jj¡s>t d|jj|jf¡| |¡S|jrX| |¡S|     ¡}|dk    slt
‚|j }||kr‚||S| |¡||<}|SdS)Nz^__.+__$zEUnmanaged access of declarative attribute %s from non-mapped class %s) rZopt_manager_of_classÚreÚmatchrŽrgr6ÚwarnÚ    is_mappedÚdeclarative_scanÚAssertionErrorZdeclared_attr_reg)rr•r–rRÚmanagerr›r}ÚobjrXrXrYÚ__get__s&
 ÿÿ
 
 z_declared_attr_common.__get__N)FF)rgrhrir|r’rŸrXrXrXrYrˆïs
ürˆc@sheZdZejrdddddœdd„Zddd    d
œd d „Zddd dœdd„Zdd dœdd„Zdddœdd„Z    dS)Ú_declared_directiveFzCallable[..., _T]rP©rƒr‰cCsdSr‹rX©rrƒr‰rXrXrYr|5sz_declared_directive.__init__r“rrLr”cCsdSr‹rX©rr•r–rXrXrYrŸ<sz_declared_directive.__get__r]©r•r_rScCsdSr‹rX©rr•r_rXrXrYÚ__set__?sz_declared_directive.__set__©r•rScCsdSr‹rX©rr•rXrXrYÚ
__delete__Bsz_declared_directive.__delete__zCallable[..., _TT]z_declared_directive[_TT]r‚cCsdSr‹rX©rrƒrXrXrYÚ__call__Esz_declared_directive.__call__N)F)
rgrhrir>rr|rŸr¦r©r«rXrXrXrYr 0sýr c@sÀeZdZdZejr„d%dddœdd„Zddd    d
œd d „Zdd    d œdd„Ze    d    dddœdd„ƒZ
e    ddddœdd„ƒZ
ddddœdd„Z
e dddœdd„ƒZ e ddœd d!„ƒZe ddœd"d#„ƒZd$S)&Ú declared_attraMark 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`.
 
    Fú_DeclaredAttrDecorated[_T]rPr¡cCsdSr‹rXr¢rXrXrYr|¨szdeclared_attr.__init__rr]r¤cCsdSr‹rXr¥rXrXrYr¦¯szdeclared_attr.__set__r§cCsdSr‹rXr¨rXrXrYr©²szdeclared_attr.__delete__zInstrumentedAttribute[_T]r”cCsdSr‹rXr£rXrXrYrŸ¹szdeclared_attr.__get__ÚobjectrLcCsdSr‹rXr£rXrXrYrŸ¿sr“z$Union[InstrumentedAttribute[_T], _T]cCsdSr‹rXr£rXrXrYrŸÃsú_stateful_declared_attr[_T]©rvrScKs
tf|ŽSr‹)Ú_stateful_declared_attr)rRrvrXrXrYÚ    _statefulÈszdeclared_attr._statefulz_declared_directive[Any]rcCstSr‹)r ©rRrXrXrYÚ    directiveÌszdeclared_attr.directivecCs |jddS)NT)r‰)r²r³rXrXrYr‰Ñszdeclared_attr.cascadingN)F)rgrhrirlr>rr|r¦r©rrŸr<r²r=r´r‰rXrXrXrYr¬Js"[ýr¬c@sHeZdZUded<ddœdd„Zedddœd    d
„ƒZd d d œdd„ZdS)r±zDict[str, Any]rvr©rvcKs
||_dSr‹rµ©rrvrXrXrYr|Úsz _stateful_declared_attr.__init__r¯r°cKs|j ¡}| |¡tf|ŽSr‹)rvÚcopyÚupdater±)rrvZnew_kwrXrXrYr²Ýs
 
z!_stateful_declared_attr._statefulr­zdeclared_attr[_T]r‚cCst|f|jŽSr‹)r¬rvrªrXrXrYr«ãsz _stateful_declared_attr.__call__N)rgrhrir~r|r<r²r«rXrXrXrYr±×s
 
r±úType[_T]cCs|S)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>`
 
    rXr³rXrXrYÚdeclarative_mixinçs'rºú    Type[Any]r]cCsÂd|jkr|jd}nd}d|jkr0|jd}nd}|j dd¡}|dk    rtt|tƒs`t d¡‚q†|dk    r†t d¡‚nt||d}||_||_d|jkr |jj|_t|dt    j
ƒt    j
kr¾|jj |_
dS)NrpÚtype_annotation_maprrzfDeclarative 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.)rpr¼r|) rbryrzrrr4r{rwrprVr®r|Ú constructor)rRrpr¼r}rXrXrYÚ_setup_declarative_bases4
 
 
ÿÿÿ
 
r¾c sXeZdZdZejejejejejejejejfddddddddddœ    ‡fdd„ Z‡ZS)ÚMappedAsDataclassaMixin 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
 
    úUnion[_NoArg, bool]ú'Union[_NoArg, Callable[..., Type[Any]]]r])    ÚinitÚreprÚeqÚorderÚ unsafe_hashÚ
match_argsÚkw_onlyÚdataclass_callablerSc         s†||||||||dœ}    t|dƒrN|j‰t ˆ¡‡fdd„|     ¡Dƒ|_}
n
|    |_}
tƒ ¡t|ƒs‚t |¡} t     |
|| ¡dS)N©rÂrÃrÄrÅrÆrÇrÈrÉÚ_sa_apply_dc_transformscs.i|]&\}}||tjkr&ˆ |tj¡n|“qSrX)r8ÚNO_ARGry)Ú.0ÚkÚv©ÚcurrentrXrYÚ
<dictcomp>fsÿz7MappedAsDataclass.__init_subclass__.<locals>.<dictcomp>)
ÚhasattrrËr'Z_assert_dc_argumentsÚitemsÚsuperÚ__init_subclass__r"Z(_update_annotations_for_non_mapped_classZ_apply_dataclasses_to_any_class) rRrÂrÃrÄrÅrÆrÇrÈrÉZapply_dc_transformsZcurrent_transformsZnew_anno©Ú    __class__rÐrYrÖGs:ø
 
 
þþ
ÿþÿz#MappedAsDataclass.__init_subclass__)rgrhrirlr8rÌrÖÚ __classcell__rXrXr×rYr¿:sõr¿)Ú    metaclasscs„eZdZUdZejrjded<ded<ded<ded<d    ed
<d ed <d ed<d ed<d ed<d dœdd„Zddœ‡fdd„ Z‡Z    S)ÚDeclarativeBaseaÔ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__()``.
 
 
    úClassVar[_RegistryType]rwrrúClassVar[MetaData]rpz ClassVar[str]rgúClassVar[Mapper[Any]]razClassVar[FromClause]rTrÚ __tablename__Ú__mapper_args__Ú__table_args__rµcKsdSr‹rXr¶rXrXrYr|:szDeclarativeBase.__init__r]rcs<t|jkrt|tƒt|ƒnt|j||jƒtƒ ¡dSr‹)    rÛÚ    __bases__Ú_check_not_declarativer¾r&rwrbrÕrÖr³r×rXrYrÖ=s
 
 
 
z!DeclarativeBase.__init_subclass__)
rgrhrirlr>rr~r|rÖrÙrXrXr×rYrÛzs
o
     
 rÛ)rRÚbaserScCsR|j}d|kr(t|dƒs(t|ddƒr:t| dd¡tƒrNt d|j›d¡‚dS)NrTrŸrßz Cannot use zR directly as a declarative base class. Create a Base by creating a subclass of it.)    rbÚcallablerÓrzryr\r4r{rg)rRräZcls_dictrXrXrYrãFsÿ
ý üú ÿrãc@steZdZUdZded<ded<ded<ded<d    ed
<ejrbd ed <d ed <d ed<d dœdd„Zddœdd„ZdS)ÚDeclarativeBaseNoMetazõSame 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
 
 
    rÜrwrrrÝrprÞraúOptional[FromClause]rTrrßràrárµcKsdSr‹rXr¶rXrXrYr|«szDeclarativeBaseNoMeta.__init__r]rcCs.t|jkrt|tƒt|ƒn |j |¡dSr‹)rærârãr¾rwÚmap_declarativelyr³rXrXrYrÖ®s
 
 
z'DeclarativeBaseNoMeta.__init_subclass__N)    rgrhrirlr~r>rr|rÖrXrXrXrYræUs
 
     
 ræzMapperProperty[Any])Útargetr^ÚattrrScCst|||ƒdS)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$)rér^rêrXrXrYÚadd_mapped_attribute¶srëÚBase©rpÚmapperrRrÚclass_registryr¼r½rÚúOptional[MetaData]ú$Optional[Callable[..., Mapper[Any]]]ú&Optional[clsregistry._ClsRegistryType]ú Optional[_TypeAnnotationMapType]úCallable[(Ellipsis, None)]r)    rprîrRrrïr¼r½rÚrScCst||||dj||||dS)aConstruct 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`
 
    )rprïr½r¼)rîrRrrÚ)rrÚ generate_baserírXrXrYÚdeclarative_baseÉsnü÷röc@s~eZdZUdZded<ded<ded<ded    <d
ed <d ed <ded<ded<ded<dddedœdddddœdd„Zdddœdd„Zd d!d"œd#d$„Ze    d%d&œd'd(„ƒZ
d)dd*œd+d,„Z d-dd.œd/d0„Z e d1d2d3œd4d5„ƒZe d1d2d3œd6d7„ƒZd8d&œd9d:„Zd-dd;œd<d=„Zd>dd?œd@dA„ZdBddCœdDdE„ZdrdddGœdHdI„ZdsdddGœdJdK„ZdBddCœdLdM„ZdedNefdOdPdQdPdRdSœdTdU„Zejeeeee e!e"e#e$f    dVe%d>d>dWœdXdY„ƒƒZ&e%dtdZdZdZdZdZdZdZdZd[œd\d]d]d]d]d]d]d]d^d_d`œ
dadY„ƒZ&due'j(e'j(e'j(e'j(e'j(e'j(e'j(e'j(d[œdbd]d]d]d]d]d]d]d^dcd`œ
dddY„Z&d>d>d?œdedf„Z)dRdgdhœdidj„Z*d>dkd?œdldm„Z+dvd>dndRdkdoœdpdq„Z,dS)wrra°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.
 
    zclsregistry._ClsRegistryTypeÚ_class_registryz;weakref.WeakKeyDictionary[ClassManager[Any], Literal[True]]Ú    _managersz5weakref.WeakKeyDictionary[Mapper[Any], Literal[True]]Ú_non_primary_mappersr:rpz-CallableReference[Callable[(Ellipsis, None)]]r½Ú_MutableTypeAnnotationMapTyper¼zSet[_RegistryType]Ú _dependentsÚ _dependenciesrPÚ _new_mappersN)rprïr¼r½rðròrórôc    CsŽ|ptƒ}|dkrt ¡}||_t ¡|_t ¡|_||_||_i|_    |dk    rX| 
|¡t ƒ|_ t ƒ|_ d|_tjdtj|<W5QRXdS)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ÚWeakValueDictionaryr÷ÚWeakKeyDictionaryrørùrpr½r¼Úupdate_type_annotation_mapÚsetrûrürýrZ_CONFIGURE_MUTEXZ_mapper_registries)rrprïr¼r½Z lcl_metadatarXrXrYr|os /
 
 
 
zregistry.__init__Ú_TypeAnnotationMapTyper])r¼rScCs|j dd„| ¡Dƒ¡dS)zQupdate the :paramref:`_orm.registry.type_annotation_map` with new
        values.cSs,i|]$\}}tj|dddD]
}||“qqS)T)Z include_unionZ discard_none)Ú compat_typingZ expand_unions)rÍÚtypZsqltypeZsub_typerXrXrYrÒ»sÿþz7registry.update_type_annotation_map.<locals>.<dictcomp>N)r¼r¸rÔ)rr¼rXrXrYr³s
þÿz#registry.update_type_annotation_maprKz"Optional[sqltypes.TypeEngine[Any]])Ú python_typerSc    CsØt|ƒr>t|ƒr,td|ƒ}||ft|ff}qx|j}||ff}n:t|ƒrZt|ƒ}||ff}ntd|ƒ}d}dd„|jDƒ}|D]V\}}|j     |¡}|dkr¢t
  |¡}|dk    r|t
  |¡}|  |||¡}|dk    r||Sq|dS)Nr»css|]}||fVqdSr‹rX)rÍÚptrXrXrYÚ    <genexpr>Üsz)registry._resolve_type.<locals>.<genexpr>)rArBrrDÚ
__origin__rCr@rUr¼ryr7Z _type_map_getZ to_instanceZ_resolve_for_python_type)    rrZpython_type_typeÚsearchZ    flattenedrZsql_typeZ sql_type_instZresolved_sql_typerXrXrYÚ _resolve_typeÄs8
þ  
 
 
ý
zregistry._resolve_typezFrozenSet[Mapper[Any]]rcCstdd„|jDƒƒ |j¡S)z9read only collection of all :class:`_orm.Mapper` objects.css|] }|jVqdSr‹)rî©rÍrrXrXrYrúsz#registry.mappers.<locals>.<genexpr>)Ú    frozensetrøÚunionrùr‘rXrXrYÚmappersösÿzregistry.mappersrq)rrrScCs(||kr dS|j |¡|j |¡dSr‹)rûÚaddrü)rrrrXrXrYÚ_set_depends_onþs zregistry._set_depends_onz Mapper[Any])rîrScCs,d|_|jrdS| |h¡D]
}d|_qdS©NT)Ú_ready_for_configurerýÚ_recurse_with_dependents)rrîr}rXrXrYÚ_flag_new_mappers
zregistry._flag_new_mapperzSet[RegistryType]zIterator[RegistryType])Ú
registriesrSccsP|}tƒ}|rL| ¡}| |¡| |j |¡¡|V| |j |¡¡q
dSr‹)rÚpoprr¸rûÚ
difference©rRrÚtodoÚdoner}rXrXrYr s
z!registry._recurse_with_dependentsccsP|}tƒ}|rL| ¡}| |¡| |j |¡¡|V| |j |¡¡q
dSr‹)rrrr¸rürrrXrXrYÚ_recurse_with_dependenciess
z#registry._recurse_with_dependencieszIterator[Mapper[Any]]cCs,t dd„t|jƒDƒdd„t|jƒDƒ¡S)Ncss*|]"}|jr|jjs|jjr|jVqdSr‹)ršrîÚ
configuredrr rXrXrYr5s
üz1registry._mappers_to_configure.<locals>.<genexpr>css|]}|js|jr|VqdSr‹)rr)rÍZnpmrXrXrYr<sþ)Ú    itertoolsÚchainÚlistrørùr‘rXrXrYÚ_mappers_to_configure3sþþøzregistry._mappers_to_configure)Ú    np_mapperrScCsd|j|<dSr)rù)rr"rXrXrYÚ_add_non_primary_mapperCsz registry._add_non_primary_mapperrOrQcCst |j||j¡dSr‹)rZ remove_classrgr÷©rrRrXrXrYÚ _dispose_clsFszregistry._dispose_clszClassManager[Any])rrScCs8d|j|<|jr t d|j¡‚|jdks.t‚||_dS)NTz1Class '%s' already has a primary mapper defined. )røršr4Ú ArgumentErrorrWrrrœ)rrrXrXrYÚ _add_managerIs
ÿÿzregistry._add_managerF)ÚcascaderScCstj|h|ddS)a]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
 
        ©r(N)rZ_configure_registries©rr(rXrXrYÚ    configureSs'zregistry.configurecCstj|h|ddS)a®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)rZ_dispose_registriesr*rXrXrYÚdispose|szregistry.disposecCs8d|jkr|j}| ¡|j}| |¡tj |¡dS)Nrî)rbrîZ_set_dispose_flagsrWr%rZ_instrumentation_factoryÚ
unregister)rrrîrWrXrXrYÚ_dispose_manager_and_mapper–s 
 
z$registry._dispose_manager_and_mapperrìrñr»r\r)rîrRrrÚrSc    Cs”|j}t|tƒ r|fp|}t||d}t|tƒr<|j|d<|jdk    rP|j|d<d|d<|rd||d<t|dƒrˆd    d
d    d œd d „}||d<||||ƒS)aÍ    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`
 
        )rrrprlNr|TrxZ__mapper_cls__Ú__class_getitem__r¹r\)rRr^rScSs|Sr‹rXrfrXrXrYr/ÿsz1registry.generate_base.<locals>.__class_getitem__)rprzÚtupleÚdictrcrlr½rÓ)    rrîrRrrÚrprtÚ
class_dictr/rXrXrYrõ sN 
 
 
 
 
zregistry.generate_baserm)Ú_registry__clsrScCsdSr‹rX)rr3rXrXrYÚmapped_as_dataclassszregistry.mapped_as_dataclass.rÊz Literal[None]rÀrÁzCallable[[Type[_O]], Type[_O]])
r3rÂrÃrÄrÅrÆrÇrÈrÉrSc
CsdSr‹rX)
rr3rÂrÃrÄrÅrÆrÇrÈrÉrXrXrYr4szOptional[Type[_O]]z/Union[Type[_O], Callable[[Type[_O]], Type[_O]]]c
s8dddœ‡‡‡‡‡‡‡‡‡f    dd„ }
|r0|
|ƒS|
SdS)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
 
 
        rOrQc    s*ˆˆˆˆˆˆˆˆdœ|_tˆ||jƒ|S)NrÊ)rËr&rbr³©    rÉrÄrÂrÈrÇrÅrÃrrÆrXrYr†Fsø
z.registry.mapped_as_dataclass.<locals>.decorateNrX) rr3rÂrÃrÄrÅrÆrÇrÈrÉr†rXr5rYr4(s$cCst|||jƒ|S)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&rbr$rXrXrYÚmappedYs%zregistry.mappedúCallable[[Type[_T]], Type[_T]]r°c sdddœ‡‡fdd„ }|S)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`.
 
        r¹rQcs|ˆd<|jˆd<ˆjfˆŽS)NrRr)rgrõr³©rvrrXrYr†s
z.registry.as_declarative_base.<locals>.decoraterX)rrvr†rXr8rYÚas_declarative_baseszregistry.as_declarative_basez
Mapper[_O]cCst|||jƒ|jS)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&rbrar$rXrXrYrè¤s-zregistry.map_declarativelyrç)rWÚ local_tablervrScKst||||ƒS)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rWr:rvrXrXrYÚmap_imperativelyÔs6zregistry.map_imperatively)F)F).)N)N)-rgrhrirlr~r(r|rr ÚpropertyrrrrŒrrr!r#r%r'r+r,r.r®rorõrÚdataclass_transformr0r1r-r.rrrrrrr4r8rÌr6r9rèr;rXrXrXrYrrDsž
 úD2
) ûg÷ÿ þõ&þó$1(#3ýrrr7r°cKs.| dd¡| dd¡}}t||djf|ŽS)a¢
    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`
 
    rpNrï)rprï)rrrr9)rvrprïrXrXrYÚas_declaratives
 
þÿþr>zOptional[Mapper[Any]]cCs(t|ƒ}|dkr$t |¡r$t |¡|Sr‹)r!r)Zhas_clsZraise_unmapped_for_cls)rRÚmprXrXrYÚ_inspect_decl_meta:s
 
 
r@)F)€rlÚ
__future__rrr—r>rrrrrrr    r
r r r rrrrrrrrþÚrrrrrZ_orm_constructorsrrrrrr rär!r"r#Z    decl_baser%r&r'r(r)r*r,Zdescriptor_propsr-r.r„rîr/Z
propertiesr0Z relationshipsr1Ústater2r4r5r6Zsqlr7Zsql.baser8Z sql.elementsr9Z
sql.schemar:Zsql.selectabler;r<r=rZ util.typingr?r@rArBrCrDÚ_typingrErFrGrHrIZ sql._typingrJZ sql.type_apirKrLrNrrúZ_DeclaredAttrDecoratedrZrcr[Z Inspectablerjr=rnror‡rˆr Z_MappedAttributer¬r±rºr¾r¿rÛrãrærër®rörrrqr>Z    _inspectsr@rXrXrXrYÚ<module>s,                                                                            ÿ
 ÿ
÷ÿ 
 ÿ!ÿ*A*)@
 þMa÷"{N&ÿ