QfdZddlmZmZddlZddlmZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZmZmZmZddlmZmZmZmZmZmZmZmZgdZddd d Zddd d Zd Z dZ!dZ"dZ#dZ$dZ%dddZ&dZ'dZ(dZ)dZ*gZ+iZ,ddddZ-de.ddZ/GddZ0Gdd Z1Gd!d"e0e1d #Z2Gd$d%e2d #Z3Gd&d'e4Z5Gd(d)e5*Z6e2d+Z7e2d,Z8e2d-Z9e2d.Z:e2d/Z;e2d0Ze2d3Z?e3e-d d4Z@e2d5ZAe2d6ZBe2d7ZCGd8d9e0d #ZDd:e6d;eEfd<ZFd:e6d;eEfd=ZGGd>d?ZHd@ZIdAZJdBZKdCZLe-dDZMdEZNdFZOGdGdHe0d #ZPGdIdJePd #ZQGdKdLe1ePd #ZRGdMdNeRd #ZSGdOdPe1eQd #ZTGdQdReRd #ZUGdSdTeRd #ZVGdUdVe1eQd #ZWdWZXGdXdYeQd #ZYGdZd[eQd #ZZe2d\Z[Gd]d^eQd #Z\Gd_d`Z]e.hdaZ^e.hdbZ_e^e_zdchzZ`ddZadeZbddgZcddiZdgdjdkdlgdmZee jdnZge+jegjdoZjejeejdpZlejeel[j[lGdqdreZmendsZoGdtdueem*ZpGdvdwe1eQd #ZqGdxdyZrdzZsd{Ztd|ZuejejejejeeefZzdd}Z{d~Z|dZ}dZ~dZdZde8d;e8fdZdZdZdZee j eeZdZdZdZdZedZedZedZedd Zedd Zedd Zedd Zedd e4ZedeeZeRZeejj0dZeejj2dfZeejj4dZeejj6dfZeejj8dfZeejj:dfZeejj<dfZeejj>dfZeejj@dZeejjBdfZeejjDdfZeUejjFdhZde_eejjHdfdZeejjLdfZeejjNdhZeejjPdhZeejjRdfZeejjTdfZeSejjVddZeVedddZde_eedfddZeej`dfdZeedfddZee.dfddZeejjhdfZeejjjdfZeejjldhZeejjndfZeejpdfdZeejtdfdZeedhddZeej dhdZeej|dhZeej~dfZeejdhZeejjdZeejjdhZee4dfddZde_esGddepZesGddepZesGddepZesGddepZesGddepZesdZesdZddZe.hdZe.hdZGdde4ZddZe4jeddiZdZee_Gdde4Zdd dÜdĄZe4jeddiZdƄe_e2dDŽZe2dȄZGdɄdʫZeZdZGd˄deeZGd̈́deeZGdτdeeZGdфde4ZGdӄde߬*Zedze_ee jej<ee jdfZee jdfZGdքde߬*Z edze _e e je j<dلZGdڄdepZd dddddܜdeEdeEdeEdeEdee4e6ede6fzdfde6d;efdZdddf ZdZy)a The typing module: Support for gradual typing as defined by PEP 484 and subsequent PEPs. Among other things, the module includes the following: * Generic, Protocol, and internal machinery to support generic aliases. All subscripted types like X[int], Union[int, str] are generic aliases. * Various "special forms" that have unique meanings in type annotations: NoReturn, Never, ClassVar, Self, Concatenate, Unpack, and others. * Classes whose instances can be type arguments to generic classes and functions: TypeVar, ParamSpec, TypeVarTuple. * Public helper functions: get_type_hints, overload, cast, final, and others. * Several protocols to support duck-typing: SupportsFloat, SupportsIndex, SupportsAbs, and others. * Special types: NewType, NamedTuple, TypedDict. * Deprecated wrapper submodules for re and io related types. * Deprecated aliases for builtin types and collections.abc ABCs. Any name not present in __all__ is an implementation detail that may be changed without notice. Use at your own risk! )abstractmethodABCMetaN) defaultdict)WrapperDescriptorTypeMethodWrapperTypeMethodDescriptorType GenericAlias)_idfuncTypeVar ParamSpec TypeVarTuple ParamSpecArgsParamSpecKwargs TypeAliasTypeGeneric)c AnnotatedAnyCallableClassVar ConcatenateFinal ForwardRefrLiteralOptionalr ProtocolTupleTyper r Union AbstractSet ByteString ContainerContextManagerHashable ItemsViewIterableIteratorKeysViewMapping MappingViewMutableMappingMutableSequence MutableSetSequenceSized ValuesView Awaitable AsyncIterator AsyncIterable Coroutine CollectionAsyncGeneratorAsyncContextManager Reversible SupportsAbs SupportsBytesSupportsComplex SupportsFloat SupportsIndex SupportsInt SupportsRoundChainMapCounterDequeDict DefaultDictList OrderedDictSet FrozenSet NamedTuple TypedDict GeneratorBinaryIOIOMatchPatternTextIOAnyStr assert_type assert_nevercastclear_overloadsdataclass_transformfinalget_args get_origin get_overloadsget_type_hints is_typeddict LiteralStringNeverNewType no_type_checkno_type_check_decoratorNoReturn NotRequiredoverloadoverriderrRequired reveal_typeruntime_checkableSelfText TYPE_CHECKING TypeAlias TypeGuardrUnpackFallow_special_formsc\| tdSt|trt|||S|S)z=For converting None to type(None), and strings to ForwardRef.N)moduleis_class)type isinstancestrr)argrqros -/opt/alt/python312/lib64/python3.12/typing.py _type_convertrxs0 {Dz#s#f7JKK JTcttf}|s|tfz }|r |tfz }t |||}t |t r|j|vrt|d|ttttttfvr|S|r|ttfvr|St |ts|ttfvrtd|dt!|t"urt|d|dd|S)aCheck that the argument is a type, and return it (internal helper). As a special case, accept None and return type(None) instead. Also wrap strings into ForwardRef instances. Consider several corner cases, for example plain special forms like Union are not valid, while Union[int, str] is OK, etc. The msg argument is a human-readable error message, e.g.:: "Union[arg, ...]: arg should be a type." We append the repr() of the actual value (truncated to 100 chars). )rqro is not valid as type argumentzPlain z Got z.100.)rrrrrxrt _GenericAlias __origin__ TypeErrorrr\rar]rhrk _SpecialFormrstuple)rvmsg is_argumentrqroinvalid_generic_formss rw _type_checkrs%h/ (,  !eX - ! F@S TC3 & NN3 33%=>?? sM8UD)DD sx&77 #|$/B(B&%CDEE CyE3%uS4L233 JrycN|duxs t|ttttfSN.)rtrlistr _ConcatenateGenericAlias)rvs rw_is_param_exprrs, #: @C D)%= >@@ryc|jtjjuxrt |dk(xrt |d S)aCInternal helper for munging collections.abc.Callable's __args__. The canonical representation for a Callable's __args__ flattens the argument types, see https://github.com/python/cpython/issues/86361. For example:: >>> import collections.abc >>> P = ParamSpec('P') >>> collections.abc.Callable[[int, int], str].__args__ == (int, int, str) True >>> collections.abc.Callable[P, str].__args__ == (P, str) True As a result, if we need to reconstruct the Callable from its __args__, we need to unflatten it. r)r~ collectionsabcrlenr)typargss rw_should_unflatten_callable_argsrs@& +//222 =Ta;N47$; <rycVt|tr6|jdk(r |jS|jd|jS|duryt|tj r |j St|trddjd|DzdzSt|S) a;Return the repr() of an object, special-casing types (internal helper). If obj is a type, we return a shorter version than the default type.__repr__, based on the module and qualified name, which is typically enough to uniquely identify a type. For everything else, we fall back on repr(obj). builtinsr|....[, c32K|]}t|ywN) _type_repr).0ts rw z_type_repr..s:cz!}c]) rtrs __module__ __qualname__types FunctionType__name__rjoinreprobjs rwrrs#t >>Z '## #..!3#3#3"455 cz#u))*||#uTYY:c:::S@@ 9ryc`g}|D]}t|trt|tr/|D])}t|gD]}||vs|j |+St |dr||vsd|j |vt |ddD]}||vs|j |t|S)aCollect all type variables and parameter specifications in args in order of first appearance (lexicographic order). For example:: >>> P = ParamSpec('P') >>> T = TypeVar('T') >>> _collect_parameters((T, Callable[P, T])) (~T, ~P) __typing_subst____parameters__)rtrsr_collect_parametersappendhasattrgetattr)r parametersrx collecteds rwrrsJ  a   5 !!4aS!9I 2")))4":Q* + "!!!$Q 0"5J&%%a(6$  ryc |st|dt|}||k7rtd||kDrdndd|d|d|y) zCheck correct count for parameters of a generic cls (internal helper). This gives a nice error message in case of count mismatch.  is not a generic classToo manyfew arguments for ; actual , expected N)rr)clsrelenalens rw_check_genericr'sh 3%6788 z?D t|$v%@PSuU##'& D6;< <rycg}|D]=}t|dd}||r|ddus|j|-|j|?|S)N__typing_unpacked_tuple_args__.)rextendr)rnewargsrvsubargss rw _unpack_argsr3sRG#?F  GBK34F NN7 # NN3   Nryunhashable_fallbackch tj|S#t$r|st|cYSwxYwr)dictfromkeysr_deduplicate_unhashable)paramsrs rw _deduplicater=s6/}}V$$ /" &v.. /s 11cDg}|D]}||vs|j||Sr)r)unhashable_paramsnew_unhashablers rwrrGs/N  N "  ! !! $ ryct|}t|}t|} |D]}|j| | S#t$rYywxYw)NF)rrremove ValueError) first_args second_argsfirst_unhashablesecond_unhashablerelems rw_compare_args_orderlessrNsZ.z:/ < A$D HHTN%5L s? A  A cg}|D]O}t|ttjfr|j |j ?|j |Qtt|dS)zwInternal helper for Union creation and substitution. Flatten Unions among parameters, then remove duplicates. Tr) rt_UnionGenericAliasr UnionTyper__args__rrrrrps rw_remove_dups_flattenrYsW F  a,eoo> ? MM!** % MM!   f$? @@rycg}|D]?}t|tr|j|j/|j |At |S)zHInternal helper for Literal creation: flatten Literals among parameters.)rt_LiteralGenericAliasrrrrrs rw_flatten_literal_paramsrisD F  a- . MM!** % MM!   =rytypedc&fd}|||S|S)zInternal wrapper caching __getitem__ of generic types. For non-hashable arguments, the original function is used as a fallback. ctj}|t<tj |j ~tj fd}|S)NrcP t|i|S#t$rYnwxYw|i|Sr)_cachesr)rkwdsfuncs rwinnerz+_tp_cache..decorator..inners> t}d3d33  && &s  ) functools lru_cacher _cleanupsr cache_clearwraps)rcacherrs` rw decoratorz_tp_cache..decorator}s^ 1 ##%06 **+    '  '  ryr)rrrs ` rw _tp_cacherxs (  ryrecursive_guardct|tr|jSt|ttt j frt|trftd|jD}|j}t||r|j|dd|df}n|j|}|r t|}tfd|jD}||jk(r|St|trt |j|St|t j r$tjtj |S|j#|S|S)zEvaluate all forward references in the given type t. For use of globalns and localns see the docstring for get_type_hints(). recursive_guard is used to prevent infinite recursion with a recursive ForwardRef. rc3VK|]!}t|tr t|n|#ywr)rtrurrrvs rwrz_eval_type..s*%C$.c3#7 3S@%s')Nrc3>K|]}t|yw)rN) _eval_type)raglobalnslocalnsr type_paramss rwrz_eval_type..s2   8Wk?   s)rtr _evaluater}r rrrr __unpacked__rr~rmrreduceoperatoror_ copy_with)rrrrrr is_unpackedev_argss ```` rwrrs0!Z {{8Wk?{[[!m\5??CD a &::D..K.q$7LL$s)T"X!67LL&1I ZZ    ajj H a & g6 6 a )##HLL': :;;w' ' HryceZdZdZdZdZy)_FinalzMixin to prohibit subclassing.) __weakref__c"d|vr tdy)N_rootz&Cannot subclass special typing classesr)rrrs rw__init_subclass__z_Final.__init_subclass__s $ DE E ryN)rrr__doc__ __slots__rrryrwr r s( IFryr ceZdZdZdZdZy) _NotIterableaMixin to prevent iteration, without being compatible with Iterable. That is, we could do:: def __iter__(self): raise TypeError() But this would make users of this mixin duck type-compatible with collections.abc.Iterable - isinstance(foo, Iterable) would be True. Luckily, we can instead prevent iteration by setting __iter__ to None, which is treated specially. rN)rrrrr__iter__rryrwrrs IHryrc\eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z ed Zy )r)_namer_getitemcV||_|j|_|j|_yr)rrrr)selfgetitems rw__init__z_SpecialForm.__init__s! %%  ryc8|dvr |jSt|)N>rr)rAttributeError)ritems rw __getattr__z_SpecialForm.__getattr__s / /:: T""ryctd|)NCannot subclass rrbasess rw__mro_entries__z_SpecialForm.__mro_entries__s*4(344ryc d|jzSNtyping.rrs rw__repr__z_SpecialForm.__repr__4::%%ryc|jSrr(r)s rw __reduce__z_SpecialForm.__reduce__ zzryctd|)NzCannot instantiate r)rrrs rw__call__z_SpecialForm.__call__s-dX677ryct||fSrrrothers rw__or__z_SpecialForm.__or__T5[!!ryct||fSrr2r3s rw__ror__z_SpecialForm.__ror__UD[!!ryct|d)Nz! cannot be used with isinstance()rrrs rw__instancecheck__z_SpecialForm.__instancecheck__4& ABCCryct|d)Nz! cannot be used with issubclass()rrrs rw__subclasscheck__z_SpecialForm.__subclasscheck__r=ryc&|j||Sr)rrrs rw __getitem__z_SpecialForm.__getitem__s}}T:..ryN)rrrrrrr$r*r-r0r5r8r<r@rrCrryrwrrsO0I' # 5&8""DD//ryr)r ceZdZdZy)_LiteralSpecialFormcNt|ts|f}|j|g|Sr)rtrrrBs rwrCz_LiteralSpecialForm.__getitem__ s)*e,$Jt}}T/J//ryN)rrrrCrryrwrErEs0ryrEc(eZdZfdZfdZxZS)_AnyMetacH|tur tdt| |S)Nz+typing.Any cannot be used with isinstance())rrsuperr<)rr __class__s rwr<z_AnyMeta.__instancecheck__s& 3;IJ Jw(--ryc2|turyt| S)Nz typing.Any)rrJr*)rrKs rwr*z_AnyMeta.__repr__s 3;w!!ry)rrrr<r* __classcell__rKs@rwrHrHs. ""ryrHc"eZdZdZfdZxZS)raWSpecial type indicating an unconstrained type. - Any is compatible with every type. - Any assumed to have all methods. - All values assumed to be instances of Any. Note that all the above statements are true from the point of view of static type checkers. At runtime, Any should not be used with instance checks. cH|tur tdt| |S)NzAny cannot be instantiated)rrrJ__new__rrkwargsrKs rwrQz Any.__new__'s% #:89 9ws##ry)rrrrrQrMrNs@rwrrs $$ryr) metaclassct|d)aSpecial type indicating functions that never return. Example:: from typing import NoReturn def stop() -> NoReturn: raise Exception('no way') NoReturn can also be used as a bottom type, a type that has no values. Starting in Python 3.11, the Never type should be used for this concept instead. Type checkers should treat the two equivalently.  is not subscriptablerrBs rwrara-s tf12 33ryct|d)adThe bottom type, a type that has no members. This can be used to define a function that should never be called, or a function that never returns:: from typing import Never def never_call_me(arg: Never) -> None: pass def int_or_str(arg: int | str) -> None: never_call_me(arg) # type checker error match arg: case int(): print("It's an int") case str(): print("It's a str") case _: never_call_me(arg) # OK, arg is of type Never rVrrBs rwr]r]Bs, tf12 33ryct|d)asUsed to spell the type of "self" in classes. Example:: from typing import Self class Foo: def return_self(self) -> Self: ... return self This is especially useful for: - classmethods that are used as alternative constructors - annotating an `__enter__` method which returns self rVrrBs rwrhrh[s" tf12 33ryct|d)a Represents an arbitrary literal string. Example:: from typing import LiteralString def run_query(sql: LiteralString) -> None: ... def caller(arbitrary_string: str, literal_string: LiteralString) -> None: run_query("SELECT * FROM students") # OK run_query(literal_string) # OK run_query("SELECT * FROM " + literal_string) # OK run_query(arbitrary_string) # type checker error run_query( # type checker error f"SELECT * FROM students WHERE name = {arbitrary_string}" ) Only string literals and other LiteralStrings are compatible with LiteralString. This provides a tool to help prevent security issues such as SQL injection. rVrrBs rwr\r\os0 tf12 33ryc:t||d}t||fS)a>Special type construct to mark class variables. An annotation wrapped in ClassVar indicates that a given attribute is intended to be used as a class variable and should not be set on instances of that class. Usage:: class Starship: stats: ClassVar[dict[str, int]] = {} # class variable damage: int = 10 # instance variable ClassVar accepts only types and cannot be further subscribed. Note that ClassVar is not a class itself, and should not be used with isinstance() or issubclass().  accepts only single type.rr}rrrs rwrr'& zdV+E#F GD w ''ryc:t||d}t||fS)aSpecial typing construct to indicate final names to type checkers. A final name cannot be re-assigned or overridden in a subclass. For example:: MAX_SIZE: Final = 9000 MAX_SIZE += 1 # Error reported by type checker class Connection: TIMEOUT: Final[int] = 10 class FastConnector(Connection): TIMEOUT = 1 # Error reported by type checker There is no runtime checking of these properties. r[r\r]s rwrrr^ryc|dk(r tdt|ts|f}dtfd|D}t|}t |dk(r|dSt |dk(rt d|vrt ||d St ||S) aUnion type; Union[X, Y] means either X or Y. On Python 3.10 and higher, the | operator can also be used to denote unions; X | Y means the same thing to the type checker as Union[X, Y]. To define a union, use e.g. Union[int, str]. Details: - The arguments must be types and there must be at least one. - None as an argument is a special case and is replaced by type(None). - Unions of unions are flattened, e.g.:: assert Union[Union[int, str], float] == Union[int, str, float] - Unions of a single argument vanish, e.g.:: assert Union[int] == int # The constructor actually returns int - Redundant arguments are skipped, e.g.:: assert Union[int, str, int] == Union[int, str] - When comparing unions, the argument order is ignored, e.g.:: assert Union[int, str] == Union[str, int] - You cannot subclass or instantiate a union. - You can use Optional[X] as a shorthand for Union[X, None]. rz Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.c36K|]}t|ywrrrrrs rwrzUnion..s?Jq{1c*JrrNrname)rrtrrrrsrrrrs @rwrrs>R:;; j% ( ] 5C?J??J%j1J :!!} :!T j 8!$ DD dJ //ryct||fS)zUsed from the C implementation of TypeVar. TypeVar.__or__ calls this instead of returning types.UnionType because we want to allow unions between TypeVars and strings (forward references). r2)leftrights rw _make_unionrls u rycHt||d}t|tdfS)z,Optional[X] is equivalent to Union[X, None].z requires a single type.N)rrrs)rrrvs rwrrs+ jTF*B"C DC d4j !!ryc t|} tdttt |D}t ||S#t $rYwxYw)aSpecial typing form to define literal types (a.k.a. value types). This form can be used to indicate to type checkers that the corresponding variable or function parameter has a value equivalent to the provided literal (or one of several literals):: def validate_simple(data: Any) -> Literal[True]: # always returns True ... MODE = Literal['r', 'rb', 'w', 'wb'] def open_helper(file: str, mode: MODE) -> str: ... open_helper('/some/path', 'r') # Passes type check open_helper('/other/path', 'typo') # Error in type checker Literal[...] cannot be subclassed. At runtime, an arbitrary value is allowed as type argument to Literal[...], but type checkers may impose restrictions. c3&K|] \}}| ywrr)rr_s rwrzLiteral.. s^)]A1)]s)rrrr_value_and_type_iterrrrBs rwrrsW2)4J ^d;OPZ;[6\)]^^  j 11    s-A AAct|d)a:Special form for marking type aliases. Use TypeAlias to indicate that an assignment should be recognized as a proper type alias definition by type checkers. For example:: Predicate: TypeAlias = Callable[..., bool] It's invalid when used anywhere except as in the example above. rVrrBs rwrkrks tf12 33ryc|dk(r tdt|ts|f}|ddust|dts tddgfd|ddD|d}t ||S) acSpecial form for annotating higher-order functions. ``Concatenate`` can be used in conjunction with ``ParamSpec`` and ``Callable`` to represent a higher-order function which adds, removes or transforms the parameters of a callable. For example:: Callable[Concatenate[int, P], int] See PEP 612 for detailed information. rz&Cannot take a Concatenate of no types.r.zMThe last parameter to Concatenate should be a ParamSpec variable or ellipsis.z/Concatenate[arg, ...]: each arg must be a type.c36K|]}t|ywrrbrcs rwrzConcatenate..;sAAK3'rdN)rrtrr rrhs @rwrr%sR@AA j% ( ] rNc !Z 2 %J:; ; ;CRACRAR:b>RJ #D* 55ryc:t||d}t||fS)aSpecial typing construct for marking user-defined type guard functions. ``TypeGuard`` can be used to annotate the return type of a user-defined type guard function. ``TypeGuard`` only accepts a single type argument. At runtime, functions marked this way should return a boolean. ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static type checkers to determine a more precise type of an expression within a program's code flow. Usually type narrowing is done by analyzing conditional code flow and applying the narrowing to a block of code. The conditional expression here is sometimes referred to as a "type guard". Sometimes it would be convenient to use a user-defined boolean function as a type guard. Such a function should use ``TypeGuard[...]`` as its return type to alert static type checkers to this intention. Using ``-> TypeGuard`` tells the static type checker that for a given function: 1. The return value is a boolean. 2. If the return value is ``True``, the type of its argument is the type inside ``TypeGuard``. For example:: def is_str_list(val: list[object]) -> TypeGuard[list[str]]: '''Determines whether all objects in the list are strings''' return all(isinstance(x, str) for x in val) def func1(val: list[object]): if is_str_list(val): # Type of ``val`` is narrowed to ``list[str]``. print(" ".join(val)) else: # Type of ``val`` remains as ``list[object]``. print("Not a list of strings!") Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower form of ``TypeA`` (it can even be a wider form) and this may lead to type-unsafe results. The main reason is to allow for things like narrowing ``list[object]`` to ``list[str]`` even though the latter is not a subtype of the former, since ``list`` is invariant. The responsibility of writing type-safe type guards is left to the user. ``TypeGuard`` also works with type variables. For more information, see PEP 647 (User-Defined Type Guards). r[r\r]s rwrlrl?s(b zdV+E#F GD w ''rycHeZdZdZdZd dddZddZdZd Zd Z d Z d Z y)rz-Internal wrapper to hold a forward reference.)__forward_arg____forward_code____forward_evaluated____forward_value____forward_is_argument____forward_is_class____forward_module__NF)rrc(t|tstd||jdrd|d}n|} t |dd}||_||_d|_d|_ ||_ ||_ ||_ y#t $rt d|wxYw) Nz*Forward reference must be a string -- got *(z,)[0]zevalz/Forward reference must be an expression -- got F) rtrur startswithcompile SyntaxErrorrwrxryrzr{r|r})rrvrrqrrarg_to_compilecodes rwrzForwardRef.__init__|s#s#HPQ Q >>#  U^N N Y>:v>D # $%*"!%'2$$,!"( Y OPSwWX X Ys A99Bcl|j|vr|S|jr||ur||ix}}n ||}n||}|j5ttj j |jdd|}|rQt|t|}}|D]6}|j}|jr||vs |||<|j|d8tt|j||d|j|j}t||||||jhz|_d|_|j S)N__dict__z*Forward references must evaluate to types.)rrorT)rwryr}rsysmodulesgetrrr|poprrrxr{rrz)rrrrrparam param_nametype_s rwrzForwardRef._evaluatesG   ? 2K))WH-DGO%''7!""&&2"KKOOD$;$;TBJPX$(NDM'(E!&J44 (8R/4, J5 )  T**Hg>< 88$($=$= E &0!0D4H4H3I!I &D "*.D &%%%ryc.t|tstS|jr@|jr4|j|jk(xr|j |j k(S|j|jk(xr|j |j k(Sr)rtrNotImplementedryrwrzr}r3s rw__eq__zForwardRef.__eq__s%,! !  % %%*E*E((E,A,AAF**e.E.EE G$$(=(==D''5+C+CC ErycDt|j|jfSr)hashrwr}r)s rw__hash__zForwardRef.__hash__sT))4+B+BCDDryct||fSrr2r3s rwr5zForwardRef.__or__r6ryct||fSrr2r3s rwr8zForwardRef.__ror__r9rycb|jd}nd|j}d|j|dS)Nz , module=z ForwardRef())r}rw)r module_reprs rwr*zForwardRef.__repr__s@  " " *K%d&=&=%@AKT114[MCCryTNr) rrrrrrrrrr5r8r*rryrwrrts:7'I )u)0,&\EE""DryrrreturncBt|t xr t|ddS)N#__typing_is_unpacked_typevartuple__F)rtrsrrs rw_is_unpacked_typevartuplers(At$ $ E A?? Jryc |j}|j|}||dzdD] }t|tst d|t |}t |}|}||z dz } d} d} t |D]Q\} } t| trt| dd}|s't |dk(s6|ddus>| t d| } |d} S| t|| }t| || z dz } n|| z|kDrt d |d |d |dz g|d|| g||z zt|||| z | g|| z |z |z dz z||| z dS) Nrez(More than one TypeVarTuple parameter in rrr.z6More than one unpacked arbitrary-length tuple argumentrToo few arguments for rz, expected at least ) rindexrtr rr enumeratersrminr)raliasrrtypevartuple_indexrrplenrjrkvar_tuple_indexfillargkrvrs rw_typevartuple_prepare_substrs  ! !Fd+*Q./0 e\ *FugNO O1 t9D v;D D % % )EOGD/3#t$c#CTJG3w<1,1C".#$\]]"#!!*""4)E4/1A56  08##'&(.sD1K#56zFExpected a list of types, an ellipsis, ParamSpec, or Concatenate. Got )rtrrrrrrvs rw_paramspec_substrsU#e}%DDD JC ::=@A A Jryc*|j}|j|}|t|k\rtd|t|dk(rt |ds |dk(sJ|f}|St ||t rg|d|t||||dzd}|S)Nrrer)rrrrrrtrr)rrrris rw_paramspec_prepare_substr#s  ! !F TACI~0899 6{atAw 7Av vw K DGT "7bq75a>7D1J7 Kryct|ts|f}td|D}|ttfv}|r|st d|j dt d|Dst d|jdtt|t|k7rt d|jd|jD]}t|dd }||||}t||t|jg}t|j|D]8\}}t|tr|j|(|j!|:t|}t#||S) aParameterizes a generic class. At least, parameterizing a generic class is the *main* thing this method does. For example, for some generic class `Foo`, this is called when we do `Foo[int]` - there, with `cls=Foo` and `params=int`. However, note that this method is also called when defining generic classes in the first place with `class Foo(Generic[T]): ...`. c32K|]}t|ywrrxrrs rwrz)_generic_class_getitem..@s4V=#VrzParameter list to z[...] cannot be emptyc32K|]}t|ywr)rrs rwrz)_generic_class_getitem..Is71#A&rzParameters to zF[...] must all be type variables or parameter specification variables.z[...] must all be unique__typing_prepare_subst__N)rtrrrrrallrrsetrrrzipr rrr})rris_generic_or_protocolrpreparenew_argsnew_args rw_generic_class_getitemr2sk fe $ 4V4 4F Wh$77$S%5%5$66KL 777 /89: : s6{ s6{ * .FGI I''Ee%?FG" f-( sFC(:(:$;<!#"4"4f=NE7%.(( > x f %%ryc tt| |i|g}d|jvrt|jv}n7t|j vxr#|j dk7xrt|tk7}|r tdd|jvrt|j}d}|jD]?}t|ts|jtus'| td|j}A|at|}t| | ksDdj! fd|D}dj!d|D} td|d | d |}t#||_y) N__orig_bases__rz!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple times.rc3>K|]}|vst|ywrru)rrgvarsets rwrz)_generic_init_subclass..s"M5aAW.s"95a3q65rzSome type variables (z) are not listed in Generic[r)rJrrrr __bases__rrs_TypedDictMetarrrtr}r~rrrr) rrrStvarserrorgvarsbasetvarsets_varss_argsrs @rw_generic_init_subclassrcsl '3)4:6: E3<<'3---CMM)0LLJ.0I/  ;<<3<<'#C$6$67 &&D4/OOw.$#JLL++ '  %jG%jGg%"M5"MM"95"99"7x@::@!DEEEuCrycJ|jdxr|jdS)N__)rendswith)attrs rw _is_dunderrs ??4 8T]]4%88rycXeZdZdZddddZdZdZdZfd Zd Z d Z fd Z xZ S) _BaseGenericAliasaThe central part of the internal API. This represents a generic version of type 'origin' with type arguments 'params'. There are two kind of these aliases: user defined and special. The special ones are wrappers around builtin collections and ABCs in collections.abc. These must have 'name' always set. If 'inst' is False, then the alias can't be instantiated; this is used by e.g. typing.List and typing.Dict. TNinstrgc<||_||_||_d|_yr)_instrr~r)roriginrrgs rwrz_BaseGenericAlias.__init__s   ryc|js0td|jd|jjd|j|i|} ||_|S#t $rY|SwxYw)NzType z cannot be instantiated; use z () instead)rrrr~r__orig_class__ Exception)rrrSresults rwr0z_BaseGenericAlias.__call__szzeDJJ<0##'??#;#;"rrr~)rr~rrrrr)rrs rwrz_BaseGenericAlias.__getattr__sU / /::9!9!9 9 4== (D1A4??D1 1T""ryctt|s|dvrt| ||yt|j||y)N>rr_nparams)rrJ __setattr__setattrr~)rrvalrKs rwrz_BaseGenericAlias.__setattr__s2 d t'EE G c * DOOT3 /ryc6|jt|Srr@rsr;s rwr<z#_BaseGenericAlias.__instancecheck__%%d3i00ryctd)NzBSubscripted generics cannot be used with class and instance checksrr?s rwr@z#_BaseGenericAlias.__subclasscheck__s56 6ryc ttt| t |j Dcgc]}t |r|c}zScc}wr)rrrJ__dir__dirr~rrrrKs rwrz_BaseGenericAlias.__dir__sPC)$'$8Q$8D 4@P4$8QRST TQs AA) rrrrrr0r$rrr<r@rrMrNs@rwrrs>(,$  #0 16TTryrc|eZdZdddfd ZdZdZdZdZed Z d Z d Z d Z d Z dZfdZdZxZS)r}TNrct||||t|ts|f}td|D|_t ||_|s|j|_yy)Nrc34K|]}|turdn|yw).N)_TypingEllipsisrs rwrz)_GenericAlias.__init__..s'/)-A&'/%9c )-r)rJrrtrrrrr)rrrrrgrKs rwrz_GenericAlias.__init__sc d6$&7D/)-// 1$7$//DOryct|tstS|j|jk(xr|j|jk(Sr)rtr}rr~rr3s rwrz_GenericAlias.__eq__s>%/! !5#3#334MMU^^3 5rycDt|j|jfSr)rr~rr)s rwrz_GenericAlias.__hash__sT__dmm455ryct||fSrr2rrks rwr5z_GenericAlias.__or__r6ryct||fSrr2rrjs rwr8z_GenericAlias.__ror__ T4Z  ryc*|jttfvrtd||jst|dt |t s|f}t d|D}t|}|j|}|j|}|S)Nz%Cannot subscript already-subscripted rc32K|]}t|ywrrrs rwrz,_GenericAlias.__getitem__..(s4t!]1%tr) r~rrrrrtrr_determine_new_argsr)rrrrs rwrCz_GenericAlias.__getitem__s" ??w1 1CD6JK K""tf$;<= =$&7D4t44D!++D1 NN8 $ryc @|j}|D]}t|dd}||||}t|}t|}||k7rtd||kDrdndd|d|d|t t ||}t |j|j|S)Nrrrrrrr) rrrrrrr_make_substitutionr)rrrrrrrnew_arg_by_params rwrz!_GenericAlias._determine_new_args.s$$Ee%?FG"tT*4y6{ 4<dTD[6e"DOTXSYZ''+fKv?@ @FD 12T,,T]]#G-=rB  %G G&%a6#NN+;A+>?#NN+;A+>? ' &eGn5G+//":"::z'SX?Y(*73(GU+$11';KLM(qrrych|j|j||j|jSN)rgr)rKr~rrrrs rwrz_GenericAlias.copy_withs%~~doot$**4::~VVryc|jrd|jz}nt|j}|jr3dj |jDcgc] }t|c}}nd}|d|dScc}w)Nr'rz()rr)rrr~rr)rrgrrs rwr*z_GenericAlias.__repr__sq ::tzz)Ddoo.D ==99T]]C]jm]CDDDqa  DsA;c|jrt|j}n |j}t|j}t |dk(rt |dts|\}tj||ffSNrer) rglobalsr~rrrrtrr)rrrs rwr-z_GenericAlias.__reduce__sd ::Ytzz*F__FT]]# t9>*T!We"<ED&$//rycDt|jtrtd||jrt ||S|jtur>t|vry|j|}||dzdD]}t|ts||usy|jfS)Nr!rre) rtr~rrrrJr$rrrr)rr#rrrKs rwr$z_GenericAlias.__mro_entries__s doo| 4.th78 8 ::7*51 1 ??g %5  D!A1Q34[a!23 !!!ryc#"Kt|ywr)rmr)s rwrz_GenericAlias.__iter__sTls )rrrrrrr5r8rrCrrrr*r-r$rrMrNs@rwr}r}s]2.205 6"!>O:<|W !0 "ryr}c^eZdZdddfd ZedZdZdZfdZd Z d Z d Z xZ S) _SpecialGenericAliasTNrc| |j}t| |||||_|jdk(rd|j d|_yd|jd|j d|_y)NrrzA generic version of r|)rrJrrrrr)rrnparamsrrgrKs rwrz_SpecialGenericAlias.__init__sv <??D d6    *263F3F2GqIDL263D3D2EQvGZGZF[[\]DLryct|ts|f}dtfd|D}t|||j|j |S)Nrc36K|]}t|ywrrbrcs rwrz3_SpecialGenericAlias.__getitem__..;Fq{1c*Frd)rtrrrrrrrs @rwrCz _SpecialGenericAlias.__getitem__sH&%(YF:;F;;tVT]]3~~f%%ryc\t|j||j|jSr)r}r~rrrrs rwrz_SpecialGenericAlias.copy_withs$T__f"&**4::? ?ryc d|jzSr&r(r)s rwr*z_SpecialGenericAlias.__repr__r+ryct|tr t|j|jSt|tst||jSt ||Sr)rtr!rr~r}rJr@)rrrKs rwr@z&_SpecialGenericAlias.__subclasscheck__sN c/ 0cnndoo> >#}-c4??3 3w(--ryc|jSrr(r)s rwr-z_SpecialGenericAlias.__reduce__r.ryct||fSrr2rs rwr5z_SpecialGenericAlias.__or__r6ryct||fSrr2r s rwr8z_SpecialGenericAlias.__ror__r ry) rrrrrrCrr*r@r-r5r8rMrNs@rwr!r!s@044^&&?&."!ryr!c0eZdZdddfd ZfdZxZS)_DeprecatedGenericAliasTNrc:t|||||||_y)Nr)rJr_removal_version)rrr#removal_versionrrgrKs rwrz _DeprecatedGenericAlias.__init__s# t$? /rycddl}|j|jd|j|jt ||S)Nrr|)r)warnings _deprecatedrrr2rJr<)rrr5rKs rwr<z)_DeprecatedGenericAlias.__instancecheck__sGq -d6K6K w(..ry)rrrrr<rMrNs@rwr0r0s8<40 //ryr0c$eZdZfdZdZxZS)_CallableGenericAliasc |jdk(sJ|j}t|dk(rt|drt|Sddj |ddDcgc] }t|c}dt|ddScc}w) Nrrrztyping.Callable[[rrz], r)rrrrrJr*rr)rrrrKs rwr*z_CallableGenericAlias.__repr__szzZ'''}} t9>nT!W57#% %YYtCRyAy! 1 yABC3d2h'(+ ,AsB c|j}t|dk(rt|dst|dd|df}tj t |ffS)Nrrr)rrrrrrrrs rwr-z _CallableGenericAlias.__reduce__sO}}D Q>$q'#:Sb ?DH,D(D!111ry)rrrr*r-rMrNs@rwr8r8s ,2ryr8c(eZdZdZdZedZy) _CallableTypec\t|j||j|jSr)r8r~rrr)s rwrz_CallableType.copy_withs&$T__f*.**4::G Gryct|trt|dk7r td|\}}t|trt||f}n||f}|j |S)Nrz6Callable must be used as Callable[[arg, ...], result].)rtrrrr__getitem_inner__)rrrrs rwrCz_CallableType.__getitem__ sf&%(CK1,<<= = f dD !Dk6*FF^F%%f--ryc|\}}d}t||}|tur|jt|fSt |t s|f}t d|D}||fz}|j|S)Nz.Callable[args, result]: result must be a type.c32K|]}t|ywrrrs rwrz2_CallableType.__getitem_inner__..!s84C]3'4r)rEllipsisrrrtr)rrrrrs rwr?z_CallableType.__getitem_inner__st f>VS) 8 >>?F";< <$&7D8488 !~~f%%ryN)rrrrrCrr?rryrwr<r<s!G . & &ryr<ceZdZedZy) _TupleTypect|ts|f}t|dk\r:|ddur3dtfd|ddD}|jg|tSdtfd|D}|j|S)Nrr.z Tuple[t, ...]: t must be a type.c36K|]}t|ywrrbrcs rwrz)_TupleType.__getitem__..-sD 1;q#. rdz*Tuple[t0, t1, ...]: each t must be a type.c36K|]}t|ywrrbrcs rwrz)_TupleType.__getitem__..0r&rd)rtrrrrr's @rwrCz_TupleType.__getitem__'s&%(YF v;! r c 14CDs DDF>>"A?c>tt|jSr)r frozensetrr)s rwrz_UnionGenericAlias.__hash__@sIdmm,--ryc|j}t|dk(rD|dtdurdt|ddS|dtdurdt|ddSt|S)Nrrztyping.Optional[rer)rrrsrrJr*rrrKs rwr*z_UnionGenericAlias.__repr__Csw}} t9>Aw$t*$)*T!W*=)>a@@aDJ&)*T!W*=)>a@@w!!ryc6|jt|Srrr;s rwr<z$_UnionGenericAlias.__instancecheck__LrrycB|jD]}t||syy)NT)rr)rrrvs rwr@z$_UnionGenericAlias.__subclasscheck__Os==C#s#!ryc@t|\}\}}|t|ffSr)rJr-r)rrrrrKs rwr-z_UnionGenericAlias.__reduce__Ts($w13nvteT]""ry) rrrrrrr*r<r@r-rMrNs@rwrr4s,J."1 ##ryrcd|DS)Nc36K|]}|t|fywr)rsrs rwrz'_value_and_type_iter..Zs -*QQQL*sr)rs rwrqrqYs -* --ryceZdZdZdZy)rct|tstStt |j tt |j k(Sr)rtrrrrqrr3s rwrz_LiteralGenericAlias.__eq__^s?%!56! !' 673?STYTbTb?c;dddrycPttt|jSr)rrLrqrr)s rwrz_LiteralGenericAlias.__hash__dsI24==ABCCryN)rrrrrrryrwrr]se DryrceZdZfdZxZS)rct|dttfr g|dd|dSt|dtrg|dd|dj}t ||S)Nr)rtrrrrrJr)rrrKs rwrz"_ConcatenateGenericAlias.copy_withism fRj4- 0.VCR[.6":. . fRj": ;9vcr{9VBZ%8%89Fw ((ry)rrrrrMrNs@rwrrhs ))ryrc<t||d}t||fS)aType unpack operator. The type unpack operator takes the child types from some container type, such as `tuple[int, str]` or a `TypeVarTuple`, and 'pulls them out'. For example:: # For some generic class `Foo`: Foo[Unpack[tuple[int, str]]] # Equivalent to Foo[int, str] Ts = TypeVarTuple('Ts') # Specifies that `Bar` is generic in an arbitrary number of types. # (Think of `Ts` as a tuple of an arbitrary number of individual # `TypeVar`s, which the `Unpack` is 'pulling out' directly into the # `Generic[]`.) class Bar(Generic[Unpack[Ts]]): ... Bar[int] # Valid Bar[int, str] # Also valid From Python 3.11, this can also be done using the `*` operator:: Foo[*tuple[int, str]] class Bar(Generic[*Ts]): ... And from Python 3.12, it can be done using built-in syntax for generics:: Foo[*tuple[int, str]] class Bar[*Ts]: ... The operator can also be used along with a `TypedDict` to annotate `**kwargs` in a function signature:: class Movie(TypedDict): name: str year: int # This function expects two keyword arguments - *name* of type `str` and # *year* of type `int`. def foo(**kwargs: Unpack[Movie]): ... Note that there is only some runtime checking of this operator. Not everything the runtime allows may be accepted by static type checkers. For more information, see PEPs 646 and 692. r[)rr)r_UnpackGenericAliasr]s rwrmrmqs(^ zdV+E#F GD d$ 99rycDeZdZdZfdZedZedZxZS)rZc:dt|jddS)Nztyping.Unpack[rr)rrr)s rwr*z_UnpackGenericAlias.__repr__s" 4==+; <=Q??ryc>|jr|St| |Sr)rrJrCrNs rwrCz_UnpackGenericAlias.__getitem__s!  3 3Kw"4((ryc|jtusJt|jdk(sJ|j\}t |t t jfr)|jtur td|jSy)Nrez*Unpack[...] must be used with a tuple type) r~rmrrrtr}rr rrrs rwrz2_UnpackGenericAlias.__typing_unpacked_tuple_args__sp&(((4==!Q&&&}} cM5+=+=> ?~~U* LMM<< ryc|jtusJt|jdk(sJt |jdt Sr)r~rmrrrtr r)s rwrz7_UnpackGenericAlias.__typing_is_unpacked_typevartuple__sA&(((4==!Q&&&$--*L99ry) rrrr*rCpropertyrrrMrNs@rwrZrZs6@ ) ::ryrZceZdZdZy)rz(Internal placeholder for ... (ellipsis).N)rrrrrryrwrrs2ryr> _is_protocolrrr__type_params____protocol_attrs___is_runtime_protocol__non_callable_proto_members__> rrQrrrrr __annotations____subclasshook____class_getitem____abstractmethods___MutableMapping__markerct}|jddD]`}|jdvrt|di}g|j|D].}|j dr|t vs|j|0b|S)zCollect protocol members from a protocol class objects. This includes names actually defined in the class dictionary, as well as names that appear in annotations. Special names (above) are skipped. Nr>rrrg_abc_)r__mro__rrrrEXCLUDED_ATTRIBUTESadd)rattrsr annotationsrs rw_get_protocol_attrsrss} EE CR  ==3 3 d$5r: 2dmm2k2D??7+Nrr)r~)r|s rw_allow_reckless_class_checksrs 5>7 77ry) rr0r%r&r2r#r.r!r4r7BufferAbstractContextManagerAbstractAsyncContextManager)zcollections.abc contextlibcddlm}|S)Nrgetattr_static)inspectrrs rw_lazy_load_getattr_staticr s ' ryc(t|jffSr)rr~)psargss rw_pickle_psargsr*s 6,,. ..ryc(t|jffSr)rr~)pskwargss rw_pickle_pskwargsr/s X002 22ryc<eZdZfdZfdZfdZfdZxZS) _ProtocolMetac 6|dk(r |tfk(rnvt|vrn|D]i}|tthvr|jtj |j gvr?t|trt|ddr]td|t|,||||fi|S)NrrbFz5Protocols can only inherit from other protocols, got ) rrrvr_PROTO_ALLOWLISTrrrrrrJrQ)mclsrgr# namespacerSrrKs rwrQz_ProtocolMeta.__new__:s : %G:"5   VW--}}(8(<(3 22LL$$%78KGRw(//rycn|turtj||St|ddst| |St|ddst s t dt| |ryt}|jD]} |||}|||jvsyy#t$rYywxYw)NrbFrerT) rrsr<rrJrrrrdrrf)rinstancerrrrKs rwr<z_ProtocolMeta.__instancecheck__ks (?))#x8 8sNE27,X6 63U;,.<= = 7 $X .24**D $Xt4{t3+M+MM+ "  s B'' B43B4)rrrrQrr@r<rMrNs@rwrr7sG&> 02ryrc|jjddstS|jD]}|jD]}||jvr|j| tccS;t |di}t |tjjs^||vsct|tstt |ddstcSy)NrbFrgT) rrrrdrnrrtrrr(rr)rr4rrrrs rwrrs <<  NE 2&&MMDt}}$==&.))"$(92>K; (?(?@K'ug.75.RW3X"" !' ryc.eZdZdZdZdZdZfdZxZS)ra_Base class for protocol classes. Protocol classes are defined as:: class Proto(Protocol): def meth(self) -> int: ... Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing). For example:: class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:: class GenProto[T](Protocol): def meth(self) -> T: ... rTFc:t||i||jjdds!t d|j D|_d|jvr t|_|j r)|jtjur t|_ yyy)NrbFc3,K|] }|tuywrrrrs rwrz-Protocol.__init_subclass__..s"H-Q1=-srh) rJrrranyrrbrrhrrrurRs rwrzProtocol.__init_subclass__s !4262||6""H#--"HHC  S\\ 1#.C     0A0A A3CL!B ry) rrrrrrbrerrMrNs@rwrrs%@IL  4 4ryrcPeZdZdZfdZdZdZdZdZdZ fdZ d Z xZ S) _AnnotatedAliasaRuntime representation of an annotated type. At its core 'Annotated[t, dec1, dec2, ...]' is an alias for the type 't' with extra annotations. The alias behaves like a normal typing alias. Instantiating is the same as instantiating the underlying type; binding it to types is also the same. The metadata itself is stored in a '__metadata__' attribute as a tuple. ct|tr|j|z}|j}t|||d||_y)Nrrf)rtr __metadata__r~rJr)rrmetadatarKs rwrz_AnnotatedAlias.__init__sD fo .**X5H&&F k:$rycXt|dk(sJ|d}t||jSr)rrr)rrnew_types rwrz_AnnotatedAlias.copy_withs06{a!9x):):;;rycdjt|jdjd|jDS)Nztyping.Annotated[{}, {}]rc32K|]}t|ywr)rrs rwrz+_AnnotatedAlias.__repr__..s9'8!d1g'8r)formatrr~rrr)s rwr*z_AnnotatedAlias.__repr__s9)00 t ' II9t'8'89 9  rycbtjt|jf|jzffSr)rrrr~rr)s rwr-z_AnnotatedAlias.__reduce__s1 )D,=,=="   ryct|tstS|j|jk(xr|j|jk(Sr)rtrrr~rr3s rwrz_AnnotatedAlias.__eq__sB%1! !5#3#33<%%););; =rycDt|j|jfSr)rr~rr)s rwrz_AnnotatedAlias.__hash__sT__d&7&7899ryc,|dvryt||S)N>rrr)rJrrs rwrz_AnnotatedAlias.__getattr__s / /w"4((ryc|jfSr)r~r"s rwr$z_AnnotatedAlias.__mro_entries__ s!!ry) rrrrrrr*r-rrrr$rMrNs@rwrrs0%<   = :) "ryrcDeZdZdZdZdZdZeddZdZ y ) ra+Add context-specific metadata to a type. Example: Annotated[int, runtime_check.Unsigned] indicates to the hypothetical runtime_check module that this type is an unsigned int. Every other consumer of this type can ignore this metadata and treat this type as int. The first argument to Annotated must be a valid type. Details: - It's an error to call `Annotated` with less than two arguments. - Access the metadata via the ``__metadata__`` attribute:: assert Annotated[int, '$'].__metadata__ == ('$',) - Nested Annotated types are flattened:: assert Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3] - Instantiating an annotated type is equivalent to instantiating the underlying type:: assert Annotated[C, Ann1](5) == C(5) - Annotated can be used as a generic type alias:: type Optimized[T] = Annotated[T, runtime.Optimize()] # type checker will treat Optimized[int] # as equivalent to Annotated[int, runtime.Optimize()] type OptimizedList[T] = Annotated[list[T], runtime.Optimize()] # type checker will treat OptimizedList[int] # as equivalent to Annotated[list[int], runtime.Optimize()] - Annotated cannot be used with an unpacked TypeVarTuple:: type Variadic[*Ts] = Annotated[*Ts, Ann1] # NOT valid This would be equivalent to:: Annotated[T1, T2, T3, ..., Ann1] where T1, T2 etc. are TypeVars, which would be invalid, because only one type should be passed to Annotated. rctd)Nz&Type Annotated cannot be instantiated.rrrrSs rwrQzAnnotated.__new__@s@AArycNt|ts|f}|j|g|Sr)rtr_class_getitem_inner)rrs rwrizAnnotated.__class_getitem__Cs+&%(YF's''5f55ryTrct|dkr tdt|dr tdd}t|d|d}t |dd}t ||S) NrzUAnnotated[...] should be used with at least two arguments (a type and an annotation).rz?Annotated[...] should not be used with an unpacked TypeVarTuplez$Annotated[t, ...]: t must be a type.Trnre)rrrrrr)rrrrrs rwrzAnnotated._class_getitem_innerHss v;?+, , %VAY /45 54VAYF$vx00rycJtdj|j)NzCannot subclass {}.Annotated)rrrrs rwrzAnnotated.__init_subclass__Vs! * 1 1#.. A  ryN) rrrrrrQrirrrrryrwrrs8-^IB6 T 1 1 ryrcVt|tr t|ddstd|zd|_t |_|jD]7} tt||d}|r|j j|9|S#t$r}td|d|d}~wwxYw)a:Mark a protocol class as a runtime protocol. Such protocol can be used with isinstance() and issubclass(). Raise TypeError if applied to a non-protocol class. This allows a simple-minded structural check very similar to one trick ponies in collections.abc such as Iterable. For example:: @runtime_checkable class Closable(Protocol): def close(self): ... assert isinstance(open('/some/file'), Closable) Warning: this will check only the presence of the required methods, not their type signatures! rbFzB@runtime_checkable can be only applied to protocol classes, got %rTNz,Failed to determine whether protocol member z is a method member) rrrrrerrfrdcallablerpr)rr is_callablees rwrgrg\s& c7 #73+N"$'() )#C *-C&&& ="73d#;thG%%  sB  B(B##B(c|S)zCast a value to a type. This returns the value unchanged. To the type checker this signals that the return value has the designated type, but at runtime we intentionally don't check anything (we want this to be as fast as possible). r)rrs rwrSrSs  Jryc|S)aAsk a static type checker to confirm that the value is of the given type. At runtime this does nothing: it returns the first argument unchanged with no checks or side effects, no matter the actual type of the argument. When a static type checker encounters a call to assert_type(), it emits an error if the value is not of the specified type:: def greet(name: str) -> None: assert_type(name, str) # OK assert_type(name, int) # type checker error r)rrs rwrQrQs  Jryct|ddriSt|tr?i}t|jD]}|6tt j j|jddi}n|}|jjdi}t|tjri}|tt|n|}||||}}|jD]M\} } | td} t| trt!| dd} t#| |||j$} | || <O|r|S|jD cic]\} } | t'| c} } S|`t|tj(r |j}n4|} t+| dr| j,} t+| drt| d i}||}n||}t|dd}|,t|t.riSt1d j3|t|}t|d d }|jD]Z\} } | td} t| tr't!| t|tj( d} t#| ||||| <\|r|S|jD cic]\} } | t'| c} } Scc} } wcc} } w) a Return type hints for an object. This is often the same as obj.__annotations__, but it handles forward references encoded as string literals and recursively replaces all 'Annotated[T, ...]' with 'T' (unless 'include_extras=True'). The argument may be a module, class, method, or function. The annotations are returned as a dictionary. For classes, annotations include also inherited members. TypeError is raised if the argument is not of a type that can contain annotations, and an empty dictionary is returned if no annotations are present. BEWARE -- the behavior of globalns and localns is counterintuitive (unless you are familiar with how eval() and exec() work). The search order is locals first, then globals. - If no dict arguments are passed, an attempt is made to use the globals from obj (or the respective module's globals for classes), and these are also used as the locals. If the object does not appear to have globals, an empty dictionary is used. For classes, the search order is globals first then locals. - If one dict argument is passed, it is used for both globals and locals. - If two dict arguments are passed, they specify globals and locals, respectively. __no_type_check__NrrgFT)rrr __wrapped__ __globals__z1{!r} is not a module, class, method, or function.rcr)rrtrsreversedrnrrrrrrGetSetDescriptorTypervarsitemsrurrrc_strip_annotations ModuleTyperr_allowed_typesrr)rrrinclude_extrashintsr base_globalsann base_localsrgvaluerrnsobjrs rwrZrZs>s'. #tS[[)D&s{{t'Mz[]^ ' --##$5r:C#u99:.5o$tDz*7K8#3-8k "yy{ e= JEeS)&u%$OE"5, TEYEYZ#d +#*0'u`RWR]R]R_,`R_$!QQ0B10E-ER_,`` c5++ ,||HE%/))%/umR8H ?G  C*D 1E } c> *I++16#;8 8 KE#0"5K{{} e =JE eS ! *30@0@ AAE !';Gd %#5\ekkm(\mda,>q,A)Am(\\K-aJ)]s J7J=ct|trt|jSt |dr0|jt t fvrt|jdSt|tr>td|jD}||jk(r|S|j|St|trCtd|jD}||jk(r|St|j|St|tjrQtd|jD}||jk(r|Stjt j"|S|S)z(Strip the annotations from a given type.r~rc32K|]}t|ywrrrs rwrz%_strip_annotations.. HZ03Zrc32K|]}t|ywrrrs rwrz%_strip_annotations.. rrc32K|]}t|ywrrrs rwrz%_strip_annotations.. rr)rtrrr~rrerbrr}rrr rrrrrr)r stripped_argss rwrr s!_%!!,,//q,ALLX{4K$K!!**Q-00!]#HQZZHH AJJ &H{{=))!\"HQZZHH AJJ &HALL-88!U__%HQZZHH AJJ &H m<< Hryct|trtSt|ttt t fr |jS|turtSt|tjrtjSy)aGet the unsubscripted version of a type. This supports generic types, Callable, Tuple, Union, Literal, Final, ClassVar, Annotated, and others. Return None for unsupported types. Examples:: >>> P = ParamSpec('P') >>> assert get_origin(Literal[42]) is Literal >>> assert get_origin(int) is None >>> assert get_origin(ClassVar[int]) is ClassVar >>> assert get_origin(Generic) is Generic >>> assert get_origin(Generic[T]) is Generic >>> assert get_origin(Union[T, int]) is Union >>> assert get_origin(List[Tuple[T, T]][int]) is list >>> assert get_origin(P.args) is P N) rtrrrr rrr~rrrtps rwrXrX# s^$"o&"(,$o78}} W}"eoo& ryc*t|tr|jf|jzSt|tt fr-|j }t||rt|dd|df}|St|tjr |j Sy)aGet type arguments with all substitutions performed. For unions, basic simplifications used by Union constructor are performed. Examples:: >>> T = TypeVar('T') >>> assert get_args(Dict[str, int]) == (str, int) >>> assert get_args(int) == () >>> assert get_args(Union[int, Union[T, int], str][int]) == (int, str) >>> assert get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int]) >>> assert get_args(Callable[[], T][int]) == ([], int) Nrr) rtrr~rr}r rrrrr)rrs rwrWrWA s~"o& "//11"}l34kk *2s 3CR>3r7+C "eoo&{{ ryc"t|tS)a+Check if an annotation is a TypedDict class. For example:: >>> from typing import TypedDict >>> class Film(TypedDict): ... title: str ... year: int ... >>> is_typeddict(Film) True >>> is_typeddict(dict) False )rtrrs rwr[r[[ s b. ))rydrvcpt|}t|tkDr |dtdz}td|)aStatically assert that a line of code is unreachable. Example:: def int_or_str(arg: int | str) -> None: match arg: case int(): print("It's an int") case str(): print("It's a str") case _: assert_never(arg) If a type checker finds that a call to assert_never() is reachable, it will emit an error. At runtime, this throws an exception when called. Nrz*Expected code to be unreachable, but got: )rr_ASSERT_NEVER_REPR_MAX_LENGTHAssertionError)rvrs rwrRrRp s@& IE 5z11445= EeWM NNryct|trt|D]}t||}t |drB|j |j d|j k7st|dd|jk7r^t|tjrd|_ t|tjrd|j_ t|tst| d|_ |S#t$rY|SwxYw)aIDecorator to indicate that annotations are not type hints. The argument must be a class or function; if it is a class, it applies recursively to all methods and classes defined in that class (but not to methods defined in its superclasses or subclasses). This mutates the function(s) or class(es) in place. rr|rNT)rtrsrrrrrrrrr MethodType__func__r_r)rvkeyrs rwr_r_ s#ts8C#s#CC0###*:*:);1S\\N'KK3 d3s~~E #u112(,%#u//015 .#t$c"%& $ J   J s%C.. C;:C;cBtjfd}|S)zDecorator to give another decorator the @no_type_check effect. This wraps the decorator with something that wraps the decorated function in @no_type_check. c.|i|}t|}|Sr)r_)rrrrs rwwrapped_decoratorz2no_type_check_decorator..wrapped_decorator s!$'$'T" ry)rr)rrs` rwr`r` s( __Y  ryctd)z*Helper for @overload to raise when called.zYou should not call an overloaded function. A series of @overload-decorated functions outside a stub module should always be followed by an implementation that is not @overload-ed.)NotImplementedError)rrs rw_overload_dummyr s  9 ::ryct|d|} |t|j|j|jj <tS#t $rYtSwxYw)aDecorator for overloaded functions/methods. In a stub file, place two or more stub definitions for the same function in a row, each decorated with @overload. For example:: @overload def utf8(value: None) -> None: ... @overload def utf8(value: bytes) -> bytes: ... @overload def utf8(value: str) -> bytes: ... In a non-stub file (i.e. a regular .py file), do the same but follow it with an implementation. The implementation should *not* be decorated with @overload:: @overload def utf8(value: None) -> None: ... @overload def utf8(value: bytes) -> bytes: ... @overload def utf8(value: str) -> bytes: ... def utf8(value): ... # implementation goes here The overloads for a function can be retrieved at runtime using the get_overloads() function. r)r_overload_registryrr__code__co_firstlinenorr)rfs rwrcrc sa@ j$'A VZ1<<(89R9RS     s7A AAct|d|}|jtvrgSt|j}|j|vrgSt ||jj S)z6Return all defined overloads for *func* as a sequence.r)rrrrrvalues)rrmod_dicts rwrYrY s` j$'A||-- !!,,/H~~X% (//1 22ryc,tjy)z$Clear all overloads in the registry.N)rclearrryrwrTrT srycB d|_|S#ttf$rY|SwxYw)aDecorator to indicate final methods and final classes. Use this decorator to indicate to type checkers that the decorated method cannot be overridden, and decorated class cannot be subclassed. For example:: class Base: @final def done(self) -> None: ... class Sub(Base): def done(self) -> None: # Error reported by type checker ... @final class Leaf: ... class Other(Leaf): # Error reported by type checker ... There is no runtime checking of these properties. The decorator attempts to set the ``__final__`` attribute to ``True`` on the decorated object to allow runtime introspection. T) __final__rr)rs rwrVrV s54  H I &  H   TKTVTT_co) covariantV_coVT_coT_contra) contravariantCT_co)rboundrPaDeprecated alias to collections.abc.Callable. Callable[[int], str] signifies a function that takes a single parameter of type int and returns a str. The subscription syntax must always be used with exactly two values: the argument list and the return type. The argument list must be a list of types, a ParamSpec, Concatenate or ellipsis. The return type must be a single type. There is no syntax to indicate optional or keyword arguments; such function types are rarely used as callback types. rrf)r)r3rrra]Deprecated alias to builtins.tuple. Tuple[X, Y] is the cross-product type of X and Y. Example: Tuple[T1, T2] is a tuple of two elements corresponding to type variables T1 and T2. Tuple[int, float, str] is a tuple of an int, a float and a string. To specify a variable-length tuple of homogeneous type, use Tuple[T, ...]. rDrArFrGr"r6rBrCraDeprecated alias to builtins.type. builtins.type or typing.Type can be used to annotate class objects. For example, suppose we have the following classes:: class User: ... # Abstract base for User classes class BasicUser(User): ... class ProUser(User): ... class TeamUser(User): ... And a function that takes a class argument that's a subclass of User and returns an instance of the corresponding class:: def new_user[U](user_class: Type[U]) -> U: user = user_class() # (Here we could write the user object to a database) return user joe = new_user(BasicUser) At this point the type checker knows that joe has type BasicUser. c*eZdZdZdZedefdZy)r=z(An ABC with one abstract method __int__.rrcyrrr)s rw__int__zSupportsInt.__int__  ryN)rrrrrrintrrryrwr=r= s#2I   ryr=c*eZdZdZdZedefdZy)r;z*An ABC with one abstract method __float__.rrcyrrr)s rw __float__zSupportsFloat.__float__ rryN)rrrrrrfloatr rryrwr;r; #4I 5  ryr;c*eZdZdZdZedefdZy)r:z,An ABC with one abstract method __complex__.rrcyrrr)s rw __complex__zSupportsComplex.__complex__ rryN)rrrrrrcomplexrrryrwr:r: s#6I W  ryr:c*eZdZdZdZedefdZy)r9z*An ABC with one abstract method __bytes__.rrcyrrr)s rw __bytes__zSupportsBytes.__bytes__ rryN)rrrrrrbytesrrryrwr9r9 rryr9c*eZdZdZdZedefdZy)r<z*An ABC with one abstract method __index__.rrcyrrr)s rw __index__zSupportsIndex.__index__ rryN)rrrrrrr rrryrwr<r< s#4I 3  ryr<c>dxfGfdd }t|S)rc4eZdZWZdZdZedWfdZy)r8zMAn ABC with one abstract method __abs__ that is covariant in its return type.rrcyrrr)s rw__abs__zSupportsAbs.__abs__ rryN)rrrrcrrrr .type_paramsrsrwr8r8 s$WI   ryr8r .generic_baserrs @@rw#r" s  X ryc>dxfGfdd }t|S)rc:eZdZWZdZdZeddedWfdZy)r>zOAn ABC with one abstract method __round__ that is covariant in its return type.rndigitsrcyrr)rr%s rw __round__zSupportsRound.__round__ rryNr) rrrrcrrrr r'rsrwr>r> s+YI  Q  ryr>rr s @@rw%r) s  x ryrc |Dcgc]\}}| }}}|Dcic]\}}|t|d|d}}}tj||||}|x|_|j_|Scc}}wcc}}w)Nzfield z annotation must be a typedefaultsrq)rr namedtuplergrQ)rgrrqr,nrfieldsnm_tpls rw _make_nmtupler1 s! "EDAqaEF " A As*DEF F   # #D&-5fFF>CCFV^^; M # s A+A1> _makerQ_asdict_fields_sourcer_replacer__getnewargs___field_defaults>rrrgceZdZdZy)NamedTupleMetac t|vsJ|D]}|tus |tustdtd|D}|j di}g}|D]M}||vr|j ||std|dt |dkDrdndd d j|t||j|Dcgc]}|| c}|d  } || _ t|vrt} t| | _ |D]@} | tvrtd | z| t vs"| | j"vs1t%| | || Bt|vr| j'| Scc}w)Nz3can only inherit from a NamedTuple type and Genericc3<K|]}|turtn|ywr) _NamedTupler)rrs rwrz)NamedTupleMeta.__new__.. sOt{2e<rgzNon-default namedtuple field z cannot follow default fieldresr rrr+z&Cannot overwrite NamedTuple attribute )r=rrrrrrrr1rrr classmethodri _prohibitedr_specialr4rr) rtypenamer#nsrr default_names field_namer.r0 class_getitemrs rwrQzNamedTupleMeta.__new__ se###D;&4w+>IKKOOO("- JR$$Z0"? |L>*-m*??  x8E(F 1A (F&(&68! e 2M'2='AF $Ck!$%MPS%STTH$FNN)BRW-  e   $ $ & )Gs E N)rrrrQrryrwr:r: s ryr:c ||j}n |r tdt||t}tf|_|S)a?Typed version of namedtuple. Usage:: class Employee(NamedTuple): name: str id: int This is equivalent to:: Employee = collections.namedtuple('Employee', ['name', 'id']) The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) An alternative equivalent functional syntax is also accepted:: Employee = NamedTuple('Employee', [('name', str), ('id', int)]) zIEither list of fields or keywords can be provided to NamedTuple, not bothrq)rrr1r~rHr)rDr/rSnts rwrHrH sK(~ CD D x :B# B IryrHc$t|vsJtfSr)rHr=r#s rw_namedtuple_mro_entriesrN; s    >ryc"eZdZddZeZdZeZy)rc |D]'}t|tus|tustdt d|Drtf}nd}tj t|g|t |}t|ds||_i}|jdi} d} | jD cic]\} } | t| | |j } } } t} t}|D]}|j|jjdi|jjdt}| |z} ||z}|jjd t}| |z} ||z}|j| | jD]\}}t!|}|t"urt%|}|r|d }t!|}|t&urd }n |t(urd }n|}|r#| j+||j-|s|j+|| j-|| j/|sJd |d| d|||_t3| |_t3||_t|ds||_|Scc} } w)a7Create a new typed dict class object. This method is called when TypedDict is subclassed, or when TypedDict is instantiated. This way TypedDict supports all three syntax forms described in its docstring. Subclasses and instances of TypedDict return actual dictionaries. zHcannot inherit from both a TypedDict type and a non-TypedDict base classc3<K|]}t|tywr)rrrs rwrz)_TypedDictMeta.__new__..P s5u!z!W%ur>rrrgz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typerJ__required_keys____optional_keys__rTFz,Required keys overlap with optional keys in z: required_keys=z, optional_keys= __total__)rsrrrrrQrrrrrrrrupdaterrXrrWrerbrpdiscard isdisjointrgrLrRrSrT)rrgr#rEtotalr generic_basetp_dictrrown_annotationsrr.r required_keys optional_keys base_required base_optionalannotation_keyannotation_typeannotation_originannotation_args is_requireds rwrQz_TypedDictMeta.__new__C sDDz/D4G!ABB 5u5 5#:LL,,~t5J|5JT5JBOw 01%*G " &&!2B7O)..0 02 {2s7+=+=> >0    D   t}}001BBG H MM--.A35IM ] *M ] *M MM--.A35IM ] *M ] *M ?+/>/D/D/F +NO *? ;  I-"*?";"&5a&8O(2?(C% H," "k1# # !!.1%%n5!!.1%%n5)0G,'' 6 :4&A0-!1 3 6#.$-m$<!$-m$<!w , %G e s*#Jctd)Nz4TypedDict does not support instance and class checksr)rr4s rwr@z _TypedDictMeta.__subclasscheck__ sNOOryN)T)rrrrQrr0r@r<rryrwrrB sL\HP*ryrrXc ||}n |r td|rtjdtddt |i}t }|||d<t |d||}tf|_|S) a*A simple typed namespace. At runtime it is equivalent to a plain dict. TypedDict creates a dictionary type such that a type checker will expect all instances to have a certain set of keys, where each key is associated with a value of a consistent type. This expectation is not checked at runtime. Usage:: >>> class Point2D(TypedDict): ... x: int ... y: int ... label: str ... >>> a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK >>> b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check >>> Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first') True The type info can be accessed via the Point2D.__annotations__ dict, and the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets. TypedDict supports an additional equivalent form:: Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) By default, all keys must be present in a TypedDict. It is possible to override this by specifying totality:: class Point2D(TypedDict, total=False): x: int y: int This means that a Point2D TypedDict can have any of the keys omitted. A type checker is only expected to support a literal False or True as the value of the total argument. True is the default, and makes all items defined in the class body be required. The Required and NotRequired special forms can also be used to mark individual keys as being required or not required:: class Point2D(TypedDict): x: int # the "x" key must always be present (Required is the default) y: NotRequired[int] # the "y" key can be omitted See PEP 655 for more details on Required and NotRequired. z@TypedDict takes either a dict or keyword arguments, but not bothzThe kwargs-based syntax for TypedDict definitions is deprecated in Python 3.11, will be removed in Python 3.13, and may not be understood by third-party type checkers.r stacklevelrgrrrf) rr5warnDeprecationWarningrr~rrIr)rDr/rXrSrErqtds rwrIrI s^~ () )   7    T&\ *B YF !< "b 6B" B IryrIctfSr) _TypedDictrMs rwro s:-rycNt||jd}t||fS)aSpecial typing construct to mark a TypedDict key as required. This is mainly useful for total=False TypedDicts. For example:: class Movie(TypedDict, total=False): title: Required[str] year: int m = Movie( title='The Matrix', # typechecker error if key is omitted year=1999, ) There is no runtime checking that a required key is actually provided when instantiating a related TypedDict.  accepts only a single type.rrr}r]s rwrere s+( zdjj\1M#N OD w ''rycNt||jd}t||fS)a7Special typing construct to mark a TypedDict key as potentially missing. For example:: class Movie(TypedDict): title: str year: NotRequired[int] m = Movie( title='The Matrix', # typechecker error if key is omitted year=1999, ) rqrrr]s rwrbrb s+ zdjj\1M#N OD w ''ryc8eZdZdZeZdZdZdZdZ dZ dZ y) r^a+NewType creates simple unique types with almost zero runtime overhead. NewType(name, tp) is considered a subtype of tp by static type checkers. At runtime, NewType(name, tp) returns a dummy callable that simply returns its argument. Usage:: UserId = NewType('UserId', int) def name_by_id(user_id: UserId) -> str: ... UserId('user') # Fails type check name_by_id(42) # Fails type check name_by_id(UserId(42)) # OK num = UserId(5) + 1 # type: int c||_d|vr|jdd}||_||_t }|dk7r||_yy)Nr|rtyping)r rpartitionr __supertype__r~r)rrgrdef_mods rwrzNewType.__init__( sN  $;??3'+D ) h %DO ryc:|jGfdd}|fS)NceZdZfdZy)&NewType.__mro_entries__..Dummyc F|j}td|d|dd)NzGCannot subclass an instance of NewType. Perhaps you were looking for: `z = NewType(rz)`)rr)r subclass_namesuperclass_names rwrz8NewType.__mro_entries__..Dummy.__init_subclass__8 s: # %k-1B"_DUUWYryN)rrrr)rsrwDummyr|7 s ryrr)rr#rrs @rwr$zNewType.__mro_entries__2 s!--  xryc8|jd|jS)Nr|)rrr)s rwr*zNewType.__repr__A s//"!D$5$5#677ryc|jSr)rr)s rwr-zNewType.__reduce__D s   ryct||fSrr2r3s rwr5zNewType.__or__G r6ryct||fSrr2r3s rwr8zNewType.__ror__J r9ryN) rrrrr r0rr$r*r-r5r8rryrwr^r^ s,*H& 8!""ryr^ceZdZdZdZeedefdZeedefdZ ed!dZ eede fdZ ede fd Zed!d Zede fd Zed"d e defd Zede fdZed"de defdZed"de deefdZed#de de de fdZede fdZede fdZed$de de fdZede fdZedede fdZedeeddfdZed%dZed!d Zy)&rLaGeneric base class for TextIO and BinaryIO. This is an abstract, generic version of the return of open(). NOTE: This does not distinguish between the different possible classes (text vs. binary, read vs. write vs. read/write, append-only, unbuffered). The TextIO and BinaryIO subclasses below capture the distinctions between text vs. binary, which is pervasive in the interface; however we currently do not offer a way to track the other distinctions in the type system. rrcyrrr)s rwmodezIO.modee  rycyrrr)s rwrgzIO.namej rryNcyrrr)s rwclosezIO.closeo rrycyrrr)s rwclosedz IO.closeds rrycyrrr)s rwfilenoz IO.filenox rrycyrrr)s rwflushzIO.flush| rrycyrrr)s rwisattyz IO.isatty rryr.cyrr)rr.s rwreadzIO.read rrycyrrr)s rwreadablez IO.readable rrylimitcyrr)rrs rwreadlinez IO.readline rryhintcyrr)rrs rw readlinesz IO.readlines rryoffsetwhencecyrr)rrrs rwseekzIO.seek rrycyrrr)s rwseekablez IO.seekable rrycyrrr)s rwtellzIO.tell rrysizecyrr)rrs rwtruncatez IO.truncate rrycyrrr)s rwwritablez IO.writable rryr?cyrrrr?s rwwritezIO.write rrylinescyrr)rrs rw writelinesz IO.writelines rrycyrrr)s rw __enter__z IO.__enter__ rrycyrr)rrsr tracebacks rw__exit__z IO.__exit__ rry)rN)rr(r)rz IO[AnyStr]) rrrrrr`rrurrgrboolrr rrrrPrrrrDrrrrrrrrrrrryrwrLrLV sd I  c   c                c 6   $   c 6   c 4<   3  C   $   c   S C   $   v #   V        ryrLcJeZdZdZdZedeeefde fdZ eddZ y) rKz5Typed version of the return of open() in binary mode.rr?rcyrrrs rwrzBinaryIO.write rrycyrrr)s rwrzBinaryIO.__enter__ rryN)rrK) rrrrrrrr bytearrayr rrrryrwrKrK sH?I uUI-. 3    ryrKceZdZdZdZeedefdZeede fdZ eede e fdZ eede fdZeedefdZed d Zy ) rOz3Typed version of the return of open() in text mode.rrcyrrr)s rwbufferz TextIO.buffer rrycyrrr)s rwencodingzTextIO.encoding rrycyrrr)s rwerrorsz TextIO.errors rrycyrrr)s rwline_bufferingzTextIO.line_buffering rrycyrrr)s rwnewlineszTextIO.newlines rrycyrrr)s rwrzTextIO.__enter__ rryN)rrO)rrrrrr`rrKrrurrrrrrrrrryrwrOrO s=I     #          #    ryrOceZdZfdZxZS)_DeprecatedTypec|dvrD||jvr6tj|jd|jdtdt ||S)N>rrrz5 is deprecated, import directly from typing instead. z will be removed in Python 3.13.rrh)rr5rjrrkrJ__getattribute__)rrgrKs rwrz _DeprecatedType.__getattribute__ s^ < <AU MM<<.!((+ ~6""#  w'--ry)rrrrrMrNs@rwrr s  . .ryrc$eZdZdZgdZeZeZeZy)ioz)Wrapper namespace for IO generic classes.)rLrOrKN)rrrr__all__rLrOrKrryrwrr s3*G B FHryrz.ioc eZdZdZddgZeZeZy)rez&Wrapper namespace for re type aliases.rNrMN)rrrrrrNrMrryrwrr s0'"GG Eryrz.rec dx}fd|d|fdcS)rrrchtdt|jtj|S)aAsk a static type checker to reveal the inferred type of an expression. When a static type checker encounters a call to ``reveal_type()``, it will emit the inferred type of the argument:: x: int = 1 reveal_type(x) Running a static type checker (e.g., mypy) on this example will produce output similar to 'Revealed type is "builtins.int"'. At runtime, the function prints the runtime type of the argument and returns the argument unchanged. zRuntime type is )file)printrsrrstderrrs rwrfrf s* T#Y//2 3#**E Jryr) .defaultsrs rw#r sryc*eZdZWfdZZy)_IdentityCallablec"dx}fd|d|fdcS)rrvrcyrrrs rwr0z_IdentityCallable.__call__& s ryr)rr __classdict__s rwz z2_IdentityCallable.& s q  ryN)rrrr0__classdictcell__)rs@rwrr% s   ryr) eq_default order_defaultkw_only_defaultfrozen_defaultfield_specifiersrrrrr.rSc &fd}|S)asDecorator to mark an object as providing dataclass-like behaviour. The decorator can be applied to a function, class, or metaclass. Example usage with a decorator function:: @dataclass_transform() def create_model[T](cls: type[T]) -> type[T]: ... return cls @create_model class CustomerModel: id: int name: str On a base class:: @dataclass_transform() class ModelBase: ... class CustomerModel(ModelBase): id: int name: str On a metaclass:: @dataclass_transform() class ModelMeta(type): ... class ModelBase(metaclass=ModelMeta): ... class CustomerModel(ModelBase): id: int name: str The ``CustomerModel`` classes defined above will be treated by type checkers similarly to classes created with ``@dataclasses.dataclass``. For example, type checkers will assume these classes have ``__init__`` methods that accept ``id`` and ``name``. The arguments to this decorator can be used to customize this behavior: - ``eq_default`` indicates whether the ``eq`` parameter is assumed to be ``True`` or ``False`` if it is omitted by the caller. - ``order_default`` indicates whether the ``order`` parameter is assumed to be True or False if it is omitted by the caller. - ``kw_only_default`` indicates whether the ``kw_only`` parameter is assumed to be True or False if it is omitted by the caller. - ``frozen_default`` indicates whether the ``frozen`` parameter is assumed to be True or False if it is omitted by the caller. - ``field_specifiers`` specifies a static list of supported classes or functions that describe fields, similar to ``dataclasses.field()``. - Arbitrary other keyword arguments are accepted in order to allow for possible future extensions. At runtime, this decorator records its arguments in the ``__dataclass_transform__`` attribute on the decorated object. It has no other runtime effect. See PEP 681 for more details. c$d|_|S)N)rrrrrrS)__dataclass_transform__) cls_or_fnrrrrrSrs rwrz&dataclass_transform..decoratorq s'$*., 0 - )ryr)rrrrrrSrs`````` rwrUrU* sN   ry_Funcc tdtfSr)rrrryrwrr~ sXc3h ryc$ddx}fd|d|fdcS)FctSr)rrryrwrr sXrymethodrcB d|_|S#ttf$rY|SwxYw)aIndicate that a method is intended to override a method in a base class. Usage:: class Base: def method(self) -> None: pass class Child(Base): @override def method(self) -> None: super().method() When this decorator is applied to a method, the type checker will validate that it overrides a method or attribute with the same name on a base class. This helps prevent bugs that may occur when a base class is changed without an equivalent change to a child class. There is no runtime checking of this property. The decorator attempts to set the ``__override__`` attribute to ``True`` on the decorated object to allow runtime introspection. See PEP 698 for details. T) __override__rr)rs rwrdrd s62 " M I &  M  rr)rrs rw r sX q  ryrr)re__main__)r)NNF)r)rrrrrrcollections.abccopyregrrrr stdlib_rerrr5rrrr _typingr r r r rrrrrrxrrrrrrrrrrrrrrrrLrr rrrErsrHrrar]rhr\rrrrlrrrkrrlrrrrrrrrrrrrrr}r!r0r8r<rDrrqrrrmrZr_TYPING_INTERNALS_SPECIAL_NAMESrorsrur~rrrrrrrpicklerrrArrrrrgrSrQrBuiltinFunctionTyperrrrZrrXrWr[rrRr_r`rpartialrrrcrYrTrVrrrrrrrrrrurP_aliasr#r0r3r2r1r%r&r7r.r!r4rrFrr,r(r*r-r+r rrrrDdequerArrGr)r'r$r/rr"rr6rBrCrEr@r?rJr5rr=r;r:r9r<r8r>r1rBrCr:rHrQr=rNr$rrIrnrerbr^rirjrLrKrOrrrrrNrMrfrrUrrdrryrwrs *(# ^^   o l5PUB@ 02B <16/  A   U>% )+% PFF((/6 [__00!4 +//**A . ;??,,a 0 KOO.. 2  991CSTZCCQMbc dAE/[,,amD [,,a0 $$a ( +&& * ;??,,a 0  66: dAE/ 2 (   H   h   H   H      DE  B C!T!H:ll><R@ 5 U*TU*pEEN\\.+r2 > 7 ((.(($;";"~  ` ` F  r%y    RW  F .d .?  BKK ""A &y"?  BKK&  ! CE QQQ Q  Q DIc(::C?@ QQQh   ry