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
U
¸ý°dGã@s>UdZddlmZddlZddlmZddlmZddlmZddlmZddlmZdd    lm    Z    dd
lm
Z
dd lm Z dd lm Z dd lm Z ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZer4ddlmZddlmZe    e efZ!ej"Z#de$d<Gdd „d eƒZ%Gd!d"„d"e%ƒZ&Gd#d$„d$e&ƒZ'Gd%d&„d&e%ƒZ(iZ)d'e$d(<ed)d d*Z*dFd)d,d-d.d.d)d/œd0d1„Z+e dGd2d3d2d4œd5d6„ƒZ,e dHd)d3d)d4œd7d6„ƒZ,dId8d3d8d4œd9d6„Z,d)d,d)d:œd;d<„Z-d=d>d>d?œd@dA„Z.d=d>dBdCœdDdE„Z/dS)Ja*The :class:`.Annotated` class and related routines; creates hash-equivalent
copies of SQL constructs which contain context-specific markers and
associations.
 
Note that the :class:`.Annotated` concept as implemented in this module is not
related in any way to the pep-593 concept of "Annotated".
 
 
é)Ú annotationsN)ÚAny)ÚCallable)Úcast)ÚDict)Ú    FrozenSet)ÚMapping)ÚOptional)Úoverload)ÚSequence)ÚTuple)ÚType)Ú TYPE_CHECKING)ÚTypeVaré)Ú    operators)Ú HasCacheKey©Úanon_map)ÚExternallyTraversible)ÚInternalTraversalé)Úutil)ÚLiteral)ÚSelf)Ú_EntityNamespace)Ú_TraverseInternalsTypeúutil.immutabledict[str, Any]ÚEMPTY_ANNOTATIONSc@s¦eZdZUdZeZded<ded<ded<dd    d
œd d „Zed ddd    dœdd„ƒZ    ed!ddddœdd„ƒZ    d"ddddœdd„Z    e
j ddœdd„ƒZ dddœdd„Z dS)#ÚSupportsAnnotations©rÚ _annotationsz*util.generic_fn_descriptor[FrozenSet[Any]]Ú    proxy_setÚboolÚ _is_immutableÚ_AnnotationDictr©ÚvaluesÚreturncCs
tƒ‚dS©N©ÚNotImplementedError©Úselfr'r r úPd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/sql/annotation.pyÚ    _annotate>szSupportsAnnotations._annotate.ú Literal[None]©r'Úcloner(cCsdSr)r ©r-r'r2r r r.Ú _deannotateAszSupportsAnnotations._deannotateú Sequence[str]cCsdSr)r r3r r r.r4IsNFúOptional[Sequence[str]]cCs
tƒ‚dSr)r*r3r r r.r4QszTuple[Any, ...]©r(cCstƒ}| |¡Sr))rÚ_gen_annotations_cache_key)r-Z    anon_map_r r r.Ú_annotations_cache_keyXsz*SupportsAnnotations._annotations_cache_keyr)rr(cs.dt‡fdd„‡fdd„tˆjƒDƒDƒƒfS)Nr!c3s0|](\}}|t|tƒr"| ˆg¡n|fVqdSr))Ú
isinstancerZ_gen_cache_key©Ú.0ÚkeyÚvaluerr r.Ú    <genexpr>cs ûÿüzASupportsAnnotations._gen_annotations_cache_key.<locals>.<genexpr>csg|]}|ˆj|f‘qSr )r!)r<r=©r-r r.Ú
<listcomp>jsÿzBSupportsAnnotations._gen_annotations_cache_key.<locals>.<listcomp>)ÚtupleÚsortedr!)r-rr )rr-r.r8^s 
þùþz.SupportsAnnotations._gen_annotations_cache_key)..)..)NF)Ú__name__Ú
__module__Ú __qualname__Ú    __slots__rr!Ú__annotations__r/r
r4rZmemoized_propertyr9r8r r r r.r5s&
 ýý    ýrc@s–eZdZUdZded<er.ejddœdd„ƒZdd    d
œd d „Z    dd    d
œd d„Z
e dddd    dœdd„ƒZ e dddddœdd„ƒZ dddddœdd„Z dS)ÚSupportsWrappingAnnotationsr z*Callable[..., SupportsWrappingAnnotations]Ú _constructorrr7cCsdSr)r r@r r r.Úentity_namespaceysz,SupportsWrappingAnnotations.entity_namespacer%rr&cCs t ||¡S)úgreturn a copy of this ClauseElement with annotations
        updated by the given dictionary.
 
        ©Ú    AnnotatedÚ_as_annotated_instancer,r r r.r/}sz%SupportsWrappingAnnotations._annotatecCs t ||¡S)úhreturn a copy of this ClauseElement with annotations
        replaced by the given dictionary.
 
        rMr,r r r.Ú_with_annotations„sz-SupportsWrappingAnnotations._with_annotations.r0r#r1cCsdSr)r r3r r r.r4‹sz'SupportsWrappingAnnotations._deannotater5rcCsdSr)r r3r r r.r4“sNFr6cCs|r| ¡}|S|SdS)ú¼return a copy of this :class:`_expression.ClauseElement`
        with annotations
        removed.
 
        :param values: optional tuple of individual values
         to remove.
 
        N)Ú_clone)r-r'r2Úsr r r.r4›s )..)..)NF) rDrErFrGrHrrÚro_non_memoized_propertyrKr/rQr
