def make_activity_endpoint(url: str, get_activity: Callable[[VarArg(str)], Activity]) -> Handler: """Make an API endpoint for an :class:`Activity` at *url*. *get_activity* is a function of the form *get_activity(*args)*, responsible for retrieving the activity. *args* are the URL arguments. """ return (r'{}{}$'.format(url, SLICE_URL), _ActivityEndpoint, {'get_activity': get_activity})
def skip_if( check_skip: t.Callable[[VarArg(t.Any), KwArg(t.Any)], bool], skip_return: t.Callable[[VarArg(t.Any), KwArg(t.Any)], t.Any] = lambda *a, **kw: None, ) -> t.Any: def decorator(func): @wraps(func) def wrapper(*args, **kwargs) -> t.Optional[t.Any]: if not check_skip(*args, **kwargs): result = func(*args, **kwargs) return result else: return skip_return(*args, **kwargs) return wrapper return decorator
def __init__( self, root: str, config: Config, docker_compose_func: Callable[[str, Config, VarArg(str)], int], ): super().__init__(root, config) self.docker_compose_func = docker_compose_func
def hasLabel( *labels: str, ) -> Tuple[Callable[[ VarArg(Any), NamedArg(Any, "traversal"), NamedArg(Union[str, Tuple[str, str]], "vertex"), ], bool, ], Tuple[str, ...], None, ]: return _hasLabel, labels, dict()
class Builtin(Obj): fn: Callable[[VarArg(Obj)], Obj] def type(self) -> ObjType: return ObjType.BUILTIN def inspect(self) -> str: return "Builtin function"
def make_list_endpoints( url: str, get_list: Callable[[VarArg(str)], Sequence[JSONifiable]]) -> List[Handler]: """Make the API endpoints for a list with support for slicing. *url* is the URL of the list. *get_list* is a hook of the form *get_list(*args)*, responsible for retrieving the underlying list. *args* are the URL arguments. """ return [(url + r'(?:/(\d*:\d*))?$', _ListEndpoint, {'get_list': get_list})]
def __getattr__(self, attr: str) -> Callable[ [VarArg(Any), KwArg(Any)], Any]: '''Proxy calls to settings store.''' if hasattr(self.__dict__.get('data'), attr): def wrapper(*args, **kwargs): '''Call query for data store.''' return getattr(self.data, attr)(*args, **kwargs) return wrapper raise AttributeError(attr)
def make_activity_endpoints(url: str, get_activity: Callable[[VarArg(str)], Activity]) -> List[Handler]: """Make API endpoints for an :class:`Activity` at *url*. *get_activity* is a function of the form ``get_activity(*args)``, responsible for retrieving the activity. *args* are the URL arguments. """ return [ (fr'{url}{SLICE_URL}$', _ActivityEndpoint, {'get_activity': get_activity}), (fr'{url}/stream$', ActivityStreamEndpoint, {'get_activity': get_activity}) ]
async def run_task(self, async_fn: Callable[[VarArg()], Awaitable[Any]], *args: Any, daemon: bool = False, name: str = None) -> None: """ Run a task in the background. If the function throws an exception it will trigger the service to be cancelled and be propogated. If `daemon == True` then the the task is expected to run indefinitely and will trigger cancellation if the task finishes. """ ...
def create( root: str, config: Dict[str, Any], docker_compose_func: Callable[[str, Dict[ str, Any], VarArg(str)], int], service: str, path: str, ) -> str: volumes_root_path = get_root_path(root) volume_name = get_name(path) container_volumes_root_path = "/tmp/volumes" command = """rm -rf {volumes_path}/{volume_name} cp -r {src_path} {volumes_path}/{volume_name} chown -R {user_id} {volumes_path}/{volume_name}""".format( volumes_path=container_volumes_root_path, volume_name=volume_name, src_path=path, user_id=get_user_id(), ) # Create volumes root dir if it does not exist. Otherwise it is created with root owner and might not be writable # in the container, e.g: in the dev containers. if not os.path.exists(volumes_root_path): os.makedirs(volumes_root_path) docker_compose_func( root, config, "run", "--rm", "--no-deps", "--volume", "{}:{}".format(volumes_root_path, container_volumes_root_path), service, "sh", "-e", "-c", command, ) return os.path.join(volumes_root_path, volume_name)
def load(region: str) -> Spec: specs = json.loads( importlib.resources.read_text(__package__, f"{region}.json")) rescs: MutableMapping[str, MutableMapping[str, MutableMapping[ str, Callable[[VarArg(), KwArg()], Resource]]], ] = {} for typ, spec in specs["ResourceTypes"].items(): rvnd, rsvc, rcom = typ.split("::") vnd, svc, com = TRANS[rvnd], TRANS[rsvc], TRANS[rcom] svc = "lambda_" if svc == "lambda" else svc attrs: MutableMapping[str, Union[Type[types.Ref], Type[types.Attr]]] = { TRANS[a]: _resolve_attr(a, s) for a, s in spec.get( "Attributes", {}).items() } attrs["ref"] = types.Ref check = _resolve_check(typ, spec, specs) def bake(vnd_, svc_, com_, typ_, attrs_, check_): def factory(*args, **kwargs) -> Resource: name = next(iter(args), "") # props = dict(kwargs) if kwargs else None res = Resource(name, vnd_, svc_, com_, typ_, attrs_, check_, dict(kwargs)) return res factory.__module__ = ".".join(["ic", vnd_, svc_]) factory.__name__ = com_ factory.__qualname__ = com_ sigs = [ inspect.Parameter(p, inspect.Parameter.KEYWORD_ONLY) for p in check_.items ] # python/myp#5958 factory.__signature__ = inspect.Signature(sigs) # type: ignore return factory resc = bake(vnd, svc, com, typ, attrs, check) rescs.setdefault(vnd, {}).setdefault(svc, {})[com] = resc return rescs
Kwargs = Dict[str, Any] KwargsLike = Union[None, Kwargs] KwargsLikeSequence = MaybeSequence[KwargsLike] FileName = Union[str, Path] # Data Data = Dict[Label, SeriesFrame] # Plotting TraceName = Union[str, None] TraceNames = MaybeSequence[TraceName] # Generic I = TypeVar("I") R = TypeVar("R") ApplyFunc = Callable[[int, Array1d, VarArg()], MaybeArray] RowApplyFunc = Callable[[int, Array1d, VarArg()], MaybeArray] RollApplyFunc = Callable[[int, int, Array1d, VarArg()], Scalar] RollMatrixApplyFunc = Callable[[int, Array2d, VarArg()], MaybeArray] GroupByApplyFunc = Callable[[Array1d, int, Array1d, VarArg()], Scalar] GroupByMatrixApplyFunc = Callable[[Array1d, Array2d, VarArg()], MaybeArray] ApplyMapFunc = Callable[[int, int, I, VarArg()], Scalar] FilterFunc = Callable[[int, int, I, VarArg()], bool] ReduceFunc = Callable[[int, Array1d, VarArg()], Scalar] ReduceArrayFunc = Callable[[int, Array1d, VarArg()], Array1d] GroupReduceFunc = Callable[[int, Array2d, VarArg()], Scalar] FlatGroupReduceFunc = Callable[[int, Array1d, VarArg()], Scalar] GroupReduceArrayFunc = Callable[[int, Array2d, VarArg()], Array1d] FlatGroupReduceArrayFunc = Callable[[int, Array1d, VarArg()], Array1d] GroupSqueezeFunc = Callable[[int, int, Array1d, VarArg()], R]
if hasattr(base, "VALIDATORS"): validators.update(base.VALIDATORS) # type: ignore for attr_name, attr in namespace.items(): if attr_name.startswith('validate_'): validators.add(attr_name) cls = super(TypeMeta, mcs).__new__(mcs, name, bases, namespace, *args, **kwargs) cls.VALIDATORS = validators # type: ignore return cls Validator = ty.Union[ ty.Callable[ [Arg(T, 'value'), Arg(ty.Any, 'original'), VarArg(ty.Any), KwArg(ty.Any)], ValidationResult ], AbstractValidator[T] ] DefaultValue = ty.Union[ty.Any, ty.Callable[[], ty.Any]] Types = ty.Tuple[type, ...] class BaseType(AbstractConvertible[T], metaclass=TypeMeta): """Base type :param default: default value :param nullable: invalidate when value is None :param enum: determines allowed values
from typing import TYPE_CHECKING, cast as typingcast if TYPE_CHECKING: from typing import (Callable, MutableMapping, Any, Sequence, List, Union, Iterable, Tuple) from mypy_extensions import VarArg MergeBaseCallable = Callable[[MutableMapping[ str, Any], VarArg(str)], Union[MutableMapping[str, Any], List[Any]]] MergeFunctionType = Callable[ [MutableMapping[str, Any], Sequence[str], str], None] def getMapOp(operation: 'Callable', dict_obj: 'MutableMapping[str, Any]', initial_value: 'Any', *args: str) -> 'Any': out = initial_value for key in args: val = dict_obj.get(key) if val is not None: operation(out, val) return out def getMapConcat(dict_obj: 'MutableMapping[str, MutableMapping[str, Any]]', *args: str) -> 'MutableMapping[str, Any]': return typingcast( 'MutableMapping[str, Any]', getMapOp(lambda first, second: first.update(second), dict_obj, {}, *args))
pass class InsertOptions(OptionBlock, ServerDurableOption, ClientDurableOption): pass class GetFromReplicaOptions(OptionBlock): pass T = TypeVar('T', bound='CBCollection') R = TypeVar("R") RawCollectionMethodDefault = Callable[ [Arg('CBCollection', 'self'), Arg(str, 'key'), VarArg(OptionBlockDeriv), KwArg(Any)], R] RawCollectionMethodInt = Callable[ [Arg('CBCollection', 'self'), Arg(str, 'key'), int, VarArg(OptionBlockDeriv), KwArg(Any)], R] RawCollectionMethod = Union[RawCollectionMethodDefault, RawCollectionMethodInt] RawCollectionMethodSpecial = TypeVar('RawCollectionMethodSpecial',bound=RawCollectionMethod) def _get_result_and_inject(func # type: RawCollectionMethod ): # type: (...) ->RawCollectionMethod result = _inject_scope_and_collection(get_result_wrapper(func)) result.__doc__=func.__doc__ result.__name__=func.__name__ return result
class DiscoveryV5Module(ModuleV2): # type: ignore """ A web3.py module that exposes high level APIs for interacting with the discovery v5 network. """ get_node_info: Method[Callable[[], NodeInfo]] = Method( RPC.nodeInfo, result_formatters=lambda method, module: NodeInfo.from_rpc_response, ) update_node_info: Method[Callable[ [VarArg(ENR_KV)], UpdateENRPayload]] = Method( RPC.updateNodeInfo, result_formatters=lambda method, module: UpdateENRPayload. from_rpc_response, mungers=[kv_pair_munger], ) get_routing_table_info: Method[Callable[[], TableInfo]] = Method( RPC.routingTableInfo, result_formatters=lambda method, module: TableInfo.from_rpc_response, ) get_enr: Method[Callable[[NodeIDIdentifier], GetENRPayload]] = Method( RPC.getENR, result_formatters=lambda method, module: GetENRPayload. from_rpc_response, mungers=[node_identifier_munger], ) set_enr: Method[Callable[[str], EmptyPayload]] = Method( RPC.setENR, result_formatters=lambda method, module: EmptyPayload. from_rpc_response, mungers=[node_identifier_munger], ) delete_enr: Method[Callable[[NodeIDIdentifier], EmptyPayload]] = Method( RPC.deleteENR, result_formatters=lambda method, module: EmptyPayload. from_rpc_response, mungers=[node_identifier_munger], ) lookup_enr: Method[Callable[[NodeIDIdentifier], GetENRPayload]] = Method( RPC.lookupENR, result_formatters=lambda method, module: GetENRPayload. from_rpc_response, mungers=[node_identifier_and_sequence_munger], ) ping: Method[Callable[[NodeIDIdentifier], PongPayload]] = Method( RPC.ping, result_formatters=lambda method, module: PongPayload.from_rpc_response, mungers=[node_identifier_munger], ) send_ping: Method[Callable[[NodeIDIdentifier], SendPingPayload]] = Method( RPC.sendPing, result_formatters=lambda method, module: SendPingPayload. from_rpc_response, mungers=[node_identifier_munger], ) send_pong: Method[Callable[[NodeIDIdentifier, HexStr], EmptyPayload]] = Method( RPC.sendPong, result_formatters=lambda method, module: EmptyPayload.from_rpc_response, mungers=[send_pong_munger], ) find_nodes: Method[Callable[[NodeIDIdentifier, Union[int, Sequence[int]]], Tuple[ENRAPI, ...]]] = Method( RPC.findNodes, result_formatters=lambda method, module: find_nodes_response_formatter, mungers=[find_nodes_munger], ) send_find_nodes: Method[ Callable[[NodeIDIdentifier, Union[int, Sequence[int]]], HexStrPayload]] = Method( RPC.sendFindNodes, result_formatters=lambda method, module: HexStrPayload. from_rpc_response, mungers=[find_nodes_munger], ) send_found_nodes: Method[Callable[ [NodeIDIdentifier, Tuple[ENRAPI], HexStr], IntegerPayload]] = Method( RPC.sendFoundNodes, result_formatters=lambda method, module: IntegerPayload. from_rpc_response, mungers=[send_found_nodes_munger], ) send_talk_request: Method[Callable[ [NodeIDIdentifier, HexStr, HexStr], HexStrPayload]] = Method( RPC.sendTalkRequest, result_formatters=lambda method, module: HexStrPayload. from_rpc_response, mungers=[talk_request_munger], ) send_talk_response: Method[Callable[ [NodeIDIdentifier, HexStr, HexStr], EmptyPayload]] = Method( RPC.sendTalkResponse, result_formatters=lambda method, module: EmptyPayload. from_rpc_response, mungers=[talk_request_munger], ) talk: Method[Callable[[NodeIDIdentifier, HexStr, HexStr], HexStrPayload]] = Method( RPC.talk, result_formatters=lambda method, module: HexStrPayload.from_rpc_response, mungers=[talk_request_munger], ) bond: Method[Callable[[NodeIDIdentifier], BoolPayload]] = Method( RPC.bond, result_formatters=lambda method, module: BoolPayload.from_rpc_response, mungers=[node_identifier_munger], ) recursive_find_nodes: Method[Callable[[NodeIDIdentifier], Tuple[ ENRAPI, ...]]] = Method( RPC.recursiveFindNodes, result_formatters=lambda method, module: find_nodes_response_formatter, mungers=[node_identifier_munger], )
self._reqs.extend(deps) def deletion(self, policy: str): policies = {"delete", "retain", "snapshot"} if policy not in policies: raise ValueError( f"invalid deletion policy {policy!r}, expected one of {policies}" ) self._deletion = policy # python/myp#220 deletion = property(fset=deletion) # type: ignore Spec = Mapping[str, Mapping[str, Mapping[str, Callable[[VarArg(), KwArg()], Resource]]]] @lru_cache(maxsize=None) def load(region: str) -> Spec: specs = json.loads( importlib.resources.read_text(__package__, f"{region}.json")) rescs: MutableMapping[str, MutableMapping[str, MutableMapping[ str, Callable[[VarArg(), KwArg()], Resource]]], ] = {} for typ, spec in specs["ResourceTypes"].items(): rvnd, rsvc, rcom = typ.split("::") vnd, svc, com = TRANS[rvnd], TRANS[rsvc], TRANS[rcom] svc = "lambda_" if svc == "lambda" else svc attrs: MutableMapping[str, Union[Type[types.Ref], Type[types.Attr]]] = {
from functools import wraps from threading import local from typing import Any, Callable, cast, Dict, Generic, Iterable, Iterator, List, Optional, Sequence, TypeVar, Text, Tuple, Union from typing_extensions import Protocol from mypy_extensions import KwArg, VarArg import sys SomeFunction = Callable[[VarArg(), KwArg()], Any] _F = TypeVar("_F", bound=Callable[..., Any]) class SupportsClose(Protocol): def close(self, *args: Any, **kwargs: Any) -> None: ... _T = TypeVar("_T", bound=SupportsClose) class Cursor(Iterator[Any], Protocol): arraysize: Any connection: Any description: Any lastrowid: Any row_factory: Any rowcount: Any def __init__(self, *args: Any, **kwargs: Any) -> None: ...
Args = TypedDict('Args', { 'config': str, 'outdir': str, 'ref': str, 'r1': str, 'r2': str, 'sample': str }) PathLike = str Targets = List[PathLike] FileDeps = List[PathLike] Failure = Literal[False] ActionReturn = Union[Failure, None, Dict[str, Any]] PyAction = Callable[[List[PathLike], List[PathLike], VarArg(Any)], ActionReturn] Actions = List[Union[PyAction, str]] IdxBamJob = TypedDict( 'IdxBamJob', { 'targets': Targets, 'actions': Actions, 'file_dep': FileDeps, 'task_dep': List[Literal['index_bam']] }) TaskDepJob = TypedDict( 'TaskDepJob', { 'targets': Targets, 'actions': Actions, 'file_dep': FileDeps,
Kwargs = Dict[str, Any] KwargsLike = Union[None, Kwargs] KwargsLikeSequence = MaybeSequence[KwargsLike] FileName = Union[str, Path] # Data Data = Dict[Label, SeriesFrame] # Plotting TraceName = Union[str, None] TraceNames = MaybeSequence[TraceName] # Generic I = TypeVar("I") R = TypeVar("R") ApplyFunc = Callable[[int, Array1d, VarArg()], R] RollApplyFunc = Callable[[int, int, Array1d, VarArg()], R] RollApplyMatrixFunc = Callable[[int, Array2d, VarArg()], R] GroupByApplyFunc = Callable[[Array1d, int, Array1d, VarArg()], R] GroupByApplyMatrixFunc = Callable[[Array1d, Array2d, VarArg()], R] ApplyMapFunc = Callable[[int, int, I, VarArg()], R] ReduceFunc = Callable[[int, Array1d, VarArg()], R] GroupReduceFunc = Callable[[int, Array2d, VarArg()], R] GroupReduceFlatFunc = Callable[[int, Array1d, VarArg()], R] GroupSqueezeFunc = Callable[[int, int, Array1d, VarArg()], R] # Signals SignalChoiceFunc = Callable[[int, int, int, VarArg()], Array1d] SignalMapFunc = Callable[[int, int, int, VarArg()], float] SignalReduceFunc = Callable[[int, Array1d, VarArg()], float]
'Response', 'ResourceOptions', 'View', 'ViewHandlerMethod', 'ViewHandlerFun', 'ViewDecorator', 'PageArg', 'HttpClientT', 'Web', 'CacheBackendT', 'CacheT', 'BlueprintT', ] ViewHandlerMethod = Callable[ [Arg(Request), VarArg(Any), KwArg(Any)], Awaitable[Response], ] ViewHandler2ArgsFun = Callable[ [Arg(View), Arg(Request)], Union[Coroutine[Any, Any, Response], Awaitable[Response]], ] ViewHandlerVarArgsFun = Callable[ [Arg(View), Arg(Request), VarArg(Any), KwArg(Any)], Union[Coroutine[Any, Any, Response], Awaitable[Response]], ] ViewHandlerFun = Union[ViewHandler2ArgsFun, ViewHandlerVarArgsFun]
'FilterReceiverMapping', 'SignalHandlerT', 'SignalHandlerRefT', 'SignalT', 'SyncSignalT', 'T', 'T_contra', ] T = TypeVar('T') T_contra = TypeVar('T_contra', contravariant=True) signal = None # just here to fix flake8 bug SignalHandlerT = Union[Callable[ [T, VarArg(), NamedArg('BaseSignalT', name='signal'), KwArg()], None, ], Callable[ [T, VarArg( ), NamedArg('BaseSignalT', name='signal'), KwArg()], Awaitable[None], ], ] if typing.TYPE_CHECKING: SignalHandlerRefT = Union[Callable[[], SignalHandlerT], ReferenceType[SignalHandlerT]] else: SignalHandlerRefT = Any FilterReceiverMapping = MutableMapping[Any, MutableSet[SignalHandlerRefT]] class BaseSignalT(Generic[T]):
""" Covariance estimation for 2SLS and LIML IV estimators """ from typing import Any, Callable, Dict, Union from mypy_extensions import VarArg from numpy import (arange, argsort, asarray, ceil, cos, empty, int64, ndarray, ones, pi, r_, sin, sum as npsum, unique, where, zeros) from numpy.linalg import inv, pinv from linearmodels.typing import Numeric, OptionalNumeric KernelWeight = Union[Callable[[int, float], ndarray], Callable[[float, float], ndarray], Callable[[int, VarArg(Any)], ndarray], Callable[[Numeric, int], Any]] CLUSTER_ERR = """ clusters has the wrong nobs. Expected {0}, got {1}. Any missing observation in the regression variables have have been dropped. When using a clustered covariance estimator, drop missing data before estimating the model. The model property `notnull` contains the locations of the observations that have no missing values.""" def _cov_cluster(z: ndarray, clusters: ndarray) -> ndarray: """ Core cluster covariance estimator Parameters ----------
TargetFunctionT = TypeVar('TargetFunctionT', bound=Callable[..., Any]) # TargetReturnT]) """Type for decorated function""" #FUTURE: Currently (mypy 0.800) not possible to declare generic `TypeVar` # https://github.com/python/mypy/issues/8278 # Would need to use Callable[..., TargetReturnT] directly. TargetClassT = TypeVar('TargetClassT', bound=object) """Type for decorated class""" TargetT = TypeVar('TargetT', Callable[..., Any], Type[object]) """Type for decorated function or class""" TargetFunctionWrapper = Callable[[ Arg(Callable[..., TargetReturnT], 'target'), VarArg(), KwArg() ], TargetReturnT] # Callable[[TargetFunctionT, ...], TargetReturnT] """ Generic type for function that calls the decorated function :param TargetReturnT: Return type of the decorated function. """ TargetMethodWrapper = Callable[[ Arg(Callable[..., TargetReturnT], 'target'), Arg(TargetClassT, 'instance'), Arg(Type[TargetClassT], 'cls'), VarArg(), KwArg() ], TargetReturnT] # Callable[[TargetFunctionT, ...], TargetReturnT] """
ndarray, ones, pi, sin, sum as npsum, unique, zeros, ) from numpy.linalg import inv, pinv from linearmodels.shared.covariance import cov_cluster, cov_kernel from linearmodels.typing import NDArray, Numeric, OptionalNumeric KernelWeight = Union[Callable[[float, float], ndarray], Callable[[float, int], ndarray], Callable[[float, VarArg(Any)], ndarray], ] CLUSTER_ERR = """ clusters has the wrong nobs. Expected {0}, got {1}. Any missing observation in the regression variables have have been dropped. When using a clustered covariance estimator, drop missing data before estimating the model. The model property `notnull` contains the locations of the observations that have no missing values.""" def kernel_weight_bartlett(bw: float, *args: int) -> NDArray: r""" Kernel weights from a Bartlett kernel Parameters ----------
async def run_task(self, async_fn: Callable[[VarArg()], Awaitable[Any]], *args: Any, daemon: bool = False, name: str = None) -> None: """ Run a task in the background. If the function throws an exception it will trigger the service to be cancelled and be propogated. If `daemon == True` then the the task is expected to run indefinitely and will trigger cancellation if the task finishes. """ ... LogicFnType = Callable[[ManagerAPI, VarArg(), KwArg()], Awaitable[Any]] class Service(ServiceAPI): pass def as_service(service_fn: LogicFnType) -> Type[Service]: """ Create a service out of a simple function """ class _Service(Service): def __init__(self, *args: Any, **kwargs: Any): self._args = args self._kwargs = kwargs
def ap(f: typing.Callable[[Judge, VarArg(AbsVal)], CallSpec]): shape.fields[attr] = f return f
class CombNonOpt(Protocol[QueryLike]): def __call__(x, self: QueryLike, *args: Any, **kwargs: Any) -> QueryLike: ... class Combiner2(Protocol[QueryLike]): def __call__(x, self: QueryLike, __arg) -> Optional[QueryLike]: ... # BuilderFuncSignature = Callable[[Arg(QueryLike, 'self'), VarArg(), KwArg()], Optional[QueryLike]] # BuilderFuncNoArgSignature = Callable[[Arg(QueryLike, 'self')], Optional[QueryLike]] # BuilderFuncSingleArgSignature = Callable[[Arg(QueryLike, 'self'), Arg(Any)], Optional[QueryLike]] # BuilderFuncTwoArgSignature = Callable[[Arg(QueryLike, 'self'), Arg(Any), Arg(Any)], Optional[QueryLike]] BuilderDecSignature = Callable[[Arg( QueryLike, 'self'), VarArg(), KwArg()], QueryLike] def builder( func: Union[Combiner[QueryLike], Combiner2[QueryLike]] ) -> Callable[..., QueryLike]: """ Decorator for wrapper "builder" functions. These are functions on the Query class or other classes used for building queries which mutate the query and return self. To make the build functions immutable, this decorator is used which will deepcopy the current instance. This decorator will return the return value of the inner function or the new copy of the instance. The inner function does not need to return self. """ import copy def _copy(self, *args: Any, **kwargs: Any) -> QueryLike: reveal_type(self)
'Request', 'Response', 'View', 'ViewHandlerMethod', 'ViewHandlerFun', 'ViewDecorator', 'PageArg', 'HttpClientT', 'Web', 'CacheBackendT', 'CacheT', 'BlueprintT', ] ViewHandlerMethod = Callable[ [Arg(Request), VarArg(Any), KwArg(Any)], Awaitable[Response], ] ViewHandlerFun = Callable[ [Arg(View), Arg(Request), VarArg(Any), KwArg(Any)], Awaitable[Response], ] ViewGetHandler = ViewHandlerFun # XXX compat ViewDecorator = Callable[[ViewHandlerFun], ViewHandlerFun] RoutedViewGetHandler = ViewDecorator # XXX compat PageArg = Union[Type[View], ViewHandlerFun] RouteDecoratorRet = Callable[[PageArg], PageArg] class CacheBackendT(ServiceT): @abc.abstractmethod def __init__(self,
"""Types defined for DashML.""" import typing as t if t.TYPE_CHECKING: from mypy_extensions import VarArg, KwArg # pragma: no cover else: # Stub out for normal execution. VarArg = lambda x: t.List[x] KwArg = lambda x: t.Dict[str, x] from lxml.etree import _Element as Element __all__ = ["Child", "Prop", "BuilderCallable", "Element"] Child = t.Union[Element, str, int, float, None] Prop = t.Union[str, int, float, bool, None] BuilderCallable = t.Callable[[VarArg(Child), KwArg(Prop)], Element]