"""
This type stub file was generated by pyright.
"""

import asyncio
import logging
import uuid
import temporalio.api.common.v1
import temporalio.common
import temporalio.converter
import temporalio.exceptions
from abc import ABC, abstractmethod
from contextlib import contextmanager
from dataclasses import dataclass
from datetime import datetime, timedelta
from enum import Enum, IntEnum
from random import Random
from typing import (
    Any,
    Awaitable,
    Callable,
    Generic,
    Iterator,
    List,
    Mapping,
    MutableMapping,
    NoReturn,
    Optional,
    Sequence,
    TYPE_CHECKING,
    Tuple,
    Type,
    Union,
    overload,
    Literal,
    Protocol,
    runtime_checkable,
    TypedDict,
    Concatenate,
    TypeVarTuple,
    Unpack,
)
from .types import (
    AnyType,
    CallableAsyncNoParam,
    CallableAsyncSingleParam,
    CallableAsyncType,
    CallableSyncNoParam,
    CallableSyncOrAsyncReturnNoneType,
    CallableSyncOrAsyncType,
    CallableSyncSingleParam,
    CallableType,
    ClassType,
    MethodAsyncNoParam,
    MethodAsyncSingleParam,
    MethodSyncNoParam,
    MethodSyncOrAsyncNoParam,
    MethodSyncOrAsyncSingleParam,
    MethodSyncSingleParam,
    MultiParamSpec,
    ParamType,
    ProtocolReturnType,
    ReturnType,
    SelfType,
    ProtocolSelfType,
    ProtocolParamType,
)

"""Utilities that can decorate or be called inside workflows."""

@overload
def defn(cls: ClassType) -> ClassType: ...
@overload
def defn(*, name: Optional[str] = ..., sandboxed: bool = ...) -> Callable[[ClassType], ClassType]: ...
@overload
def defn(*, sandboxed: bool = ..., dynamic: bool = ...) -> Callable[[ClassType], ClassType]: ...
def defn(
    cls: Optional[ClassType] = ..., *, name: Optional[str] = ..., sandboxed: bool = ..., dynamic: bool = ...
):  # -> ClassType@defn | ((cls: ClassType@defn) -> ClassType@defn):
    """Decorator for workflow classes.

    This must be set on any registered workflow class (it is ignored if on a
    base class).

    Args:
        cls: The class to decorate.
        name: Name to use for the workflow. Defaults to class ``__name__``. This
            cannot be set if dynamic is set.
        sandboxed: Whether the workflow should run in a sandbox. Default is
            true.
        dynamic: If true, this activity will be dynamic. Dynamic workflows have
            to accept a single 'Sequence[RawValue]' parameter. This cannot be
            set to true if name is present.
    """
    ...

def run(fn: CallableAsyncType) -> CallableAsyncType:
    """Decorator for the workflow run method.

    This must be set on one and only one async method defined on the same class
    as ``@workflow.defn``. This can be defined on a base class method but must
    then be explicitly overridden and defined on the workflow class.

    Run methods can only have positional parameters. Best practice is to only
    take a single object/dataclass argument that can accept more fields later if
    needed.

    Args:
        fn: The function to decorate.
    """
    ...

@overload
def signal(fn: CallableSyncOrAsyncReturnNoneType) -> CallableSyncOrAsyncReturnNoneType: ...
@overload
def signal(*, name: str) -> Callable[[CallableSyncOrAsyncReturnNoneType], CallableSyncOrAsyncReturnNoneType]: ...
@overload
def signal(
    *, dynamic: Literal[True]
) -> Callable[[CallableSyncOrAsyncReturnNoneType], CallableSyncOrAsyncReturnNoneType]: ...
def signal(
    fn: Optional[CallableSyncOrAsyncReturnNoneType] = ..., *, name: Optional[str] = ..., dynamic: Optional[bool] = ...
):  # -> partial[CallableSyncOrAsyncReturnNoneType@signal] | CallableSyncOrAsyncReturnNoneType@signal:
    """Decorator for a workflow signal method.

    This is set on any async or non-async method that you wish to be called upon
    receiving a signal. If a function overrides one with this decorator, it too
    must be decorated.

    Signal methods can only have positional parameters. Best practice for
    non-dynamic signal methods is to only take a single object/dataclass
    argument that can accept more fields later if needed. Return values from
    signal methods are ignored.

    Args:
        fn: The function to decorate.
        name: Signal name. Defaults to method ``__name__``. Cannot be present
            when ``dynamic`` is present.
        dynamic: If true, this handles all signals not otherwise handled. The
            parameters of the method must be self, a string name, and a
            ``*args`` positional varargs. Cannot be present when ``name`` is
            present.
    """
    ...

@overload
def query(fn: CallableType) -> CallableType: ...
@overload
def query(*, name: str) -> Callable[[CallableType], CallableType]: ...
@overload
def query(*, dynamic: Literal[True]) -> Callable[[CallableType], CallableType]: ...
def query(
    fn: Optional[CallableType] = ..., *, name: Optional[str] = ..., dynamic: Optional[bool] = ...
):  # -> partial[CallableType@query] | CallableType@query:
    """Decorator for a workflow query method.

    This is set on any non-async method that expects to handle a query. If a
    function overrides one with this decorator, it too must be decorated.

    Query methods can only have positional parameters. Best practice for
    non-dynamic query methods is to only take a single object/dataclass
    argument that can accept more fields later if needed. The return value is
    the resulting query value. Query methods must not mutate any workflow state.

    Args:
        fn: The function to decorate.
        name: Query name. Defaults to method ``__name__``. Cannot be present
            when ``dynamic`` is present.
        dynamic: If true, this handles all queries not otherwise handled. The
            parameters of the method should be self, a string name, and a
            ``Sequence[RawValue]``. An older form of this accepted vararg
            parameters which will now warn. Cannot be present when ``name`` is
            present.
    """
    ...

@dataclass(frozen=True)
class Info:
    """Information about the running workflow.

    Retrieved inside a workflow via :py:func:`info`. This object is immutable
    with the exception of the :py:attr:`search_attributes` and
    :py:attr:`typed_search_attributes` which is updated on
    :py:func:`upsert_search_attributes`.

    Note, required fields may be added here in future versions. This class
    should never be constructed by users.
    """

    attempt: int
    continued_run_id: Optional[str]
    cron_schedule: Optional[str]
    execution_timeout: Optional[timedelta]
    headers: Mapping[str, temporalio.api.common.v1.Payload]
    namespace: str
    parent: Optional[ParentInfo]
    raw_memo: Mapping[str, temporalio.api.common.v1.Payload]
    retry_policy: Optional[temporalio.common.RetryPolicy]
    run_id: str
    run_timeout: Optional[timedelta]
    search_attributes: temporalio.common.SearchAttributes
    start_time: datetime
    task_queue: str
    task_timeout: timedelta
    typed_search_attributes: temporalio.common.TypedSearchAttributes
    workflow_id: str
    workflow_type: str
    def get_current_history_length(self) -> int:
        """Get the current number of events in history.

        Note, this value may not be up to date if accessed inside a query.

        Returns:
            Current number of events in history (up until the current task).
        """
        ...
    def get_current_history_size(self) -> int:
        """Get the current byte size of history.

        Note, this value may not be up to date if accessed inside a query.

        Returns:
            Current byte-size of history (up until the current task).
        """
        ...
    def is_continue_as_new_suggested(self) -> bool:
        """Get whether or not continue as new is suggested.

        Note, this value may not be up to date if accessed inside a query.

        Returns:
            True if the server is configured to suggest continue as new and it
            is suggested.
        """
        ...

