zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
¸ý°dQ?ã
@sddlmZddlZddlZddlZddlmZddlmZddlmZddlmZddlm    Z    ddlm
Z
dd    lm Z dd
lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"dd lm#Z#dd!lm$Z$dd"lm%Z%dd#lm&Z&dd$lm'Z'dd%lm(Z(dd&lm)Z)ed'ed(Z*ed)ƒZ+ed*d+d,Z,ed-d+d.Z-ed/ƒZ.ed0d+d,Z/ej0rdd1l1m2Z2ne3dƒZ2e    d2ƒZ4eZ5e Z6eeee7e    e d3fZ8Gd4d5„d5e$ƒZ9Gd6d7„d7e$e*ƒZ:Gd8d9„d9e$e+e/fƒZ;e!d:Z<dd;dd<œd=d>d?d@dAdBdCd=dDœdEdF„Z=dGdHdIdJœdKdL„Z>ddMœd?d?dNdOdPœdQdR„Z?ddMœd?d?dNdOdSœdTdU„Z@d?d?d?dVœdWdX„ZAddYœd=d5d?d@dAd=dZœd[d\„ZBd]dBd^œd_d`„ZCd>dBd^œdadb„ZDd]dcd^œddde„ZEd>dfd^œdgdh„ZFdid=d^œdjdk„ZGdžd>dBdldmœdndo„ZHed?d?d^œdpdq„ƒZIed=d=d^œdrdq„ƒZIed>d>d^œdsdq„ƒZId>d>d^œdtdq„ZIdud>d^œdvdw„ZJd>d=dxœdydz„ZKdŸd=dBdBd{d|œd}d~„ZLdOdd^œd€d„ZMdOdBd^œd‚dƒ„ZNdOdd^œd„d…„ZOdOd†dBd‡œdˆd‰„ZPddŠœdOd?d‹dBdŒœddŽ„ZQd=d?d^œdd„ZRGd‘d’„d’e$ƒZSed“eSd(ZTGd”d•„d•e
eTƒZUed–eSd+d—ZVGd˜d™„d™e
eVƒZWedšeed›efd(ZXGdœd„de
eXƒZYdS) é)Ú annotationsN)ÚAny)ÚCallable)Úcast)ÚDict©Ú
ForwardRef)ÚGeneric)ÚIterable)ÚMapping)ÚNewType)ÚNoReturn)ÚOptional)Úoverload)ÚSet)ÚTuple)ÚType)Ú TYPE_CHECKING)ÚTypeVar)ÚUnioné)Úcompat)Ú    Annotated)Ú Concatenate)Údataclass_transform)ÚFinal)Úfinal)Úget_args)Ú
get_origin)ÚLiteral)Ú NotRequired)Ú    ParamSpec)ÚProtocol)Ú SupportsIndex)Ú    TypeAlias)Ú    TypedDict)Ú    TypeGuard)ÚSelfÚ_T)ÚboundÚ_KTÚ_KT_coT)Ú    covariantÚ
_KT_contra)Ú contravariantÚ_VTÚ_VT_co)ÚNoneTypeÚNonezGenericProtocol[Any]c@seZdZUdZded<dS)ÚArgsTypeProcotolz_protocol for types that have ``__args__``
 
    there's no public interface for this AFAIK
 
    úTuple[_AnnotationScanType, ...]Ú__args__N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú__annotations__©r<r<úMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/util/typing.pyr3Rs
r3c@s"eZdZUdZded<ded<dS)ÚGenericProtocolzXprotocol for generic types.
 
    this since Python.typing _GenericAlias is private
 
    r4r5úType[_T]Ú