r4r r r r.rIrs$
ýý    ýrIc@seZdZUejsdZdejfgZde    d<dddœdd    „Z
dddœd
d „Z e dd dddœdd„ƒZ e dddddœdd„ƒZ dddddœdd„Z dS)ÚSupportsCloneAnnotationsr r!rÚ%_clone_annotations_traverse_internalsr%rr&cCs6| ¡}|j |¡|_|j dd¡|j dd¡|S)rLr9NÚ_generate_cache_key)rSr!ÚunionÚ__dict__Úpop©r-r'Únewr r r.r/¾s
z"SupportsCloneAnnotations._annotatecCs4| ¡}t |¡|_|j dd¡|j dd¡|S)rPr9NrX)rSrÚ immutabledictr!rZr[r\r r r.rQÉs
 z*SupportsCloneAnnotations._with_annotations.r0r#r1cCsdSr)r r3r r r.r4Ôsz$SupportsCloneAnnotations._deannotater5rcCsdSr)r r3r r r.r4ÜsNFr6cCs6|s
|jr.| ¡}t ¡|_|j dd¡|S|SdS)rRr9N)r!rSrr^rZr[)r-r'r2r]r r r.r4äs
 
)..)..)NF)rDrErFÚtypingrrGrÚdp_annotations_keyrWrHr/rQr
r4r r r r.rV¯s"
ÿ   ýý    ýrVc@s>eZdZUdZdZeddddœdd„ƒZded    <ded
<d ed <d dddœdd„Zdddœdd„Z    dddœdd„Z
dddœdd„Z e d<ddddœdd „ƒZ e d=d!dddœd"d „ƒZ d>d%dd&dœd'd „Z ejsêdddd(œd)d*„Zed+d,„ƒZddd-œd.d/„Zd0d1œd2d3„Zd d1œd4d5„Zddd6œd7d8„Zejd9d1œd:d;„ƒZd#S)?rNaJclones a SupportsAnnotations and applies an 'annotations' dictionary.
 
    Unlike regular clones, this clone also mimics __hash__() and
    __eq__() of the original element so that it takes its place
    in hashed collections.
 
    A reference to the original element is maintained, for the important
    reason of keeping its hash value current.  When GC'ed, the
    hash value may be reused, causing conflicts.
 
    .. note::  The rationale for Annotated producing a brand new class,
       rather than placing the functionality directly within ClauseElement,
       is **performance**.  The __hash__() method is absent on plain
       ClauseElement which leads to significantly reduced function call
       overhead, as the use of sets and dictionaries against ClauseElement
       objects is prevalent, but most are not "annotated".
 
    FrIr%©Úelementr'r(cCs:zt|j}Wn tk
r.t|j|ƒ}YnX|||ƒSr))Úannotated_classesÚ    __class__ÚKeyErrorÚ_new_annotation_type)Úclsrbr'r r r.rOs
z Annotated._as_annotated_instancerr!Ú_Annotated__elementÚintÚ_hashz
Type[Self]rr)rgÚargsr(cGs
t |¡Sr))ÚobjectÚ__new__)rgrkr r r.rm szAnnotated.__new__©rbr'cCsH|j ¡|_|j dd¡|j dd¡||_t |¡|_t|ƒ|_dS©Nr9rX)    rZÚcopyr[rhrr^r!Úhashrj)r-rbr'r r r.Ú__init__#s   zAnnotated.__init__r&cCs|j |¡}| |¡}|Sr))r!rYrQ)r-r'Z_valuesr]r r r.r/-s 
zAnnotated._annotatecCsF|j |j¡}|j ¡|_|j dd¡|j dd¡t |¡|_|Sro)rdrmrZrpr[rr^r!r3r r r.rQ2s   zAnnotated._with_annotations.r0r#r1cCsdSr)r r3r r r.r4:szAnnotated._deannotater5cCsdSr)r r3r r r.r4BsNTr6rcs6ˆdkr|jS| t ‡fdd„|j ¡Dƒ¡¡SdS)Ncsi|]\}}|ˆkr||“qSr r r;©r'r r.Ú
<dictcomp>Tsþz)Annotated._deannotate.<locals>.<dictcomp>)rhrQrr^r!Úitemsr3r rsr.r4Js
þÿÿ)ÚvisitorÚkwr(cKs|jjj||f|ŽSr))rhrdÚ_compiler_dispatch)r-rvrwr r r.rx^s ÿÿzAnnotated._compiler_dispatchcCs|jjSr))rhrJr@r r r.rJcszAnnotated._constructor)rwr(cKs<|jjf|Ž}||jkr|S|j |j¡| ||j¡SdSr))rhrSrZÚupdaterdr!)r-rwr2r r r.rSgs
 