@dataclass(frozen=True)
class ParentInfo:
    """Information about the parent workflow."""

    namespace: str
    run_id: str
    workflow_id: str
    ...

class _Runtime(ABC):
    @staticmethod
    def current() -> _Runtime: ...
    @staticmethod
    def maybe_current() -> Optional[_Runtime]: ...
    @staticmethod
    def set_on_loop(loop: asyncio.AbstractEventLoop, runtime: Optional[_Runtime]) -> None: ...
    def __init__(self) -> None: ...
    @property
    def logger_details(self) -> Mapping[str, Any]: ...
    @abstractmethod
    def workflow_continue_as_new(
        self,
        *args: Any,
        workflow: Union[None, Callable, str],
        task_queue: Optional[str],
        run_timeout: Optional[timedelta],
        task_timeout: Optional[timedelta],
        retry_policy: Optional[temporalio.common.RetryPolicy],
        memo: Optional[Mapping[str, Any]],
        search_attributes: Optional[
            Union[
                temporalio.common.SearchAttributes,
                temporalio.common.TypedSearchAttributes,
            ]
        ],
        versioning_intent: Optional[VersioningIntent],
    ) -> NoReturn: ...
    @abstractmethod
    def workflow_extern_functions(self) -> Mapping[str, Callable]: ...
    @abstractmethod
    def workflow_get_current_history_length(self) -> int: ...
    @abstractmethod
    def workflow_get_current_history_size(self) -> int: ...
    @abstractmethod
    def workflow_get_external_workflow_handle(
        self, id: str, *, run_id: Optional[str]
    ) -> ExternalWorkflowHandle[Any]: ...
    @abstractmethod
    def workflow_get_query_handler(self, name: Optional[str]) -> Optional[Callable]: ...
    @abstractmethod
    def workflow_get_signal_handler(self, name: Optional[str]) -> Optional[Callable]: ...
    @abstractmethod
    def workflow_get_update_handler(self, name: Optional[str]) -> Optional[Callable]: ...
    @abstractmethod
    def workflow_get_update_validator(self, name: Optional[str]) -> Optional[Callable]: ...
    @abstractmethod
    def workflow_info(self) -> Info: ...
    @abstractmethod
    def workflow_is_continue_as_new_suggested(self) -> bool: ...
    @abstractmethod
    def workflow_is_replaying(self) -> bool: ...
    @abstractmethod
    def workflow_memo(self) -> Mapping[str, Any]: ...
    @abstractmethod
    def workflow_memo_value(self, key: str, default: Any, *, type_hint: Optional[Type[Any]]) -> Any: ...
    @abstractmethod
    def workflow_metric_meter(self) -> temporalio.common.MetricMeter: ...
    @abstractmethod
    def workflow_patch(self, id: str, *, deprecated: bool) -> bool: ...
    @abstractmethod
    def workflow_payload_converter(self) -> temporalio.converter.PayloadConverter: ...
    @abstractmethod
    def workflow_random(self) -> Random: ...
    @abstractmethod
    def workflow_set_query_handler(self, name: Optional[str], handler: Optional[Callable]) -> None: ...
    @abstractmethod
    def workflow_set_signal_handler(self, name: Optional[str], handler: Optional[Callable]) -> None: ...
    @abstractmethod
    def workflow_set_update_handler(
        self, name: Optional[str], handler: Optional[Callable], validator: Optional[Callable]
    ) -> None: ...
    @abstractmethod
    def workflow_start_activity(
        self,
        activity: Any,
        *args: Any,
        task_queue: Optional[str],
        result_type: Optional[Type[Any]],
        schedule_to_close_timeout: Optional[timedelta],
        schedule_to_start_timeout: Optional[timedelta],
        start_to_close_timeout: Optional[timedelta],
        heartbeat_timeout: Optional[timedelta],
        retry_policy: Optional[temporalio.common.RetryPolicy],
        cancellation_type: ActivityCancellationType,
        activity_id: Optional[str],
        versioning_intent: Optional[VersioningIntent],
    ) -> ActivityHandle[Any]: ...
    @abstractmethod
    async def workflow_start_child_workflow(
        self,
        workflow: Any,
        *args: Any,
        id: str,
        task_queue: Optional[str],
        result_type: Optional[Type[Any]],
        cancellation_type: ChildWorkflowCancellationType,
        parent_close_policy: ParentClosePolicy,
        execution_timeout: Optional[timedelta],
        run_timeout: Optional[timedelta],
        task_timeout: Optional[timedelta],
        id_reuse_policy: temporalio.common.WorkflowIDReusePolicy,
        retry_policy: Optional[temporalio.common.RetryPolicy],
        cron_schedule: str,
        memo: Optional[Mapping[str, Any]],
        search_attributes: Optional[
            Union[
                temporalio.common.SearchAttributes,
                temporalio.common.TypedSearchAttributes,
            ]
        ],
        versioning_intent: Optional[VersioningIntent],
    ) -> ChildWorkflowHandle[Any, Any]: ...
    @abstractmethod
    def workflow_start_local_activity(
        self,
        activity: Any,
        *args: Any,
        result_type: Optional[Type[Any]],
        schedule_to_close_timeout: Optional[timedelta],
        schedule_to_start_timeout: Optional[timedelta],
        start_to_close_timeout: Optional[timedelta],
        retry_policy: Optional[temporalio.common.RetryPolicy],
        local_retry_threshold: Optional[timedelta],
        cancellation_type: ActivityCancellationType,
        activity_id: Optional[str],
    ) -> ActivityHandle[Any]: ...
    @abstractmethod
    def workflow_time_ns(self) -> int: ...
    @abstractmethod
    def workflow_upsert_search_attributes(
        self,
        attributes: Union[
            temporalio.common.SearchAttributes,
            Sequence[temporalio.common.SearchAttributeUpdate],
        ],
    ) -> None: ...
    @abstractmethod
    async def workflow_wait_condition(self, fn: Callable[[], bool], *, timeout: Optional[float] = ...) -> None: ...

def deprecate_patch(id: str) -> None:
    """Mark a patch as deprecated.

    This marks a workflow that had :py:func:`patched` in a previous version of
    the code as no longer applicable because all workflows that use the old code
    path are done and will never be queried again. Therefore the old code path
    is removed as well.

    Args:
        id: The identifier originally used with :py:func:`patched`.
    """
    ...