__origin__Nr6r<r<r<r=r>\s
r>c@s*eZdZddœdd„Zdddœdd    „Zd
S) ÚSupportsKeysAndGetItemz Iterable[_KT])ÚreturncCsdS©Nr<)Úselfr<r<r=ÚkeysqszSupportsKeysAndGetItem.keysr*r0)Ú_SupportsKeysAndGetItem__krBcCsdSrCr<)rDrFr<r<r=Ú __getitem__tsz"SupportsKeysAndGetItem.__getitem__N)r7r8r9rErGr<r<r<r=rApsrAÚ*F©Ústr_cleanup_fnÚinclude_genericÚ _already_seenz    Type[Any]Ú_AnnotationScanTypeÚstrzMapping[str, Any]z#Optional[Callable[[str, str], str]]ÚboolzOptional[Set[Any]])ÚclsÚ
annotationÚoriginating_moduleÚlocals_rJrKrLrBc    s |}t|ƒr|j}t|tƒr8ˆr*ˆ|ˆƒ}t|ˆˆd}ˆrœt|ƒrœt|ƒsœˆdkrZtƒ‰|ˆkrf|Sˆ |¡t    ‡‡‡‡‡‡fdd„|j
Dƒƒ}t ||ƒS|S)a;Resolve annotations that may be string based into real objects.
 
    This is particularly important if a module defines "from __future__ import
    annotations", as everything inside of __annotations__ is a string. We want
    to at least have generic containers like ``Mapped``, ``Union``, ``List``,
    etc.
 
    ©rSNc
3s$|]}tˆ|ˆˆˆˆˆdVqdS)rIN©Úde_stringify_annotation©Ú.0Úelem©rLrPrKrSrRrJr<r=Ú    <genexpr>²s
÷ùz*de_stringify_annotation.<locals>.<genexpr>) Ú
is_fwd_refÚ__forward_arg__Ú
isinstancerNÚeval_expressionÚ
is_genericÚ
is_literalÚsetÚaddÚtupler5Ú_copy_generic_annotation_with)    rPrQrRrSrJrKrLZoriginal_annotationÚelementsr<rZr=rV|s6
 
ÿÿþý
 
ö
rVzGenericProtocol[_T]r4r?)rQrfrBcCs"t|dƒr| |¡S|j|SdS)NÚ    copy_with)Úhasattrrgr@)rQrfr<r<r=reÃs
 
rerTzOptional[Mapping[str, Any]]r)Ú
expressionÚ module_namerSrBc
Cs–ztj|j}Wn8tk
rH}ztd|›d|›ƒ|‚W5d}~XYnXzt|||ƒ}Wn2tk
rŒ}ztd|›ƒ|‚W5d}~XYnX|SdS)NúModule z9 isn't present in sys.modules; can't evaluate expression z"Could not de-stringify annotation )ÚsysÚmodulesÚ__dict__ÚKeyErrorÚ    NameErrorÚevalÚ    Exception)rirjrSÚ base_globalsÚkerQÚerrr<r<r=r_Îs"ÿýÿþr_)ÚnamerjrSrBc
Cs¨d|krt|||dSztj|j}Wn8tk
r^}ztd|›d|›ƒ|‚W5d}~XYnXz
||WStk
r¢}ztd|›d|›ƒ|‚W5d}~XYnXdS)NÚ.rTrkz2 isn't present in sys.modules; can't resolve name zCould not locate name z  in module )r_rlrmrnrorp)rvrjrSrsrtr<r<r=Úeval_name_onlyæs$ÿý
ÿþrx)rvrjrBcCs8zt||ƒ}Wntk
r&|YSXt|d|ƒSdS)Nr7)rxrpÚgetattr)rvrjÚobjr<r<r=Úresolve_name_to_real_class_names
 
