Format operation stub file
-from typing import Callable, Dict, Generator, Generic, Iterable, List, Mapping, Protocol, Tuple, overload
+from typing import (
+ Callable,
+ Dict,
+ Generator,
+ Generic,
+ Iterable,
+ List,
+ Mapping,
+ Protocol,
+ Tuple,
+ overload,
+)
from typing_extensions import ParamSpec
-from pyinfra.api.command import StringCommand, FileDownloadCommand, FileUploadCommand, FunctionCommand
-from pyinfra.api.state import State
+from pyinfra.api.command import (
+ FileDownloadCommand,
+ FileUploadCommand,
+ FunctionCommand,
+ StringCommand,
+)
from pyinfra.api.host import Host
+from pyinfra.api.state import State
P = ParamSpec("P")
@@ -21,7 +37,8 @@ class OperationMeta(object):
stderr: str
class Operation(Generic[P], Protocol):
- def __call__(self,
+ def __call__(
+ self,
_sudo: bool | None = None,
_sudo_user: str | None = None,
_use_sudo_login: bool | None = None,
@@ -51,11 +68,12 @@ class Operation(Generic[P], Protocol):
_run_once: bool | None = None,
_serial: bool | None = None,
*args: P.args,
- **kwargs: P.kwargs
+ **kwargs: P.kwargs,
) -> OperationMeta: ...
-
-def add_op(state: State, op_func: Operation[P],
+def add_op(
+ state: State,
+ op_func: Operation[P],
_sudo: bool | None = None,
_sudo_user: str | None = None,
_use_sudo_login: bool | None = None,
@@ -86,12 +104,10 @@ def add_op(state: State, op_func: Operation[P],
_serial: bool | None = None,
host: Iterable[Host] | Host | None = None,
*args: P.args,
- **kwargs: P.kwargs
+ **kwargs: P.kwargs,
) -> Dict[Host, OperationMeta]: ...
-
@overload
def operation(func: Callable[P, Generator[Command, None, None]]) -> Operation[P]: ...
-
@overload
def operation(
pipeline_facts=None,