def extern_functions() -> Mapping[str, Callable]:
    """External functions available in the workflow sandbox.

    Returns:
        Mapping of external functions that can be called from inside a workflow
        sandbox.
    """
    ...

def info() -> Info:
    """Current workflow's info.

    Returns:
        Info for the currently running workflow.
    """
    ...

def memo() -> Mapping[str, Any]:
    """Current workflow's memo values, converted without type hints.

    Since type hints are not used, the default converted values will come back.
    For example, if the memo was originally created with a dataclass, the value
    will be a dict. To convert using proper type hints, use
    :py:func:`memo_value`.

    Returns:
        Mapping of all memo keys and they values without type hints.
    """
    ...

@overload
def memo_value(key: str, default: Any = ...) -> Any: ...
@overload
def memo_value(key: str, *, type_hint: Type[ParamType]) -> ParamType: ...
@overload
def memo_value(key: str, default: AnyType, *, type_hint: Type[ParamType]) -> Union[AnyType, ParamType]: ...
def memo_value(key: str, default: Any = ..., *, type_hint: Optional[Type[Any]] = ...) -> Any:
    """Memo value for the given key, optional default, and optional type
    hint.

    Args:
        key: Key to get memo value for.
        default: Default to use if key is not present. If unset, a
            :py:class:`KeyError` is raised when the key does not exist.
        type_hint: Type hint to use when converting.

    Returns:
        Memo value, converted with the type hint if present.

    Raises:
        KeyError: Key not present and default not set.
    """
    ...

def metric_meter() -> temporalio.common.MetricMeter:
    """Get the metric meter for the current workflow.

    This meter is replay safe which means that metrics will not be recorded
    during replay.

    Returns:
        Current metric meter for this workflow for recording metrics.
    """
    ...

def now() -> datetime:
    """Current time from the workflow perspective.

    This is the workflow equivalent of :py:func:`datetime.now` with the
    :py:attr:`timezone.utc` parameter.

    Returns:
        UTC datetime for the current workflow time. The datetime does have UTC
        set as the time zone.
    """
    ...

def patched(id: str) -> bool:
    """Patch a workflow.

    When called, this will only return true if code should take the newer path
    which means this is either not replaying or is replaying and has seen this
    patch before.

    Use :py:func:`deprecate_patch` when all workflows are done and will never be
    queried again. The old code path can be used at that time too.

    Args:
        id: The identifier for this patch. This identifier may be used
            repeatedly in the same workflow to represent the same patch

    Returns:
        True if this should take the newer path, false if it should take the
        older path.
    """
    ...

def payload_converter() -> temporalio.converter.PayloadConverter:
    """Get the payload converter for the current workflow.

    This is often used for dynamic workflows/signals/queries to convert
    payloads.
    """
    ...

def random() -> Random:
    """Get a deterministic pseudo-random number generator.

    Note, this random number generator is not cryptographically safe and should
    not be used for security purposes.

    Returns:
        The deterministically-seeded pseudo-random number generator.
    """
    ...

def time() -> float:
    """Current seconds since the epoch from the workflow perspective.

    This is the workflow equivalent of :py:func:`time.time`.

    Returns:
        Seconds since the epoch as a float.
    """
    ...

def time_ns() -> int:
    """Current nanoseconds since the epoch from the workflow perspective.

    This is the workflow equivalent of :py:func:`time.time_ns`.

    Returns:
        Nanoseconds since the epoch
    """
    ...

def upsert_search_attributes(
    attributes: Union[
        temporalio.common.SearchAttributes,
        Sequence[temporalio.common.SearchAttributeUpdate],
    ]
) -> None:
    """Upsert search attributes for this workflow.

    Args:
        attributes: The attributes to set. This should be a sequence of
            updates (i.e. values created via value_set and value_unset calls on
            search attribute keys). The dictionary form of attributes is
            DEPRECATED and if used, result in invalid key types on the
            typed_search_attributes property in the info.
    """
    ...

@runtime_checkable
class UpdateMethodMultiParam(Protocol[MultiParamSpec, ProtocolReturnType]):
    """Decorated workflow update functions implement this."""

    _defn: temporalio.workflow._UpdateDefinition
    def __call__(
        self, *args: MultiParamSpec.args, **kwargs: MultiParamSpec.kwargs
    ) -> Union[ProtocolReturnType, Awaitable[ProtocolReturnType]]:
        """Generic callable type callback."""
        ...
    def validator(self, vfunc: Callable[MultiParamSpec, None]) -> Callable[MultiParamSpec, None]:
        """Use to decorate a function to validate the arguments passed to the update handler."""
        ...

@overload
def update(
    fn: Callable[MultiParamSpec, Awaitable[ReturnType]]
) -> UpdateMethodMultiParam[MultiParamSpec, ReturnType]: ...
@overload
def update(fn: Callable[MultiParamSpec, ReturnType]) -> UpdateMethodMultiParam[MultiParamSpec, ReturnType]: ...
@overload
def update(
    *, name: str
) -> Callable[[Callable[MultiParamSpec, ReturnType]], UpdateMethodMultiParam[MultiParamSpec, ReturnType],]: ...
@overload
def update(
    *, dynamic: Literal[True]
) -> Callable[[Callable[MultiParamSpec, ReturnType]], UpdateMethodMultiParam[MultiParamSpec, ReturnType],]: ...
def update(
    fn: Optional[CallableSyncOrAsyncType] = ..., *, name: Optional[str] = ..., dynamic: Optional[bool] = ...
):  # -> partial[CallableSyncOrAsyncType@update] | CallableSyncOrAsyncType@update:
    """Decorator for a workflow update handler method.

    This is set on any async or non-async method that you wish to be called upon
    receiving an update. If a function overrides one with this decorator, it too
    must be decorated.

    You may also optionally define a validator method that will be called before
    this handler you have applied this decorator to. You can specify the validator
    with ``@update_handler_function_name.validator``.

    Update methods can only have positional parameters. Best practice for
    non-dynamic update methods is to only take a single object/dataclass
    argument that can accept more fields later if needed. The handler may return
    a serializable value which will be sent back to the caller of the update.

    .. warning::
       This API is experimental

    Args:
        fn: The function to decorate.
        name: Update name. Defaults to method ``__name__``. Cannot be present
            when ``dynamic`` is present.
        dynamic: If true, this handles all updates not otherwise handled. The
            parameters of the method must be self, a string name, and a
            ``*args`` positional varargs. Cannot be present when ``name`` is
            present.
    """
    ...

def uuid4() -> uuid.UUID:
    """Get a new, determinism-safe v4 UUID based on :py:func:`random`.

    Note, this UUID is not cryptographically safe and should not be used for
    security purposes.

    Returns:
        A deterministically-seeded v4 UUID.
    """
    ...