r{©rJ)rPrQrRrSrJrBcst‡‡‡fdd„|jDƒŽS)Nc    sg|]}tˆ|ˆiˆd‘qS)r|rU)rXÚanno©rPrRrJr<r=Ú
<listcomp>sùûz/de_stringify_union_elements.<locals>.<listcomp>)Úmake_union_typer5)rPrQrRrSrJr<r~r=Úde_stringify_union_elements s
øÿrzOptional[_AnnotationScanType])Útype_rBcCs|dk    ot|ƒtkSrC)Útyping_get_originr©r‚r<r<r=Ú    is_pep593!sr…cCs t|ƒtkSrC)rrr„r<r<r=ra%srazTypeGuard[NewType]cCs
t|dƒS)NÚ __supertype__©rhr„r<r<r=Ú
is_newtype)srˆzTypeGuard[GenericProtocol[Any]]cCst|dƒot|dƒS)Nr5r@r‡r„r<r<r=r`1sr`r cCs|j}t|ƒr|j}q|SrC)r†rˆ)r‚Z
super_typer<r<r=Úflatten_newtype5sr‰zTypeGuard[ForwardRef])r‚Ú check_genericrBcCs6t|tƒrdS|r.t|ƒr.tdd„|jDƒƒSdSdS)NTcss|]}t|dƒVqdS)TN)r\)rXÚargr<r<r=r[Bszis_fwd_ref.<locals>.<genexpr>F)r^rr`Úanyr5)r‚rŠr<r<r=r\<s
 
 r\cCsdSrCr<r„r<r<r=Úde_optionalize_union_typesGsrcCsdSrCr<r„r<r<r=rLscCsdSrCr<r„r<r<r=rQscCsFt|ƒrt|ƒSt|ƒr>t|jƒ}| t¡| t¡t|ŽS|SdS)zmGiven a type, filter out ``Union`` types that include ``NoneType``
    to not include the ``NoneType``.
 
    N)    r\Ú"de_optionalize_fwd_ref_union_typesÚ is_optionalrbr5Údiscardr1ÚNoneFwdr€)r‚Útypr<r<r=rXs
 
 
rcCs˜|j}t d|¡}|rh| d¡dkr2t| d¡ƒS| d¡dkrdt d| d¡¡}tdd„|DƒŽS|St d    |¡}d
|kr”td  d d „|Dƒ¡ƒS|S)zÁreturn the non-optional type for Optional[], Union[None, ...], x|None,
    etc. without de-stringifying forward refs.
 
    unfortunately this seems to require lots of hardcoded heuristics
 
    z^(.+?)\[(.+)\]$rrérz,\s*cSsg|]}|dkrt|ƒ‘qS)r2rrWr<r<r=r‚sz6de_optionalize_fwd_ref_union_types.<locals>.<listcomp>z\s*\|\s*r2ú|css|]}|dkr|VqdS)r2Nr<)rXÚpr<r<r=r[‰sz5de_optionalize_fwd_ref_union_types.<locals>.<genexpr>)r]ÚreÚmatchÚgrouprÚsplitr€Újoin)r‚rQÚmmrfZ pipe_tokensr<r<r=rŽos
  ÿ rŽ)ÚtypesrBcGstttƒ |¡S)z„Make a Union type.
 
    This is needed by :func:`.de_optionalize_union_types` which removes
    ``NoneType`` from a ``Union``.
 
    )rrrrG)rœr<r<r=r€Žsr€zTuple[Type[Any], ...])r‚Ú include_unionÚ discard_nonerBcCsFt|ƒr<t|jƒ}|r | t¡|r2|ft|ƒSt|ƒSn|fSdS)zPReturn a type as a tuple of individual types, expanding for
    ``Union`` types.N)Úis_unionrbr5rr1rd)r‚rržr’r<r<r=Ú expand_unions˜s
 
 
r zTypeGuard[ArgsTypeProcotol]cCst|dddƒS)NrrZ    UnionType©Ú is_origin_ofr„r<r<r=r¬s ürcCst|ƒott|ƒkSrC)rr1Útyping_get_argsr„r<r<r=Úis_optional_unionµsr¤cCs
t|dƒS)Nrr¡r„r<r<r=rŸ¹srŸz'Union[Tuple[Type[Any], ...], Type[Any]])r‚Ú    class_objrBcCs(t|ƒ}|dkrdSt|tƒo&t||ƒS)z[return True if the given type has an __origin__ that shares a base
    with the given classNF)rƒr^ÚtypeÚ
issubclass)r‚r¥Úoriginr<r<r=Úis_origin_of_cls½sr©)Úmodulez Optional[str])r‚ÚnamesrªrBcGs4t|ƒ}|dkrdSt|ƒ|ko2|dkp2|j |¡S)z\return True if the given type has an __origin__ with the given name
    and optional module.NF)rƒÚ_get_type_namer8Ú
startswith)r‚rªr«r¨r<r<r=r¢Ês  ÿr¢cCs4tjr |jSt|ddƒ}|dkr,t|ddƒ}|SdS)Nr7Ú_name)rÚpy310r7ry)r‚Ztyp_namer<r<r=r¬Ùs   r¬c@s@eZdZddddœdd„Zddddœdd    „Zddd
œd d „Zd S)ÚDescriptorProtoÚobjectr©ÚinstanceÚownerrBcCsdSrCr<©rDr³r´r<r<r=Ú__get__åszDescriptorProto.__get__r2©r³ÚvaluerBcCsdSrCr<©rDr³r¸r<r<r=Ú__set__èszDescriptorProto.__set__©r³rBcCsdSrCr<©rDr³r<r<r=Ú
__delete__ëszDescriptorProto.__delete__N)r7r8r9r¶rºr½r<r<r<r=r°äsr°Ú_DESCc@sHeZdZdZerDddddœdd„Zdddd    œd
d „Zddd œd d„ZdS)ÚDescriptorReferenceaŠa descriptor that refers to a descriptor.
 
    used for cases where we need to have an instance variable referring to an
    object that is itself a descriptor, which typically confuses typing tools
    as they don't know when they should use ``__get__`` or not when referring
    to the descriptor assignment as an instance variable. See
    sqlalchemy.orm.interfaces.PropComparator.prop
 
    r±rr¾r²cCsdSrCr<rµr<r<r=r¶ÿszDescriptorReference.__get__r2r·cCsdSrCr<r¹r<r<r=rºszDescriptorReference.__set__r»cCsdSrCr<r¼r<r<r=r½szDescriptorReference.__delete__N©r7r8r9r:rr¶rºr½r<r<r<r=r¿òs
 
r¿Ú_DESC_co)r)r,c@sHeZdZdZerDddddœdd„Zdddd    œd
d „Zddd œd d„ZdS)ÚRODescriptorReferencez½a descriptor that refers to a descriptor.
 
    same as :class:`.DescriptorReference` but is read-only, so that subclasses
    can define a subtype as the generically contained element
 
    r±rrÁr²cCsdSrCr<rµr<r<r=r¶szRODescriptorReference.__get__r r·cCsdSrCr<r¹r<r<r=rºszRODescriptorReference.__set__r»cCsdSrCr<r¼r<r<r=r½sz RODescriptorReference.__delete__NrÀr<r<r<r=r s
rÂÚ_FN.c@sHeZdZdZerDddddœdd„Zdddd    œd
d „Zddd œd d„ZdS)ÚCallableReferenceza descriptor that refers to a callable.
 
    works around mypy's limitation of not allowing callables assigned
    as instance variables
 
 
    r±rrÃr²cCsdSrCr<rµr<r<r=r¶.szCallableReference.__get__r2r·cCsdSrCr<r¹r<r<r=rº1szCallableReference.__set__r»cCsdSrCr<r¼r<r<r=r½4szCallableReference.__delete__NrÀr<r<r<r=rÄ#s
rÄ)F)FF)ZÚ
__future__rr–rlÚtypingrrrrrr    r
r r r rrrrrrrrÚrZtyping_extensionsrrrrrrrrr r!r"r#r$r%r&r'r(r*r+r-r/r0r¯rœr1r¦r‘r£rƒrNrMr3r>rAZ _LiteralStarrVrer_rxr{rr…rarˆr`r‰r\rrŽr€r rr¤rŸr©r¢r¬r°r¾r¿rÁrÂrÃrÄr<r<r<r=Ú<module>    sÌ                                        ÿ
        ø Güüúÿ  ÿ    ÿ