zAnnotated._clonez'Tuple[Type[Annotated], Tuple[Any, ...]]r7cCs|j|j|jffSr))rdrhr!r@r r r.Ú
__reduce__rszAnnotated.__reduce__cCs|jSr))rjr@r r r.Ú__hash__uszAnnotated.__hash__)Úotherr(cCs*|jr|jj ||¡St|ƒt|ƒkSdSr))Ú_is_column_operatorsrhrdÚ__eq__rq)r-r|r r r.r~xszAnnotated.__eq__rcCs(d|jkrtt|jdƒjS|jjSdS)NrK)r!rrIrKrhr@r r r.rK~s 
þzAnnotated.entity_namespace)..)..)NT)rDrErFÚ__doc__r}Ú classmethodrOrHrmrrr/rQr
r4r_rrxÚpropertyrJrSrzr{r~rrUrKr r r r.rNüs@
    
ýý    ý
 rNz8Dict[Type[SupportsWrappingAnnotations], Type[Annotated]]rcÚ_SA)ÚboundFr%z'Optional[Sequence[SupportsAnnotations]]r#)rbrÚexcludeÚdetect_subquery_colsÚind_cols_on_fromclauser(csBi‰ddddœ‡‡‡‡‡‡fdd„ ‰|dk    r:ttˆ|ƒƒ}d‰|S)z¹Deep copy the given ClauseElement, annotating each element
    with the given annotations dictionary.
 
    Elements within the exclude collection will be cloned but not annotated.
 
    rr©Úelemrwr(csªˆ|d<t|ƒ}|ˆkr ˆ|SˆrPt|dƒrP|j ˆ¡rP|jfdˆi|—Ž}n@ˆ|jkrŒˆr€|jr€|jfdˆi|—Ž ˆ¡}q| ˆ¡}n|}|jˆˆd|ˆ|<|S)Nr…r"r2)r2r†)    ÚidÚhasattrr"Ú intersectionrSr!r$r/Ú_copy_internals)rˆrwZid_Únewelem©rr2Z
cloned_idsr…r„r†r r.r2¨s, ÿþ
ý
 
 ÿz_deep_annotate.<locals>.cloneN©rr‚)rbrr„r…r†r rŽr.Ú_deep_annotate•s  &rr0r6racCsdSr)r rnr r r.Ú_deep_deannotateÔsr‘cCsdSr)r rnr r r.r‘Ûsz Optional[_SA]cs<i‰ddddœ‡‡‡fdd„ ‰|dk    r4ttˆ|ƒƒ}d‰|S)z2Deep copy the given element, removing annotations.rrr‡csLˆrt|ƒ}n|}|ˆkr@|jˆdd}|jˆd|ˆ|<|Sˆ|SdS)NT)r'r2)r2)r‰r4rŒ)rˆrwr=r©r2Zclonedr'r r.r2és
 z_deep_deannotate.<locals>.cloneNrrnr r’r.r‘âs )rbrr(cCs| |¡}| ¡|S)a Annotate the given ClauseElement and copy its internals so that
    internal objects refer to the new annotated object.
 
    Basically used to apply a "don't traverse" annotation to a
    selectable, without digging throughout the whole
    structure wasting time.
    )r/rŒ)rbrr r r.Ú_shallow_annotateþs
r“z!Type[SupportsWrappingAnnotations]zType[Annotated])rgÚbase_clsr(cCsþt|tƒr|S|tkrt|S|jD]}|tkr$t|}q>q$ttttd|j||fiƒƒt|<}|tƒd|j<d|j    kršt
|j ƒdt j fg|_ n&|j     dd¡rÀt
|j ƒdt j fg|_ |j     dd¡rÖd|_nd|j    krì|j    d|_t|tjƒ|_|S)z[Generates a new class that subclasses Annotated and proxies a given
    element type.
 
    z Annotated%sÚ_traverse_internalsr!Ú inherit_cacheFT)Ú
issubclassrNrcÚ__mro__rr ÚtyperDÚglobalsrZÚlistr•rr`Úgetr–rZColumnOperatorsr})rgr”Zsuper_Zanno_clsr r r.rf s6
 
þ 
ÿ
ÿ
 rfÚNone)Útarget_hierarchyr”r(cCst |¡D]}t||ƒq
dSr))rZwalk_subclassesrf)ržr”rgr r r.Ú_prepare_annotations:srŸ)NFF)N)N)N)0rÚ
__future__rr_rrrrrrr    r
r r r rrÚrÚ    cache_keyrZvisitorsrrrrZ util.typingrrÚbaserrÚstrr%Ú
EMPTY_DICTrrHrrIrVrNrcr‚rr‘r“rfrŸr r r r.Ú<module>sf
                        ==Mþ
 û?ÿÿÿ /