async def wait_condition(fn: Callable[[], bool], *, timeout: Optional[Union[timedelta, float]] = ...) -> None:
    """Wait on a callback to become true.

    This function returns when the callback returns true (invoked each loop
    iteration) or the timeout has been reached.

    Args:
        fn: Non-async callback that accepts no parameters and returns a boolean.
        timeout: Optional number of seconds to wait until throwing
            :py:class:`asyncio.TimeoutError`.
    """
    ...

_sandbox_unrestricted = ...
_in_sandbox = ...
_imports_passed_through = ...

class unsafe:
    """Contains static methods that should not normally be called during
    workflow execution except in advanced cases.
    """

    def __init__(self) -> None: ...
    @staticmethod
    def in_sandbox() -> bool:
        """Whether the code is executing on a sandboxed thread.

        Returns:
            True if the code is executing in the sandbox thread.
        """
        ...
    @staticmethod
    def is_replaying() -> bool:
        """Whether the workflow is currently replaying.

        Returns:
            True if the workflow is currently replaying
        """
        ...
    @staticmethod
    def is_sandbox_unrestricted() -> bool:
        """Whether the current block of code is not restricted via sandbox.

        Returns:
            True if the current code is not restricted in the sandbox.
        """
        ...
    @staticmethod
    @contextmanager
    def sandbox_unrestricted() -> Iterator[None]:
        """A context manager to run code without sandbox restrictions."""
        ...
    @staticmethod
    def is_imports_passed_through() -> bool:
        """Whether the current block of code is in
        :py:meth:imports_passed_through.

        Returns:
            True if the current code's imports will be passed through
        """
        ...
    @staticmethod
    @contextmanager
    def imports_passed_through() -> Iterator[None]:
        """Context manager to mark all imports that occur within it as passed
        through (meaning not reloaded by the sandbox).
        """
        ...

class LoggerAdapter(logging.LoggerAdapter):
    """Adapter that adds details to the log about the running workflow.

    Attributes:
        workflow_info_on_message: Boolean for whether a string representation of
            a dict of some workflow info will be appended to each message.
            Default is True.
        workflow_info_on_extra: Boolean for whether a ``workflow_info`` value
            will be added to the ``extra`` dictionary, making it present on the
            ``LogRecord.__dict__`` for use by others.
        log_during_replay: Boolean for whether logs should occur during replay.
            Default is False.
    """

    def __init__(self, logger: logging.Logger, extra: Optional[Mapping[str, Any]]) -> None:
        """Create the logger adapter."""
        ...
    def process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> Tuple[Any, MutableMapping[str, Any]]:
        """Override to add workflow details."""
        ...
    def log(self, *args, **kwargs) -> None:
        """Override to ignore replay logs."""
        ...
    @property
    def base_logger(self) -> logging.Logger:
        """Underlying logger usable for actions such as adding
        handlers/formatters.
        """
        ...

logger = ...

@dataclass(frozen=True)
class _Definition:
    name: Optional[str]
    cls: Type
    run_fn: Callable[..., Awaitable]
    signals: Mapping[Optional[str], _SignalDefinition]
    queries: Mapping[Optional[str], _QueryDefinition]
    updates: Mapping[Optional[str], _UpdateDefinition]
    sandboxed: bool
    arg_types: Optional[List[Type[Any]]] = ...
    ret_type: Optional[Type[Any]] = ...
    @staticmethod
    def from_class(cls: Type) -> Optional[_Definition]: ...
    @staticmethod
    def must_from_class(cls: Type) -> _Definition: ...
    @staticmethod
    def from_run_fn(fn: Callable[..., Awaitable[Any]]) -> Optional[_Definition]: ...
    @staticmethod
    def must_from_run_fn(fn: Callable[..., Awaitable[Any]]) -> _Definition: ...
    def __post_init__(self) -> None: ...

@dataclass(frozen=True)
class _SignalDefinition:
    name: Optional[str]
    fn: Callable[..., Union[None, Awaitable[None]]]
    is_method: bool
    arg_types: Optional[List[Type[Any]]] = ...
    dynamic_vararg: bool = ...
    @staticmethod
    def from_fn(fn: Callable) -> Optional[_SignalDefinition]: ...
    @staticmethod
    def must_name_from_fn_or_str(signal: Union[str, Callable]) -> str: ...
    def __post_init__(self) -> None: ...
    def bind_fn(self, obj: Any) -> Callable[..., Any]: ...

@dataclass(frozen=True)
class _QueryDefinition:
    name: Optional[str]
    fn: Callable[..., Any]
    is_method: bool
    arg_types: Optional[List[Type[Any]]] = ...
    ret_type: Optional[Type[Any]] = ...
    dynamic_vararg: bool = ...
    @staticmethod
    def from_fn(fn: Callable) -> Optional[_QueryDefinition]: ...
    def __post_init__(self) -> None: ...
    def bind_fn(self, obj: Any) -> Callable[..., Any]: ...

@dataclass(frozen=True)
class _UpdateDefinition:
    name: Optional[str]
    fn: Callable[..., Union[Any, Awaitable[Any]]]
    is_method: bool
    arg_types: Optional[List[Type[Any]]] = ...
    ret_type: Optional[Type[Any]] = ...
    validator: Optional[Callable[..., None]] = ...
    dynamic_vararg: bool = ...
    def __post_init__(self) -> None: ...
    def bind_fn(self, obj: Any) -> Callable[..., Any]: ...
    def bind_validator(self, obj: Any) -> Callable[..., Any]: ...
    def set_validator(self, validator: Callable[..., None]) -> None: ...

if TYPE_CHECKING:
    class _AsyncioTask(asyncio.Task[AnyType]): ...

else: ...

class ActivityHandle(_AsyncioTask[ReturnType]):
    """Handle returned from :py:func:`start_activity` and
    :py:func:`start_local_activity`.

    This extends :py:class:`asyncio.Task` and supports all task features.
    """

    ...

class ActivityCancellationType(IntEnum):
    """How an activity cancellation should be handled."""

    TRY_CANCEL = ...
    WAIT_CANCELLATION_COMPLETED = ...
    ABANDON = ...

class ActivityConfig(TypedDict, total=False):
    """TypedDict of config that can be used for :py:func:`start_activity` and
    :py:func:`execute_activity`.
    """

    task_queue: Optional[str]
    schedule_to_close_timeout: Optional[timedelta]
    schedule_to_start_timeout: Optional[timedelta]
    start_to_close_timeout: Optional[timedelta]
    heartbeat_timeout: Optional[timedelta]
    retry_policy: Optional[temporalio.common.RetryPolicy]
    cancellation_type: ActivityCancellationType
    activity_id: Optional[str]
    versioning_intent: Optional[VersioningIntent]
    ...

