a DOg,@sdZddlmZmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z mZmZmZgdZddddd Zdddd d Zd dZddZddZddZddZddZgZdddddZefddZGdddZGd d!d!ZGd"d#d#ed d$Z Gd%d&d&e d d$Z!e d'd(Z"e d)d*Z#e d+d,Z$e d-d.Z%e d/d0Z&e d1d2Z'e!ed dd3d4Z(Gd5d6d6ed d$Z)Gd7d8d8eed d$Z*d9d:Z+Gd;d<dd>e,d d$Z-Gd?d@d@e,d d$Z.GdAdBdBe-d d$Z/GdCdDdDe.d d$Z0GdEdFdFe.d d$Z1GdGdHdHe-d d$Z2dIdJZ3GdKdLdLe-d d$Z4GdMdNdNZ5GdOdPdPZ6GdQdRdRZ7gdSZ8gdTZ9e8e9dUgZ:dVdWZ;dXdYZgd^d_d`gdaZ?GdbdcdceZ@Gdddedee5e@dfZAGdgdhdhe-d d$ZBGdidjdjZCdkdlZDdmdnZEdodpZFe jGe jHe jIe jJe eefZKddqdrZLdsdtZMdudvZNdwdxZOdydzZPd{d|ZQd}d~ZRddZSddZTe*dZUe*dZVe*dZWe*dd dZXe*dd dZYe*dd dZZe*dd dZ[e*dd e\dZ]e*de^e_Z`e.ZaeaejjbdZbeaejjcdZceaejjddZdeaejjedZeeaejjfdZfeaejjgdZgeaejjhdZheaejjidZieaejjjdZjeaejjkdZkeaejjldZle0ejjmdZmdem_eaejjndddZoeaejjpdZpeaejjqdZqeaejjrdZreaejjsdZseaejjtdZteaejjudZue1evddddZwdew_eaexddddZyeaejzdddZ{eae|ddddZneaeddddZ}eaejj~dZ~eaejjdZeaejjdZeaejjdZeaejdddZeaejdddZeaeddddZeaejdddZeaejdZeaejdZeaejdZeaejjdZeaejjdZeae\ddddZde_eDGdddeAZeDGdddeAZeDGdddeAZeDGdddeAZeDGdddeAZeDGdddeAeXZeDGdddeAeXZdddZehdZehdZGddde\ZdddZe\eddiZddZee_Gddde\Zdd dddZe\eddiZdd„e_ddĄZe_ZdZGddƄde5e`ZGddȄdee^ZGddʄdee_ZGdd̄d̃Zede_ee jej<eae jdZeae jdZGddτdσZ ede _e e je j<dS)a= The typing module: Support for gradual typing as defined by PEP 484. At large scale, the structure of the module is following: * Imports and exports, all public names should be explicitly added to __all__. * Internal helper functions: these should never be used in code outside this module. * _SpecialForm and its instances (special forms): Any, NoReturn, ClassVar, Union, Optional * Two classes whose instances can be type arguments in addition to types: ForwardRef and TypeVar * The core of internal generics API: _GenericAlias and _VariadicGenericAlias, the latter is currently only used by Tuple and Callable. All subscripted types like X[int], Union[int, str], etc., are instances of either of these classes. * The public counterpart of the generics API consists of two classes: Generic and Protocol. * Public helper functions: get_type_hints, overload, cast, no_type_check, no_type_check_decorator. * Generic aliases for collections.abc ABCs and few additional protocols. * Special types: NewType, NamedTuple, TypedDict. * Wrapper submodules for re and io related types. )abstractmethodABCMetaN)WrapperDescriptorTypeMethodWrapperTypeMethodDescriptorType GenericAlias)M AnnotatedAnyCallableClassVarFinal ForwardRefGenericLiteralOptionalProtocolTupleTypeTypeVarUnion AbstractSet ByteString ContainerContextManagerHashable ItemsViewIterableIteratorKeysViewMapping MappingViewMutableMappingMutableSequence MutableSetSequenceSized ValuesView Awaitable AsyncIterator AsyncIterable Coroutine CollectionAsyncGeneratorAsyncContextManager Reversible SupportsAbs SupportsBytesSupportsComplex SupportsFloat SupportsIndex SupportsInt SupportsRoundChainMapCounterDequeDict DefaultDictList OrderedDictSet FrozenSet NamedTuple TypedDict GeneratorBinaryIOIOMatchPatternTextIOAnyStrcastfinalget_args get_originget_type_hintsNewType no_type_checkno_type_check_decoratorNoReturnoverloadruntime_checkableText TYPE_CHECKINGFallow_special_formscCs,|durtdSt|tr(t|||dS|S)z=For converting None to type(None), and strings to ForwardRef.N)moduleis_class)type isinstancestrr )argrWrVr]+/opt/alt/python39/lib64/python3.9/typing.py _type_converts  r_TcCsttf}|s$|tf7}|r$|tf7}t|||d}t|trT|j|vrTt|d|t t tfvrf|St|t s||ttfvrtd|dt|t t tfr|St|st|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). )rWrVz is not valid as type argumentzPlain z Got z.100.)rrr r r_rZ _GenericAlias __origin__ TypeErrorr rP _SpecialFormrYrr callable)r\msg is_argumentrWrVinvalid_generic_formsr]r]r^ _type_checks&    ricCsft|tjrt|St|tr@|jdkr.|jS|jd|jS|durLdSt|tjr^|jSt|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`.z...) rZtypesrreprrY __module__ __qualname__ FunctionType__name__)objr]r]r^ _type_reprs    rrcsZg|D]H}t|tr(|vr(|t|ttfrfdd|jDqtS)zCollect all type variable contained in types in order of first appearance (lexicographic order). For example:: _collect_type_vars((T, List[S, T])) == (T, S) csg|]}|vr|qSr]r].0ttvarsr]r^ z&_collect_type_vars..)rZrappendrarextend__parameters__tuple)rkrur]rvr^_collect_type_varss r~c CsR|st|dt|}||krNtd||kr2dndd|d|d|dS) zCheck correct count for parameters of a generic cls (internal helper). This gives a nice error message in case of count mismatch. z is not a generic classzToo manyfewz parameters for z ; actual z , expected N)rclen)cls parameterselenalenr]r]r^_check_genericsrcCsVt|}t|t|krRg}|D] }||vr ||||q |}|rRJ||SN)setrrzremove)params all_params new_paramsrur]r]r^ _deduplicates   rcCsrg}|D]\}t|tr$||jqt|trZt|dkrZ|dturZ||ddq||qtt|S)zyAn internal helper for Union creation and substitution: flatten Unions among parameters, then remove duplicates. rN) rZ_UnionGenericAliasr{__args__r}rrrzrrrpr]r]r^_remove_dups_flattens " rcCs8g}|D]&}t|tr$||jq||qt|S)zJAn internal helper for Literal creation: flatten Literals among parameters)rZ_LiteralGenericAliasr{rrzr}rr]r]r^_flatten_literal_paramss   rtypedcs fdd}|dur||S|S)zInternal wrapper caching __getitem__ of generic types with a fallback to original function for non-hashable arguments. cs8tjdtjtfdd}|S)Nrcs2z|i|WSty"Yn0|i|Srrcargskwdscachedfuncr]r^inners  z+_tp_cache..decorator..inner) functools lru_cache _cleanupsrz cache_clearwraps)rrrrr^ decorator s  z_tp_cache..decoratorNr])rrrr]rr^ _tp_caches rcstt|tr|St|ttfrptfdd|jD}||jkrP|St|trft|j|S||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. c3s|]}t|VqdSr) _eval_typertaglobalnslocalnsrecursive_guardr]r^ &ryz_eval_type..) rZr _evaluaterarr}rrb copy_with)rurrrev_argsr]rr^rs     rc@seZdZdZdZddZdS)_FinalzMixin to prohibit subclassing) __weakref__cOsd|vrtddS)N_rootz&Cannot subclass special typing classesrselfrrr]r]r^__init_subclass__5sz_Final.__init_subclass__N)rprmrn__doc__ __slots__rr]r]r]r^r0src@s$eZdZdZdZddZddZdS) _Immutablez3Mixin to indicate that object should not be copied.r]cCs|Srr]rr]r]r^__copy__=sz_Immutable.__copy__cCs|Srr])rmemor]r]r^ __deepcopy__@sz_Immutable.__deepcopy__N)rprmrnrrrrr]r]r]r^r9src@sTeZdZdZddZddZddZdd Zd d Zd d Z ddZ e ddZ dS)rd)_namer_getitemcCs||_|j|_|j|_dSr)rrprr)rgetitemr]r]r^__init__Isz_SpecialForm.__init__cCstd|dS)NzCannot subclass r)rbasesr]r]r^__mro_entries__Nsz_SpecialForm.__mro_entries__cCs d|jSNtyping.rrr]r]r^__repr__Qsz_SpecialForm.__repr__cCs|jSrrrr]r]r^ __reduce__Tsz_SpecialForm.__reduce__cOstd|dS)NzCannot instantiate rrr]r]r^__call__Wsz_SpecialForm.__call__cCst|ddS)Nz! cannot be used with isinstance()rrrqr]r]r^__instancecheck__Zsz_SpecialForm.__instancecheck__cCst|ddS)Nz! cannot be used with issubclass()rrrr]r]r^__subclasscheck__]sz_SpecialForm.__subclasscheck__cCs |||Sr)rrrr]r]r^ __getitem__`sz_SpecialForm.__getitem__N) rprmrnrrrrrrrrrrr]r]r]r^rdFsrd)rc@seZdZddZdS)_LiteralSpecialFormcCs"t|ts|f}|j|g|RSr)rZr}rrr]r]r^rfs z_LiteralSpecialForm.__getitem__N)rprmrnrr]r]r]r^resrcCst|ddS)a`Special 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 or class checks.  is not subscriptableNrrr]r]r^r ls r cCst|ddS)aSpecial type indicating functions that never return. Example:: from typing import NoReturn def stop() -> NoReturn: raise Exception('no way') This type is invalid in other positions, e.g., ``List[NoReturn]`` will fail in static type checkers. rNrrr]r]r^rPzs rPcCst||d}t||fS)a3Special 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.rirarritemr]r]r^r sr cCst||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. rrrr]r]r^r sr cs`|dkrtdt|ts |f}dtfdd|D}t|}t|dkrV|dSt||S)a'Union type; Union[X, Y] means either X or 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.:: Union[Union[int, str], float] == Union[int, str, float] - Unions of a single argument vanish, e.g.:: Union[int] == int # The constructor actually returns int - Redundant arguments are skipped, e.g.:: Union[int, str, int] == Union[int, str] - When comparing unions, the argument order is ignored, e.g.:: 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]. r]z Cannot take a Union of no types.z)Union[arg, ...]: each arg must be a type.c3s|]}t|VqdSrrirtrrfr]r^rryzUnion..rr)rcrZr}rrrrr]rr^rs  rcCs t||d}t|tdfS)zEOptional type. Optional[X] is equivalent to Union[X, None]. z requires a single type.N)rirrY)rrr\r]r]r^rsrcGsHt|}z"tddttt|D}Wnty<Yn0t||S)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. css|]\}}|VqdSrr])rtr_r]r]r^rryzLiteral..)rr}rlist_value_and_type_iterrcrrr]r]r^rs " rc@sDeZdZdZdZdddddZd d Zd d Zd dZddZ dS)r z-Internal wrapper to hold a forward reference.)__forward_arg____forward_code____forward_evaluated____forward_value____forward_is_argument____forward_is_class____forward_module__TNF)rXcCsxt|tstd|zt|dd}Wn tyHtd|Yn0||_||_d|_d|_||_ ||_ ||_ dS)Nz*Forward reference must be a string -- got zevalz/Forward reference must be an expression -- got F) rZr[rccompile SyntaxErrorrrrrrrr)rr\rgrWrXcoder]r]r^r s  zForwardRef.__init__cCs|j|vr|S|jr||ur|dur6|dur6i}}n|durD|}n |durP|}|jdurrttj|jdd|}tt|j ||d|j |j d}t |||||jhB|_ d|_|j S)N__dict__z*Forward references must evaluate to types.)rgrVT)rrrgetattrsysmodulesgetrirrrrrr)rrrrtype_r]r]r^rs0    zForwardRef._evaluatecCsJt|tstS|jr2|jr2|j|jko0|j|jkS|j|jkoH|j|jkSr)rZr NotImplementedrrrrrotherr]r]r^__eq__5s      zForwardRef.__eq__cCst|j|jfSr)hashrrrr]r]r^__hash__>szForwardRef.__hash__cCsd|jdS)Nz ForwardRef())rrr]r]r^rAszForwardRef.__repr__)TN) rprmrnrrrrrrrr]r]r]r^r s r c@s6eZdZdZdZddddddZdd Zd d ZdS) raType variable. Usage:: T = TypeVar('T') # Can be anything A = TypeVar('A', str, bytes) # Must be str or bytes Type variables exist primarily for the benefit of static type checkers. They serve as the parameters for generic types as well as for generic function definitions. See class Generic for more information on generic types. Generic functions work as follows: def repeat(x: T, n: int) -> List[T]: '''Return a list containing n references to x.''' return [x]*n def longest(x: A, y: A) -> A: '''Return the longest of two strings.''' return x if len(x) >= len(y) else y The latter example's signature is essentially the overloading of (str, str) -> str and (bytes, bytes) -> bytes. Also note that if the arguments are instances of some subclass of str, the return type is still plain str. At runtime, isinstance(x, T) and issubclass(C, T) will raise TypeError. Type variables defined with covariant=True or contravariant=True can be used to declare covariant or contravariant generic types. See PEP 484 for more details. By default generic types are invariant in all type variables. Type variables can be introspected. e.g.: T.__name__ == 'T' T.__constraints__ == () T.__covariant__ == False T.__contravariant__ = False A.__constraints__ == (str, bytes) Note that only type variables defined in global scope can be pickled. )rp __bound____constraints__ __covariant____contravariant__rNF)bound covariant contravariantc s||_|r|rtdt||_t||_|r>|dur>td|rVt|dkrVtddtfdd|D|_|rt |d|_ nd|_ zt dj d d }Wnttfyd}Yn0|d kr||_dS) Nz"Bivariant types are not supported.z-Constraints cannot be combined with bound=...rz"A single constraint is not allowedz:TypeVar(name, constraint, ...): constraints must be types.c3s|]}t|VqdSrrrsrr]r^rryz#TypeVar.__init__..zBound must be a type.rp__main__typing)rp ValueErrorboolrrrcrr}rrirr _getframe f_globalsrAttributeErrorrm)rnamerrr constraintsdef_modr]rr^rts(    zTypeVar.__init__cCs&|jr d}n|jrd}nd}||jS)N+-~)rrrp)rprefixr]r]r^rs zTypeVar.__repr__cCs|jSr)rprr]r]r^rszTypeVar.__reduce__)rprmrnrrrrrr]r]r]r^rEs+  rcCs|do|dS)N__) startswithendswith)attrr]r]r^ _is_dundersrcsXeZdZdZdddddZddZd d Zd d Zfd dZddZ ddZ Z S)_BaseGenericAliasaThe central part of 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. TNinstrcCs||_||_||_d|_dSr)_instrrbr)roriginrrr]r]r^rsz_BaseGenericAlias.__init__cOsT|js"td|jd|jjd|j|i|}z ||_WntyNYn0|S)NzType z cannot be instantiated; use z () instead)rrcrrbrp__orig_class__r)rrkwargsresultr]r]r^rs    z_BaseGenericAlias.__call__cCsdg}|j|vr||j||}||ddD]}t|tsLt|tr4q\q4|tt|S)Nr)rbrzindexrZr issubclassrr})rrresibr]r]r^rs    z!_BaseGenericAlias.__mro_entries__cCs*d|jvrt|st|j|St|dS)Nrb)rrrrbr)rr r]r]r^ __getattr__s z_BaseGenericAlias.__getattr__cs2t|s|dvr t||nt|j||dS)N)rr_nparams)rsuper __setattr__setattrrb)rr val __class__r]r^rsz_BaseGenericAlias.__setattr__cCs|t|Sr)rrYrr]r]r^rsz#_BaseGenericAlias.__instancecheck__cCs tddS)NzBSubscripted generics cannot be used with class and instance checksrrr]r]r^rsz#_BaseGenericAlias.__subclasscheck__) rprmrnrrrrrrrr __classcell__r]r]r"r^rs   rcsdeZdZdddfdd ZddZdd Zed d Zd d ZddZ ddZ fddZ Z S)raTNrcsPtj|||dt|ts"|f}tdd|D|_t||_|sL|j|_dS)Nrcss*|]"}|turdn|turdn|VqdS).r]N)_TypingEllipsis _TypingEmptyrr]r]r^rs  z)_GenericAlias.__init__..)rrrZr}rr~r|rm)rrrrrr"r]r^rs   z_GenericAlias.__init__cCs&t|tstS|j|jko$|j|jkSr)rZrarrbrrr]r]r^rs    z_GenericAlias.__eq__cCst|j|jfSr)rrbrrr]r]r^rsz_GenericAlias.__hash__cs|jttfvrtd|t|ts,|f}dtfdd|D}t||t|jt t |j|g}|j D]X}t|t r|}n6t|t tfr|j}|rtfdd|D}||}||qr|t|S)Nz%Cannot subscript already-subscripted *Parameters to generic types must be types.c3s|]}t|VqdSrrrrr]r^rryz,_GenericAlias.__getitem__..c3s|]}|VqdSrr])rtx)substr]r^r ry)rbrrrcrZr}rrr|dictziprrrarrzr)rrnew_argsr\ subparamssubargsr])rfr)r^rs&     z_GenericAlias.__getitem__cCs|j|j||j|jdSN)rr)r#rbrrrrr]r]r^rsz_GenericAlias.copy_withcCsB|jrd|j}n t|j}ddd|jD}|d|dS)Nr, cSsg|] }t|qSr]rrrr]r]r^rxryz*_GenericAlias.__repr__..[])rrrrbjoinr)rrrr]r]r^rs   z_GenericAlias.__repr__cCsR|jrt|j}n|j}t|j}t|dkrDt|dtsD|\}tj||ffSNrr) rglobalsrbr}rrrZoperatorr)rrrr]r]r^rs z_GenericAlias.__reduce__csh|jrt|S|jtur`t|vr(dS||}||ddD]}t|trB||urBdSqB|jfS)Nr]r) rrrrbrrrrZr)rrrrr"r]r^r$s   z_GenericAlias.__mro_entries__) rprmrnrrrrrrrrrr$r]r]r"r^ras   racsTeZdZdddfdd ZeddZdd Zd d Zfd d ZddZ Z S)_SpecialGenericAliasTNrcs^|dur|j}tj|||d||_|jdkrBd|jd|_nd|jd|jd|_dS)NrrjzA generic version of r`)rprrrrmrnr)rrnparamsrrr"r]r^r6s z_SpecialGenericAlias.__init__csBt|ts|f}dtfdd|D}t|||j||S)Nr'c3s|]}t|VqdSrrrrr]r^rEryz3_SpecialGenericAlias.__getitem__..)rZr}rrrr0r]rr^r@s  z _SpecialGenericAlias.__getitem__cCst|j||j|jdSr/)rarbrrr0r]r]r^rIsz_SpecialGenericAlias.copy_withcCs d|jSrrrr]r]r^rMsz_SpecialGenericAlias.__repr__cs:t|trt|j|jSt|ts.t||jSt|Sr)rZr9rrbrarrrr"r]r^rPs    z&_SpecialGenericAlias.__subclasscheck__cCs|jSrrrr]r]r^rWsz_SpecialGenericAlias.__reduce__) rprmrnrrrrrrrr$r]r]r"r^r95s   r9cs$eZdZfddZddZZS)_CallableGenericAliascsj|jdksJt|jdkr4|jdtur4tSdddd|jddDd t|jdd S) Nr rztyping.Callable[[r1cSsg|] }t|qSr]r2rr]r]r^rxaryz2_CallableGenericAlias.__repr__..z], r4)rrrEllipsisrrr5rrrr"r]r^r\s  z_CallableGenericAlias.__repr__cCsD|j}t|dkr|ddus6t|dd|df}tjt|ffS)Nr<r.r=)rrrr8rr rrr]r]r^rdsz _CallableGenericAlias.__reduce__)rprmrnrrr$r]r]r"r^r;[s r;c@s(eZdZddZddZeddZdS) _CallableTypecCst|j||j|jdSr/)r;rbrrr0r]r]r^rlsz_CallableType.copy_withcCsPt|trt|dkrtd|\}}t|tr>t||f}n||f}||S)Nr<z6Callable must be used as Callable[[arg, ...], result].)rZr}rrcr__getitem_inner__)rrrrr]r]r^rps z_CallableType.__getitem__cCsb|\}}d}t||}|tur,|t|fSt|ts<|f}tdd|D}||f}||S)Nz.Callable[args, result]: result must be a type.css|]}t|VqdSr)r_)rtr\r]r]r^rryz2_CallableType.__getitem_inner__..)rir>rr%rZr})rrrrrfr]r]r^rA~s   z_CallableType.__getitem_inner__N)rprmrnrrrrAr]r]r]r^r@ksr@c@seZdZeddZdS) _TupleTypecs|dkr|tfSt|ts$|f}t|dkr\|ddur\dt|d}||tfSdtfdd |D}||S) Nr]r<r.z Tuple[t, ...]: t must be a type.rz*Tuple[t0, t1, ...]: each t must be a type.c3s|]}t|VqdSrrrrr]r^rryz)_TupleType.__getitem__..)rr&rZr}rrir%)rrrr]rr^rs  z_TupleType.__getitem__N)rprmrnrrr]r]r]r^rBsrBcs4eZdZddZddZddZfddZZS) rcCst|Sr)rr0r]r]r^rsz_UnionGenericAlias.copy_withcCs"t|tstSt|jt|jkSr)rZrrrrrr]r]r^rs z_UnionGenericAlias.__eq__cCstt|jSr)r frozensetrrr]r]r^rsz_UnionGenericAlias.__hash__csd|j}t|dkrZ|dtdur6dt|ddS|dtdurZdt|ddStS)Nr<rztyping.Optional[rr4)rrrYrrrrr?r"r]r^rs z_UnionGenericAlias.__repr__)rprmrnrrrrr$r]r]r"r^rsrcCsdd|DS)Ncss|]}|t|fVqdSr)rYrr]r]r^rryz'_value_and_type_iter..r])rr]r]r^rsrc@seZdZddZddZdS)rcCs*t|tstStt|jtt|jkSr)rZrrrrrrr]r]r^rs z_LiteralGenericAlias.__eq__cCsttt|jSr)rrCrrrr]r]r^rsz_LiteralGenericAlias.__hash__N)rprmrnrrr]r]r]r^rsrcs4eZdZdZdZdZeddZfddZZ S)raCAbstract base class for generic types. A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:: class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc. This class can then be used as follows:: def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default r]Fcst|ts|f}|s.|tur.td|jddtfdd|D}|ttfvrtdd|Dsxtd|jdt t |t |krtd|jd nt ||t |j t ||S) NzParameter list to z[...] cannot be emptyr'c3s|]}t|VqdSrrrrr]r^rryz,Generic.__class_getitem__..css|]}t|tVqdSr)rZrrr]r]r^rryzParameters to z [...] must all be type variablesz[...] must all be unique)rZr}rrcrnrrallrprrrr|ra)rrr]rr^__class_getitem__s&      zGeneric.__class_getitem__c stj|i|g}d|jvr,t|jv}nt|jvo>|jdk}|rLtdd|jvrt|j}d}|jD].}t |t rl|j turl|durtd|j }ql|durt |}t ||ksdfdd|D}ddd|D} td |d | d |}t||_ dS) N__orig_bases__rz!Cannot inherit from plain Genericz0Cannot inherit from Generic[...] multiple types.r1c3s|]}|vrt|VqdSrr[rsgvarsetr]r^r ryz,Generic.__init_subclass__..css|]}t|VqdSrrG)rtgr]r]r^r ryzSome type variables (z) are not listed in Generic[r4)rrrrrF __bases__rprcr~rZrarbr|rr5r}) rrrrwerrorgvarsbasetvarsets_varss_argsr"rHr^rs<          zGeneric.__init_subclass__) rprmrnrr _is_protocolrrErr$r]r]r"r^rs  rc@seZdZdZdS)r&zInternal placeholder for () or []. Used by TupleMeta and CallableMeta to allow empty list/tuple in specific places, without allowing them to sneak in where prohibited. Nrprmrnrr]r]r]r^r&sr&c@seZdZdZdS)r%z(Internal placeholder for ... (ellipsis).NrSr]r]r]r^r%sr%)r|rFrrR_is_runtime_protocol) __abstractmethods____annotations__rrrrm__new__r__subclasshook__rrE_MutableMapping__markercCsrt}|jddD]X}|jdvr$qt|di}t|jt|D] }|dsJ|tvrJ| |qJq|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=)rrrV_abc_) r__mro__rprrrkeysr EXCLUDED_ATTRIBUTESadd)rattrsrN annotationsr r]r]r^_get_protocol_attrs)s  racstfddtDS)Nc3s|]}tt|dVqdSr)rerrtr rr]r^r<ryz,_is_callable_members_only..)rDrarcr]rcr^_is_callable_members_only:srdcOstt|}|jrtd|jtur$dS|jD]$}|jdt}|tur*||_qXq*tj|_|j|g|Ri|dS)Nz Protocols cannot be instantiatedr) rYrRrcr_no_init_or_replace_initr[rrobject)rrrrrNinitr]r]r^re?s  rec Cs4ztdjddvWSttfy.YdS0dS)zAllow instance and class checks for special stdlib modules. The abc and functools modules indiscriminately call isinstance() and issubclass() on the whole MRO of a user class, which may contain protocols. rp)abcrTN)rrrrrr]r]r]r^_allow_reckless_class_cheks]srj) r r'rrr)rr%rr+r.AbstractContextManagerAbstractAsyncContextManager)zcollections.abc contextlibcseZdZfddZZS) _ProtocolMetacsVtddrtr$tjr$dSjrJtfddtDrJdStS)NrRFTc3s8|]0}t|o.tt|d p.t|duVqdSr)hasattrrerrbrinstancer]r^r}s z2_ProtocolMeta.__instancecheck__..) rrdrr#rRrDrarrrpr"rpr^rus  z_ProtocolMeta.__instancecheck__)rprmrnrr$r]r]r"r^rnrsrncs,eZdZdZdZdZdZfddZZS)raZBase 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(Protocol[T]): def meth(self) -> T: ... r]TFcstj|i|jdds6tddjD_fdd}djvrR|_js\dSjD]F}|tt fvsb|j t vr|j t |j vsbt |t r|jsbtd|qbt_dS) NrRFcss|]}|tuVqdSr)r)rtrr]r]r^rryz-Protocol.__init_subclass__..csjddstStdds0tr(tStdtsJtrBtStdt|ts\tdt D]v}|j D]b}||jvr|j|durtSqdt|di}t|t j j rn||vrnt|trn|jrnqdqntSqddS) NrRFrTzLInstance and class checks can only be used with @runtime_checkable protocolsz._proto_hookrXz7Protocols can only inherit from other protocols, got %r)rrrranyrKrRrXrfrrm_PROTO_WHITELISTrprrcrer)rrrrsrNr"rcr^rs, &   zProtocol.__init_subclass__) rprmrnrrrRrTrr$r]r]r"r^rs r) metaclasscsHeZdZdZfddZddZddZdd Zd d Zd d Z Z S)_AnnotatedAliasa7Runtime 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. cs2t|tr|j|}|j}t||||_dSr)rZrw __metadata__rbrr)rrmetadatar"r]r^rs   z_AnnotatedAlias.__init__cCs$t|dksJ|d}t||jSr6)rrwrx)rrnew_typer]r]r^rsz_AnnotatedAlias.copy_withcCs$dt|jddd|jDS)Nztyping.Annotated[{}, {}]r1css|]}t|VqdSr)rlrr]r]r^rryz+_AnnotatedAlias.__repr__..)formatrrrbr5rxrr]r]r^rsz_AnnotatedAlias.__repr__cCstjt|jf|jffSr)r8rrrbrxrr]r]r^rsz_AnnotatedAlias.__reduce__cCs&t|tstS|j|jko$|j|jkSr)rZrwrrbrxrr]r]r^rs    z_AnnotatedAlias.__eq__cCst|j|jfSr)rrbrxrr]r]r^r sz_AnnotatedAlias.__hash__) rprmrnrrrrrrrr$r]r]r"r^rws rwc@s0eZdZdZdZddZeddZddZd S) raAdd 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. - Nested Annotated are flattened:: Annotated[Annotated[T, Ann1, Ann2], Ann3] == Annotated[T, Ann1, Ann2, Ann3] - Instantiating an annotated type is equivalent to instantiating the underlying type:: Annotated[C, Ann1](5) == C(5) - Annotated can be used as a generic type alias:: Optimized = Annotated[T, runtime.Optimize()] Optimized[int] == Annotated[int, runtime.Optimize()] OptimizedList = Annotated[List[T], runtime.Optimize()] OptimizedList[int] == Annotated[List[int], runtime.Optimize()] r]cOs tddS)Nz&Type Annotated cannot be instantiated.rrrrr]r]r^rW2szAnnotated.__new__cCsNt|trt|dkrtdd}t|d|dd}t|dd}t||S)Nr<zUAnnotated[...] should be used with at least two arguments (a type and an annotation).z$Annotated[t, ...]: t must be a type.rTrUr)rZr}rrcrirw)rrrfrryr]r]r^rE5s zAnnotated.__class_getitem__cOstd|jdS)NzCannot subclass {}.Annotated)rcr{rmr|r]r]r^r@s zAnnotated.__init_subclass__N) rprmrnrrrWrrErr]r]r]r^rs  rcCs&t|tr|jstd|d|_|S)a9Mark 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! zB@runtime_checkable can be only applied to protocol classes, got %rT)rrrRrcrTrcr]r]r^rRFs rRcCs|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])typr!r]r]r^rH_srHc Csz |j}Wnty iYS0|j}|j}|d|}|jpBd}|j}|rVt|ni}|t|}t||d|D]\}} ||vsJ| ||<qx|S)z:Internal helper to extract the default arguments, by name.Nr]) __code__r co_argcount co_varnames __defaults____kwdefaults__r*rr+) rr pos_count arg_namesdefaults kwdefaultsr pos_offsetrvaluer]r]r^ _get_defaultsjs        rc Cst|ddriSt|tri}t|jD]|}|durDtj|jj}n|}|j di}| D]D\}} | durvtd} t| t rt | ddd} t | ||} | ||<q^q(|r|Sdd| DS|durt|tjr|j}n"|} t| d r| j} qt| d i}|dur|}n|dur|}t|dd}|durRt|trDiStd |t|} t|}| D]t\}} | durtd} t| t rt | t|tj dd} t | ||} || vr| |durt| } | ||<qj|r|Sd d| DS) aReturn type hints for an object. This is often the same as obj.__annotations__, but it handles forward references encoded as string literals, adds Optional[t] if a default value equal to None is set 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. - 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__NrVFT)rgrXcSsi|]\}}|t|qSr]_strip_annotationsrtkrur]r]r^ ryz"get_type_hints.. __wrapped__ __globals__z1{!r} is not a module, class, method, or function.cSsi|]\}}|t|qSr]rrr]r]r^rry)rrZrYreversedr[rrrmrritemsr[r rrk ModuleTyperor_allowed_typesrcr{rr*r) rqrrinclude_extrashintsrN base_globalsannrrnsobjrr]r]r^rLsf                   rLcCst|trt|jSt|trJtdd|jD}||jkr@|S||St|trtdd|jD}||jkrv|St|j|S|S)z.Strips the annotations from a given type. css|]}t|VqdSrrrr]r]r^rryz%_strip_annotations..css|]}t|VqdSrrrr]r]r^rry) rZrwrrbrar}rrr)ru stripped_argsr]r]r^rs        rcCs2t|trtSt|ttfr"|jS|tur.tSdS)aGet the unsubscripted version of a type. This supports generic types, Callable, Tuple, Union, Literal, Final, ClassVar and Annotated. Return None for unsupported types. Examples:: get_origin(Literal[42]) is Literal get_origin(int) is None get_origin(ClassVar[int]) is ClassVar get_origin(Generic) is Generic get_origin(Generic[T]) is Generic get_origin(Union[T, int]) is Union get_origin(List[Tuple[T, T]][int]) == list N)rZrwrrrrbr)tpr]r]r^rKs rKcCsft|tr|jf|jSt|ttfrb|j}|jtjj ur^|dt ur^t |dd|df}|SdS)aGet type arguments with all substitutions performed. For unions, basic simplifications used by Union constructor are performed. Examples:: get_args(Dict[str, int]) == (str, int) get_args(int) == () get_args(Union[int, Union[T, int], str][int]) == (int, str) get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int]) get_args(Callable[[], T][int]) == ([], int) rNr=r]) rZrwrbrxrarrrrrir r>r)rrr]r]r^rJ s rJcCst|trt|j}|jD]"\}}||j|fvr||q|D](}t|tj r`d|_ t|trJt |qJz d|_ Wnt yYn0|S)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. T) rZrYrcopyrrKpopvaluesrkrorrNrc)r\ arg_attrsr r!rqr]r]r^rNs         rNcstfdd}|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. cs|i|}t|}|Sr)rN)rrrrr]r^wrapped_decorator?sz2no_type_check_decorator..wrapped_decorator)rr)rrr]rr^rO8srOcOs tddS)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.N)NotImplementedErrorrr]r]r^_overload_dummyHsrcCstS)a Decorator 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. For example: @overload def utf8(value: None) -> None: ... @overload def utf8(value: bytes) -> bytes: ... @overload def utf8(value: str) -> bytes: ... def utf8(value): # implementation goes here )r)rr]r]r^rQQsrQcCs|S)aVA decorator 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. r])fr]r]r^rInsrITKTVTT_co)rV_coVT_coT_contra)rCT_co)rrrGrrhr<aCallable type; Callable[[int], str] is a function of (int) -> 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 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. r)rr=rra@Tuple type; 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, ...]. r;r8r=r>rr-r9r:raA special construct usable 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:: U = TypeVar('U', bound=User) def new_user(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@s&eZdZdZdZeedddZdS)r4z(An ABC with one abstract method __int__.r]returncCsdSrr]rr]r]r^__int__szSupportsInt.__int__N)rprmrnrrrintrr]r]r]r^r4sr4c@s&eZdZdZdZeedddZdS)r2z*An ABC with one abstract method __float__.r]rcCsdSrr]rr]r]r^ __float__szSupportsFloat.__float__N)rprmrnrrrfloatrr]r]r]r^r2sr2c@s&eZdZdZdZeedddZdS)r1z,An ABC with one abstract method __complex__.r]rcCsdSrr]rr]r]r^ __complex__ szSupportsComplex.__complex__N)rprmrnrrrcomplexrr]r]r]r^r1sr1c@s&eZdZdZdZeedddZdS)r0z*An ABC with one abstract method __bytes__.r]rcCsdSrr]rr]r]r^ __bytes__szSupportsBytes.__bytes__N)rprmrnrrrbytesrr]r]r]r^r0sr0c@s&eZdZdZdZeedddZdS)r3z*An ABC with one abstract method __index__.r]rcCsdSrr]rr]r]r^ __index__szSupportsIndex.__index__N)rprmrnrrrrrr]r]r]r^r3sr3c@s&eZdZdZdZeedddZdS)r/zMAn ABC with one abstract method __abs__ that is covariant in its return type.r]rcCsdSrr]rr]r]r^__abs__'szSupportsAbs.__abs__N)rprmrnrrrrrr]r]r]r^r/"sr/c@s*eZdZdZdZedeedddZdS) r5zOAn ABC with one abstract method __round__ that is covariant in its return type.r]r)ndigitsrcCsdSrr])rrr]r]r^ __round__1szSupportsRound.__round__N)r) rprmrnrrrrrrr]r]r]r^r5,sr5r]cCs@dd|D}dd|D}tj||||d}||_|j_|S)NcSsg|] \}}|qSr]r]rtnrur]r]r^rx7ryz!_make_nmtuple..cSs$i|]\}}|t|d|dqS)zfield z annotation must be a typerrr]r]r^r8sz!_make_nmtuple..rrW)rr namedtuplerVrW)rrkrWrfieldsnm_tplr]r]r^ _make_nmtuple6sr> rW_make__getnewargs___field_defaults_fieldsr_asdict_sourcer_replace>rVrprmc@seZdZddZdS)NamedTupleMetac s|dtusJdi}g}|D]L}|vr<||q$|r$td|dt|dkrZdnddd |q$t||fd d |Dd d }D]<}|tvrt d|q|t vr||j vrt |||q|S)NrrVzNon-default namedtuple field z cannot follow default fieldrs r1csg|] }|qSr]r])rtrnsr]r^rxWryz*NamedTupleMeta.__new__..rmrz&Cannot overwrite NamedTuple attribute ) _NamedTuplerrzrcrr5rr _prohibitedr_specialrr ) rtypenamerrrk default_names field_namerkeyr]rr^rWJs,     zNamedTupleMeta.__new__N)rprmrnrWr]r]r]r^rHsrc Ks`|dur|}n |rtdztdjdd}WnttfyPd}Yn0t|||dS)aTyped version of namedtuple. Usage in Python versions >= 3.6:: 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.) Alternative equivalent keyword syntax is also accepted:: Employee = NamedTuple('Employee', name=str, id=int) In Python versions <= 3.5 use:: Employee = NamedTuple('Employee', [('name', str), ('id', int)]) NzIEither list of fields or keywords can be provided to NamedTuple, not bothrrprrW) rrcrrrrrrr)rrrrWr]r]r^r?bs  r?cCs*t|dkrtd|dtus$JtfS)Nrz5Multiple inheritance with NamedTuple is not supportedr)rrcr?rrr]r]r^_namedtuple_mro_entriess rc@s&eZdZdddZeZddZeZdS)_TypedDictMetaTc s|D]}t|turtdqtt|tf|i}|di}t|}dfdd|D}t} t} |D]@}| |j di| |j dd| |j ddqx| ||r| |n | ||_ t | _ t | _td s |_S) a5Create 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 classrVz?TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a typecs"i|]\}}|t|jdqS)r)rirm)rtrrrftp_dictr]r^rsz*_TypedDictMeta.__new__..__required_keys__r]__optional_keys__ __total__)rYrrcrWr*rrr\rupdaterrVrCrrror) rrrrtotalrNr`own_annotationsown_annotation_keys required_keys optional_keysr]rr^rWs6           z_TypedDictMeta.__new__cCs tddS)Nz4TypedDict does not support instance and class checksr)rrr]r]r^rsz _TypedDictMeta.__subclasscheck__N)T)rprmrnrWr*rrrr]r]r]r^rs +rrc Ksj|dur|}n |rtddt|i}ztdjdd|d<WnttfyXYn0t|d||d S) aSA simple typed namespace. At runtime it is equivalent to a plain dict. TypedDict creates a dictionary type that expects all of its 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 but is only enforced by type checkers. 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 assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first') The type info can be accessed via the Point2D.__annotations__ dict, and the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets. TypedDict supports two additional equivalent forms:: Point2D = TypedDict('Point2D', x=int, y=int, label=str) 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. Usage:: 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 class syntax is only supported in Python 3.6+, while two other syntax forms work for Python 2.7 and 3.2+ Nz@TypedDict takes either a dict or keyword arguments, but not bothrVrrprrmr]r) rcr*rrrrrrr)rrrrrr]r]r^r@s* r@cCstfSr) _TypedDictrr]r]r^ryrcCsdd}||_||_|S)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 function 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 cSs|Srr])r(r]r]r^rzszNewType..new_type)rp __supertype__)rrrzr]r]r^rMsrMc@seZdZdZdZeeedddZeeedddZ eddd d Z eee dd d Z ee dd dZeddddZee dddZed7e edddZee dddZed8e edddZed9e eedddZed:e e e d d!d"Zee dd#d$Zee dd%d&Zed;e e d'd(d)Zee dd*d+Zeee d,d-d.Zeeedd/d0d1Zed2dd3d4Zeddd5d6ZdS)szIO.closecCsdSrr]rr]r]r^closedBsz IO.closedcCsdSrr]rr]r]r^filenoGsz IO.filenocCsdSrr]rr]r]r^flushKszIO.flushcCsdSrr]rr]r]r^isattyOsz IO.isattyr=)rrcCsdSrr])rrr]r]r^readSszIO.readcCsdSrr]rr]r]r^readableWsz IO.readable)limitrcCsdSrr])rrr]r]r^readline[sz IO.readline)hintrcCsdSrr])rrr]r]r^ readlines_sz IO.readlinesr)offsetwhencercCsdSrr])rrrr]r]r^seekcszIO.seekcCsdSrr]rr]r]r^seekablegsz IO.seekablecCsdSrr]rr]r]r^tellkszIO.tell)sizercCsdSrr])rrr]r]r^truncateosz IO.truncatecCsdSrr]rr]r]r^writablessz IO.writablerrcCsdSrr]rrr]r]r^writewszIO.write)linesrcCsdSrr])rrr]r]r^ writelines{sz IO.writelinesz IO[AnyStr]cCsdSrr]rr]r]r^ __enter__sz IO.__enter__cCsdSrr])rrYr tracebackr]r]r^__exit__sz IO.__exit__)r=)r=)r=)r)N) rprmrnrrpropertyrr[rrrrrrrrrrGrrrr;rrrrrrrrrrr]r]r]r^rC%sZ rCc@sBeZdZdZdZeeeefe dddZ eddddZ d S) rBz5Typed version of the return of open() in binary mode.r]rcCsdSrr]rr]r]r^rszBinaryIO.writercCsdSrr]rr]r]r^rszBinaryIO.__enter__N) rprmrnrrrrr bytearrayrrrr]r]r]r^rBs rBc@seZdZdZdZeeedddZeee dddZ eee e ddd Z eee dd d Zeeedd d ZeddddZdS)rFz3Typed version of the return of open() in text mode.r]rcCsdSrr]rr]r]r^buffersz TextIO.buffercCsdSrr]rr]r]r^encodingszTextIO.encodingcCsdSrr]rr]r]r^errorssz TextIO.errorscCsdSrr]rr]r]r^line_bufferingszTextIO.line_bufferingcCsdSrr]rr]r]r^newlinesszTextIO.newlinescCsdSrr]rr]r]r^rszTextIO.__enter__N)rprmrnrrrrrBrr[r rr rr r r rr]r]r]r^rFs&rFc@s$eZdZdZgdZeZeZeZdS)ioz)Wrapper namespace for IO generic classes.)rCrFrBN)rprmrnr__all__rCrFrBr]r]r]r^r s r z.ioc@s eZdZdZddgZeZeZdS)rez&Wrapper namespace for re type aliases.rErDN)rprmrnrrrErDr]r]r]r^rsrz.re)N)TN)N)NNF)r])N)N)rrirrrrcollections.abcrmrr8r stdlib_rerrkrrrrrr_rirrr~rrrrrrrCrrrrdrr rPr r rrrr rrrrar9r;r@rBrrrrr&r%_TYPING_INTERNALS_SPECIAL_NAMESr]rardrerjrurnrrwrrRrHrroBuiltinFunctionType MethodTyperrrLrrKrJrNrOrrQrIrrrrrrrrYrrr[rG_aliasrr'r*r)r(rrr.r%rr+r r=rr#rr!r$r"rr}rrr;dequer8rr>r rrr&rkrrlr-r*r9 defaultdictr:r<r7r6rAr,rr4r2r1r0r3r/r5rrrrr?rWrrrrr@rrMrSrTrCrBrFr rprrErDr]r]r]r^sh` !         %  !ATFS&! Q  b)5  ]                    #59 c#