@overload
def start_activity(
    activity: CallableAsyncNoParam[ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity(
    activity: CallableSyncNoParam[ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity(
    activity: CallableAsyncSingleParam[ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity(
    activity: CallableSyncSingleParam[ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity(
    activity: Callable[..., Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity(
    activity: Callable[..., ReturnType],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity(
    activity: str,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    result_type: Optional[Type[Any]] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[Any]: ...
def start_activity(
    activity: Any,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    result_type: Optional[Type[Any]] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[Any]:
    """Start an activity and return its handle.

    At least one of ``schedule_to_close_timeout`` or ``start_to_close_timeout``
    must be present.

    Args:
        activity: Activity name or function reference.
        arg: Single argument to the activity.
        args: Multiple arguments to the activity. Cannot be set if arg is.
        task_queue: Task queue to run the activity on. Defaults to the current
            workflow's task queue.
        result_type: For string activities, this can set the specific result
            type hint to deserialize into.
        schedule_to_close_timeout: Max amount of time the activity can take from
            first being scheduled to being completed before it times out. This
            is inclusive of all retries.
        schedule_to_start_timeout: Max amount of time the activity can take to
            be started from first being scheduled.
        start_to_close_timeout: Max amount of time a single activity run can
            take from when it starts to when it completes. This is per retry.
        heartbeat_timeout: How frequently an activity must invoke heartbeat
            while running before it is considered timed out.
        retry_policy: How an activity is retried on failure. If unset, a
            server-defined default is used. Set maximum attempts to 1 to disable
            retries.
        cancellation_type: How the activity is treated when it is cancelled from
            the workflow.
        activity_id: Optional unique identifier for the activity. This is an
            advanced setting that should not be set unless users are sure they
            need to. Contact Temporal before setting this value.
        versioning_intent: When using the Worker Versioning feature, specifies whether this Activity
            should run on a worker with a compatible Build Id or not.

    Returns:
        An activity handle to the activity which is an async task.
    """
    ...

Ts = TypeVarTuple("Ts")

class MethodAsyncNParam(Protocol[ProtocolSelfType, ProtocolParamType, ProtocolReturnType]):
    """Generic callable type."""

    def __call__(__self, self: ProtocolSelfType, *args: ProtocolParamType) -> Awaitable[ProtocolReturnType]:
        """Generic callable type callback."""
        ...

@overload
async def execute_activity(
    activity: CallableAsyncNoParam[ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: CallableSyncNoParam[ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: CallableAsyncSingleParam[ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: CallableSyncSingleParam[ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: MethodAsyncNoParam[Any, ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: MethodSyncNoParam[Any, ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: MethodAsyncSingleParam[Any, ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: Callable[[Any, ParamType], Awaitable[ReturnType]],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: MethodSyncSingleParam[Any, ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: MethodAsyncNParam[Any, Ts, ReturnType],
    *,
    args: Sequence[Ts],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: Callable[[Ts], ReturnType],
    *,
    args: Sequence[Ts],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: Callable[[SelfType, Unpack[Ts]], Awaitable[ReturnType]],
    *,
    args: tuple[Unpack[Ts]],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: Callable[[SelfType, Ts], ReturnType],
    *,
    args: tuple[Unpack[Ts]],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity(
    activity: str,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    result_type: Optional[Type[Any]] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> Any: ...
async def execute_activity(
    activity: Any,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    result_type: Optional[Type[Any]] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> Any:
    """Start an activity and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_activity`.
    """
    ...

@overload
def start_activity_class(
    activity: Type[CallableAsyncNoParam[ReturnType]],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_class(
    activity: Type[CallableSyncNoParam[ReturnType]],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_class(
    activity: Type[CallableAsyncSingleParam[ParamType, ReturnType]],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_class(
    activity: Type[CallableSyncSingleParam[ParamType, ReturnType]],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_class(
    activity: Type[Callable[..., Awaitable[ReturnType]]],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_class(
    activity: Type[Callable[..., ReturnType]],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
def start_activity_class(
    activity: Type[Callable],
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[Any]:
    """Start an activity from a callable class.

    See :py:meth:`start_activity` for parameter and return details.
    """
    ...

@overload
async def execute_activity_class(
    activity: Type[CallableAsyncNoParam[ReturnType]],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_class(
    activity: Type[CallableSyncNoParam[ReturnType]],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_class(
    activity: Type[CallableAsyncSingleParam[ParamType, ReturnType]],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_class(
    activity: Type[CallableSyncSingleParam[ParamType, ReturnType]],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_class(
    activity: Type[Callable[..., Awaitable[ReturnType]]],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_class(
    activity: Type[Callable[..., ReturnType]],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
async def execute_activity_class(
    activity: Type[Callable],
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> Any:
    """Start an activity from a callable class and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_activity_class`.
    """
    ...

@overload
def start_activity_method(
    activity: MethodAsyncNoParam[SelfType, ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_method(
    activity: MethodSyncNoParam[SelfType, ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_method(
    activity: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_method(
    activity: MethodSyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_method(
    activity: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_activity_method(
    activity: Callable[Concatenate[SelfType, MultiParamSpec], ReturnType],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[ReturnType]: ...
def start_activity_method(
    activity: Callable,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ActivityHandle[Any]:
    """Start an activity from a method.

    See :py:meth:`start_activity` for parameter and return details.
    """
    ...

@overload
async def execute_activity_method(
    activity: MethodAsyncNoParam[SelfType, ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_method(
    activity: MethodSyncNoParam[SelfType, ReturnType],
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_method(
    activity: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_method(
    activity: MethodSyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_method(
    activity: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_activity_method(
    activity: Callable[Concatenate[SelfType, MultiParamSpec], ReturnType],
    *,
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
async def execute_activity_method(
    activity: Callable,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    heartbeat_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> Any:
    """Start an activity from a method and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_activity_method`.
    """
    ...

class LocalActivityConfig(TypedDict, total=False):
    """TypedDict of config that can be used for :py:func:`start_local_activity`
    and :py:func:`execute_local_activity`.
    """

    schedule_to_close_timeout: Optional[timedelta]
    schedule_to_start_timeout: Optional[timedelta]
    start_to_close_timeout: Optional[timedelta]
    retry_policy: Optional[temporalio.common.RetryPolicy]
    local_retry_threshold: Optional[timedelta]
    cancellation_type: ActivityCancellationType
    activity_id: Optional[str]
    ...

@overload
def start_local_activity(
    activity: CallableAsyncNoParam[ReturnType],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity(
    activity: CallableSyncNoParam[ReturnType],
    *,
    activity_id: Optional[str] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity(
    activity: CallableAsyncSingleParam[ParamType, ReturnType],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity(
    activity: CallableSyncSingleParam[ParamType, ReturnType],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity(
    activity: Callable[..., Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity(
    activity: Callable[..., ReturnType],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity(
    activity: str,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    result_type: Optional[Type[Any]] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[Any]: ...
def start_local_activity(
    activity: Any,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    result_type: Optional[Type[Any]] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[Any]:
    """Start a local activity and return its handle.

    At least one of ``schedule_to_close_timeout`` or ``start_to_close_timeout``
    must be present.

    .. warning::
        Local activities are currently experimental.

    Args:
        activity: Activity name or function reference.
        arg: Single argument to the activity.
        args: Multiple arguments to the activity. Cannot be set if arg is.
        result_type: For string activities, this can set the specific result
            type hint to deserialize into.
        schedule_to_close_timeout: Max amount of time the activity can take from
            first being scheduled to being completed before it times out. This
            is inclusive of all retries.
        schedule_to_start_timeout: Max amount of time the activity can take to
            be started from first being scheduled.
        start_to_close_timeout: Max amount of time a single activity run can
            take from when it starts to when it completes. This is per retry.
        retry_policy: How an activity is retried on failure. If unset, an
            SDK-defined default is used. Set maximum attempts to 1 to disable
            retries.
        cancellation_type: How the activity is treated when it is cancelled from
            the workflow.
        activity_id: Optional unique identifier for the activity. This is an
            advanced setting that should not be set unless users are sure they
            need to. Contact Temporal before setting this value.

    Returns:
        An activity handle to the activity which is an async task.
    """
    ...

@overload
async def execute_local_activity(
    activity: CallableAsyncNoParam[ReturnType],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity(
    activity: CallableSyncNoParam[ReturnType],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity(
    activity: CallableAsyncSingleParam[ParamType, ReturnType],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity(
    activity: CallableSyncSingleParam[ParamType, ReturnType],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity(
    activity: Callable[..., Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity(
    activity: Callable[..., ReturnType],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity(
    activity: str,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    result_type: Optional[Type[Any]] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> Any: ...
async def execute_local_activity(
    activity: Any,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    result_type: Optional[Type[Any]] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> Any:
    """Start a local activity and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_local_activity`.

    .. warning::
        Local activities are currently experimental.
    """
    ...

@overload
def start_local_activity_class(
    activity: Type[CallableAsyncNoParam[ReturnType]],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_class(
    activity: Type[CallableSyncNoParam[ReturnType]],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_class(
    activity: Type[CallableAsyncSingleParam[ParamType, ReturnType]],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_class(
    activity: Type[CallableSyncSingleParam[ParamType, ReturnType]],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_class(
    activity: Type[Callable[..., Awaitable[ReturnType]]],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_class(
    activity: Type[Callable[..., ReturnType]],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
def start_local_activity_class(
    activity: Type[Callable],
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[Any]:
    """Start a local activity from a callable class.

    See :py:meth:`start_local_activity` for parameter and return details.

    .. warning::
        Local activities are currently experimental.
    """
    ...

@overload
async def execute_local_activity_class(
    activity: Type[CallableAsyncNoParam[ReturnType]],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_class(
    activity: Type[CallableSyncNoParam[ReturnType]],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_class(
    activity: Type[CallableAsyncSingleParam[ParamType, ReturnType]],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_class(
    activity: Type[CallableSyncSingleParam[ParamType, ReturnType]],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_class(
    activity: Type[Callable[..., Awaitable[ReturnType]]],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_class(
    activity: Type[Callable[..., ReturnType]],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
async def execute_local_activity_class(
    activity: Type[Callable],
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> Any:
    """Start a local activity from a callable class and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_local_activity_class`.

    .. warning::
        Local activities are currently experimental.
    """
    ...

@overload
def start_local_activity_method(
    activity: MethodAsyncNoParam[SelfType, ReturnType],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_method(
    activity: MethodSyncNoParam[SelfType, ReturnType],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_method(
    activity: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_method(
    activity: MethodSyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_method(
    activity: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
@overload
def start_local_activity_method(
    activity: Callable[Concatenate[SelfType, MultiParamSpec], ReturnType],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[ReturnType]: ...
def start_local_activity_method(
    activity: Callable,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ActivityHandle[Any]:
    """Start a local activity from a method.

    See :py:meth:`start_local_activity` for parameter and return details.

    .. warning::
        Local activities are currently experimental.
    """
    ...

@overload
async def execute_local_activity_method(
    activity: MethodAsyncNoParam[SelfType, ReturnType],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_method(
    activity: MethodSyncNoParam[SelfType, ReturnType],
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_method(
    activity: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_method(
    activity: MethodSyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_method(
    activity: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
@overload
async def execute_local_activity_method(
    activity: Callable[Concatenate[SelfType, MultiParamSpec], ReturnType],
    *,
    args: Sequence[Any],
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> ReturnType: ...
async def execute_local_activity_method(
    activity: Callable,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    schedule_to_close_timeout: Optional[timedelta] = ...,
    schedule_to_start_timeout: Optional[timedelta] = ...,
    start_to_close_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    local_retry_threshold: Optional[timedelta] = ...,
    cancellation_type: ActivityCancellationType = ...,
    activity_id: Optional[str] = ...,
) -> Any:
    """Start a local activity from a method and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_local_activity_method`.

    .. warning::
        Local activities are currently experimental.
    """
    ...

class ChildWorkflowHandle(_AsyncioTask[ReturnType], Generic[SelfType, ReturnType]):
    """Handle for interacting with a child workflow.

    This is created via :py:func:`start_child_workflow`.

    This extends :py:class:`asyncio.Task` and supports all task features.
    """

    @property
    def id(self) -> str:
        """ID for the workflow."""
        ...
    @property
    def first_execution_run_id(self) -> Optional[str]:
        """Run ID for the workflow."""
        ...
    @overload
    async def signal(self, signal: MethodSyncOrAsyncNoParam[SelfType, None]) -> None: ...
    @overload
    async def signal(self, signal: MethodSyncOrAsyncSingleParam[SelfType, ParamType, None], arg: ParamType) -> None: ...
    @overload
    async def signal(
        self,
        signal: Callable[Concatenate[SelfType, MultiParamSpec], Union[Awaitable[None], None]],
        *,
        args: Sequence[Any],
    ) -> None: ...
    @overload
    async def signal(self, signal: str, arg: Any = ..., *, args: Sequence[Any] = ...) -> None: ...
    async def signal(self, signal: Union[str, Callable], arg: Any = ..., *, args: Sequence[Any] = ...) -> None:
        """Signal this child workflow.

        Args:
            signal: Name or method reference for the signal.
            arg: Single argument to the signal.
            args: Multiple arguments to the signal. Cannot be set if arg is.

        """
        ...

class ChildWorkflowCancellationType(IntEnum):
    """How a child workflow cancellation should be handled."""

    ABANDON = ...
    TRY_CANCEL = ...
    WAIT_CANCELLATION_COMPLETED = ...
    WAIT_CANCELLATION_REQUESTED = ...

class ParentClosePolicy(IntEnum):
    """How a child workflow should be handled when the parent closes."""

    UNSPECIFIED = ...
    TERMINATE = ...
    ABANDON = ...
    REQUEST_CANCEL = ...

class ChildWorkflowConfig(TypedDict, total=False):
    """TypedDict of config that can be used for :py:func:`start_child_workflow`
    and :py:func:`execute_child_workflow`.
    """

    id: Optional[str]
    task_queue: Optional[str]
    cancellation_type: ChildWorkflowCancellationType
    parent_close_policy: ParentClosePolicy
    execution_timeout: Optional[timedelta]
    run_timeout: Optional[timedelta]
    task_timeout: Optional[timedelta]
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy
    retry_policy: Optional[temporalio.common.RetryPolicy]
    cron_schedule: str
    memo: Optional[Mapping[str, Any]]
    search_attributes: Optional[Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]]
    ...

@overload
async def start_child_workflow(
    workflow: MethodAsyncNoParam[SelfType, ReturnType],
    *,
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ChildWorkflowHandle[SelfType, ReturnType]: ...
@overload
async def start_child_workflow(
    workflow: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ChildWorkflowHandle[SelfType, ReturnType]: ...
@overload
async def start_child_workflow(
    workflow: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ChildWorkflowHandle[SelfType, ReturnType]: ...
@overload
async def start_child_workflow(
    workflow: str,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    result_type: Optional[Type[Any]] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ChildWorkflowHandle[Any, Any]: ...
async def start_child_workflow(
    workflow: Any,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    result_type: Optional[Type[Any]] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ChildWorkflowHandle[Any, Any]:
    """Start a child workflow and return its handle.

    Args:
        workflow: String name or class method decorated with ``@workflow.run``
            for the workflow to start.
        arg: Single argument to the child workflow.
        args: Multiple arguments to the child workflow. Cannot be set if arg is.
        id: Optional unique identifier for the workflow execution. If not set,
            defaults to :py:func:`uuid4`.
        task_queue: Task queue to run the workflow on. Defaults to the current
            workflow's task queue.
        result_type: For string workflows, this can set the specific result type
            hint to deserialize into.
        cancellation_type: How the child workflow will react to cancellation.
        parent_close_policy: How to handle the child workflow when the parent
            workflow closes.
        execution_timeout: Total workflow execution timeout including
            retries and continue as new.
        run_timeout: Timeout of a single workflow run.
        task_timeout: Timeout of a single workflow task.
        id_reuse_policy: How already-existing IDs are treated.
        retry_policy: Retry policy for the workflow.
        cron_schedule: See https://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/
        memo: Memo for the workflow.
        search_attributes: Search attributes for the workflow. The dictionary
            form of this is DEPRECATED.
        versioning_intent:  When using the Worker Versioning feature, specifies whether this Child
            Workflow should run on a worker with a compatible Build Id or not.

    Returns:
        A workflow handle to the started/existing workflow.
    """
    ...

@overload
async def execute_child_workflow(
    workflow: MethodAsyncNoParam[SelfType, ReturnType],
    *,
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_child_workflow(
    workflow: MethodAsyncSingleParam[SelfType, ParamType, ReturnType],
    arg: ParamType,
    *,
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_child_workflow(
    workflow: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]],
    *,
    args: Sequence[Any],
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> ReturnType: ...
@overload
async def execute_child_workflow(
    workflow: str,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    result_type: Optional[Type[Any]] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> Any: ...
async def execute_child_workflow(
    workflow: Any,
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    id: Optional[str] = ...,
    task_queue: Optional[str] = ...,
    result_type: Optional[Type[Any]] = ...,
    cancellation_type: ChildWorkflowCancellationType = ...,
    parent_close_policy: ParentClosePolicy = ...,
    execution_timeout: Optional[timedelta] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    cron_schedule: str = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> Any:
    """Start a child workflow and wait for completion.

    This is a shortcut for ``await`` :py:meth:`start_child_workflow`.
    """
    ...

class ExternalWorkflowHandle(Generic[SelfType]):
    """Handle for interacting with an external workflow.

    This is created via :py:func:`get_external_workflow_handle` or
    :py:func:`get_external_workflow_handle_for`.
    """

    @property
    def id(self) -> str:
        """ID for the workflow."""
        ...
    @property
    def run_id(self) -> Optional[str]:
        """Run ID for the workflow if any."""
        ...
    @overload
    async def signal(self, signal: MethodSyncOrAsyncNoParam[SelfType, None]) -> None: ...
    @overload
    async def signal(self, signal: MethodSyncOrAsyncSingleParam[SelfType, ParamType, None], arg: ParamType) -> None: ...
    @overload
    async def signal(self, signal: str, arg: Any = ..., *, args: Sequence[Any] = ...) -> None: ...
    async def signal(self, signal: Union[str, Callable], arg: Any = ..., *, args: Sequence[Any] = ...) -> None:
        """Signal this external workflow.

        Args:
            signal: Name or method reference for the signal.
            arg: Single argument to the signal.
            args: Multiple arguments to the signal. Cannot be set if arg is.

        """
        ...
    async def cancel(self) -> None:
        """Send a cancellation request to this external workflow.

        This will fail if the workflow cannot accept the request (e.g. if the
        workflow is not found).
        """
        ...

def get_external_workflow_handle(workflow_id: str, *, run_id: Optional[str] = ...) -> ExternalWorkflowHandle[Any]:
    """Get a workflow handle to an existing workflow by its ID.

    Args:
        workflow_id: Workflow ID to get a handle to.
        run_id: Optional run ID for the workflow.

    Returns:
        The external workflow handle.
    """
    ...

def get_external_workflow_handle_for(
    workflow: Union[MethodAsyncNoParam[SelfType, Any], MethodAsyncSingleParam[SelfType, Any, Any]],
    workflow_id: str,
    *,
    run_id: Optional[str] = ...,
) -> ExternalWorkflowHandle[SelfType]:
    """Get a typed workflow handle to an existing workflow by its ID.

    This is the same as :py:func:`get_external_workflow_handle` but typed. Note,
    the workflow type given is not validated, it is only for typing.

    Args:
        workflow: The workflow run method to use for typing the handle.
        workflow_id: Workflow ID to get a handle to.
        run_id: Optional run ID for the workflow.

    Returns:
        The external workflow handle.
    """
    ...

class ContinueAsNewError(BaseException):
    """Error thrown by :py:func:`continue_as_new`.

    This should not be caught, but instead be allowed to throw out of the
    workflow which then triggers the continue as new. This should never be
    instantiated directly.
    """

    def __init__(self, *args: object) -> None:
        """Direct instantiation is disabled. Use :py:func:`continue_as_new`."""
        ...

@overload
def continue_as_new(
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> NoReturn: ...
@overload
def continue_as_new(
    *,
    workflow: MethodAsyncNoParam[SelfType, Any],
    task_queue: Optional[str] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> NoReturn: ...
@overload
def continue_as_new(
    arg: ParamType,
    *,
    workflow: MethodAsyncSingleParam[SelfType, ParamType, Any],
    task_queue: Optional[str] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> NoReturn: ...
@overload
def continue_as_new(
    *,
    workflow: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[Any]],
    args: Sequence[Any],
    task_queue: Optional[str] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> NoReturn: ...
@overload
def continue_as_new(
    *,
    workflow: str,
    args: Sequence[Any] = ...,
    task_queue: Optional[str] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> NoReturn: ...
def continue_as_new(
    arg: Any = ...,
    *,
    args: Sequence[Any] = ...,
    workflow: Union[None, Callable, str] = ...,
    task_queue: Optional[str] = ...,
    run_timeout: Optional[timedelta] = ...,
    task_timeout: Optional[timedelta] = ...,
    retry_policy: Optional[temporalio.common.RetryPolicy] = ...,
    memo: Optional[Mapping[str, Any]] = ...,
    search_attributes: Optional[
        Union[temporalio.common.SearchAttributes, temporalio.common.TypedSearchAttributes]
    ] = ...,
    versioning_intent: Optional[VersioningIntent] = ...,
) -> NoReturn:
    """Stop the workflow immediately and continue as new.

    Args:
        arg: Single argument to the continued workflow.
        args: Multiple arguments to the continued workflow. Cannot be set if arg
            is.
        workflow: Specific workflow to continue to. Defaults to the current
            workflow.
        task_queue: Task queue to run the workflow on. Defaults to the current
            workflow's task queue.
        run_timeout: Timeout of a single workflow run. Defaults to the current
            workflow's run timeout.
        task_timeout: Timeout of a single workflow task. Defaults to the current
            workflow's task timeout.
        memo: Memo for the workflow. Defaults to the current workflow's memo.
        search_attributes: Search attributes for the workflow. Defaults to the
            current workflow's search attributes. The dictionary form of this is
            DEPRECATED.
        versioning_intent: When using the Worker Versioning feature, specifies whether this Workflow
            should Continue-as-New onto a worker with a compatible Build Id or not.

    Returns:
        Never returns, always raises a :py:class:`ContinueAsNewError`.

    Raises:
        ContinueAsNewError: Always raised by this function. Should not be caught
            but instead be allowed to
    """
    ...

def get_signal_handler(name: str) -> Optional[Callable]:
    """Get the signal handler for the given name if any.

    This includes handlers created via the ``@workflow.signal`` decorator.

    Args:
        name: Name of the signal.

    Returns:
        Callable for the signal if any. If a handler is not found for the name,
        this will not return the dynamic handler even if there is one.
    """
    ...

def set_signal_handler(name: str, handler: Optional[Callable]) -> None:
    """Set or unset the signal handler for the given name.

    This overrides any existing handlers for the given name, including handlers
    created via the ``@workflow.signal`` decorator.

    When set, all unhandled past signals for the given name are immediately sent
    to the handler.

    Args:
        name: Name of the signal.
        handler: Callable to set or None to unset.
    """
    ...

def get_dynamic_signal_handler() -> Optional[Callable]:
    """Get the dynamic signal handler if any.

    This includes dynamic handlers created via the ``@workflow.signal``
    decorator.

    Returns:
        Callable for the dynamic signal handler if any.
    """
    ...

def set_dynamic_signal_handler(handler: Optional[Callable]) -> None:
    """Set or unset the dynamic signal handler.

    This overrides the existing dynamic handler even if it was created via the
    ``@workflow.signal`` decorator.

    When set, all unhandled past signals are immediately sent to the handler.

    Args:
        handler: Callable to set or None to unset.
    """
    ...

def get_query_handler(name: str) -> Optional[Callable]:
    """Get the query handler for the given name if any.

    This includes handlers created via the ``@workflow.query`` decorator.

    Args:
        name: Name of the query.

    Returns:
        Callable for the query if any. If a handler is not found for the name,
        this will not return the dynamic handler even if there is one.
    """
    ...

def set_query_handler(name: str, handler: Optional[Callable]) -> None:
    """Set or unset the query handler for the given name.

    This overrides any existing handlers for the given name, including handlers
    created via the ``@workflow.query`` decorator.

    Args:
        name: Name of the query.
        handler: Callable to set or None to unset.
    """
    ...

def get_dynamic_query_handler() -> Optional[Callable]:
    """Get the dynamic query handler if any.

    This includes dynamic handlers created via the ``@workflow.query``
    decorator.

    Returns:
        Callable for the dynamic query handler if any.
    """
    ...

def set_dynamic_query_handler(handler: Optional[Callable]) -> None:
    """Set or unset the dynamic query handler.

    This overrides the existing dynamic handler even if it was created via the
    ``@workflow.query`` decorator.

    Args:
        handler: Callable to set or None to unset.
    """
    ...

def get_update_handler(name: str) -> Optional[Callable]:
    """Get the update handler for the given name if any.

    This includes handlers created via the ``@workflow.update`` decorator.

    Args:
        name: Name of the update.

    Returns:
        Callable for the update if any. If a handler is not found for the name,
        this will not return the dynamic handler even if there is one.
    """
    ...

def set_update_handler(name: str, handler: Optional[Callable], *, validator: Optional[Callable] = ...) -> None:
    """Set or unset the update handler for the given name.

    This overrides any existing handlers for the given name, including handlers
    created via the ``@workflow.update`` decorator.

    Args:
        name: Name of the update.
        handler: Callable to set or None to unset.
        validator: Callable to set or None to unset as the update validator.
    """
    ...

def get_dynamic_update_handler() -> Optional[Callable]:
    """Get the dynamic update handler if any.

    This includes dynamic handlers created via the ``@workflow.update``
    decorator.

    Returns:
        Callable for the dynamic update handler if any.
    """
    ...

def set_dynamic_update_handler(handler: Optional[Callable], *, validator: Optional[Callable] = ...) -> None:
    """Set or unset the dynamic update handler.

    This overrides the existing dynamic handler even if it was created via the
    ``@workflow.update`` decorator.

    Args:
        handler: Callable to set or None to unset.
        validator: Callable to set or None to unset as the update validator.
    """
    ...

class _UnexpectedEvictionError(temporalio.exceptions.TemporalError):
    def __init__(
        self, reason: temporalio.bridge.proto.workflow_activation.RemoveFromCache.EvictionReason.ValueType, message: str
    ) -> None: ...

class NondeterminismError(temporalio.exceptions.TemporalError):
    """Error that can be thrown during replay for non-deterministic workflow."""

    def __init__(self, message: str) -> None:
        """Initialize a nondeterminism error."""
        ...

class ReadOnlyContextError(temporalio.exceptions.TemporalError):
    """Error thrown when trying to do mutable workflow calls in a read-only
    context like a query or update validator.
    """

    def __init__(self, message: str) -> None:
        """Initialize a read-only context error."""
        ...

class _NotInWorkflowEventLoopError(temporalio.exceptions.TemporalError):
    def __init__(self, *args: object) -> None: ...

class VersioningIntent(Enum):
    """Indicates whether the user intends certain commands to be run on a compatible worker Build
    Id version or not.

    `COMPATIBLE` indicates that the command should run on a worker with compatible version if
    possible. It may not be possible if the target task queue does not also have knowledge of the
    current worker's Build Id.

    `DEFAULT` indicates that the command should run on the target task queue's current
    overall-default Build Id.

    Where this type is accepted optionally, an unset value indicates that the SDK should choose the
    most sensible default behavior for the type of command, accounting for whether the command will
    be run on the same task queue as the current worker.
    """

    COMPATIBLE = ...
    DEFAULT = ...
