Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions exec_helpers/_api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ExecHelper:
@property
def lock(self) -> threading.RLock: ...

def __enter__(self): ...
def __enter__(self) -> ExecHelper: ...

def __exit__(self, exc_type: typing.Any, exc_val: typing.Any, exc_tb: typing.Any) -> None: ...

Expand All @@ -29,7 +29,7 @@ class ExecHelper:
open_stderr: bool=...,
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
**kwargs
**kwargs: typing.Dict
) -> typing.Tuple[typing.Any, typing.Any, typing.Any, typing.Any,]: ...

def _exec_command(
Expand All @@ -41,15 +41,15 @@ class ExecHelper:
timeout: typing.Union[int, None],
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
**kwargs
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...

def execute(
self,
command: str,
verbose: bool=...,
timeout: typing.Union[int, None]=...,
**kwargs
**kwargs: typing.Type
) -> exec_result.ExecResult: ...

def check_call(
Expand All @@ -60,7 +60,7 @@ class ExecHelper:
error_info: typing.Optional[str]=...,
expected: typing.Optional[typing.Iterable[typing.Union[int, proc_enums.ExitCodes]]]=...,
raise_on_err: bool=...,
**kwargs
**kwargs: typing.Type
) -> exec_result.ExecResult: ...

def check_stderr(
Expand All @@ -70,5 +70,5 @@ class ExecHelper:
timeout: typing.Union[int, None]=...,
error_info: typing.Optional[str]=...,
raise_on_err: bool=...,
**kwargs
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...
18 changes: 9 additions & 9 deletions exec_helpers/_ssh_client_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ from exec_helpers import exec_result, ssh_auth, _api

class _MemorizedSSH(type):
@classmethod
def __prepare__(mcs, name: str, bases: typing.Iterable[typing.Type], **kwargs) -> collections.OrderedDict: ...
def __prepare__(mcs: typing.Type, name: str, bases: typing.Iterable[typing.Type], **kwargs: typing.Dict) -> collections.OrderedDict: ...

def __call__( # type: ignore
cls,
cls: typing.Type[SSHClientBase],
host: str,
port: int=...,
username: typing.Optional[str]=...,
Expand All @@ -22,14 +22,14 @@ class _MemorizedSSH(type):
) -> SSHClientBase: ...

@classmethod
def clear_cache(mcs) -> None: ...
def clear_cache(mcs: typing.Type[SSHClientBase]) -> None: ... # type: ignore

@classmethod
def close_connections(mcs) -> None: ...
def close_connections(mcs: typing.Type[SSHClientBase]) -> None: ... # type: ignore


class SSHClientBase(_api.ExecHelper, metaclass=_MemorizedSSH):
def __hash__(self): ...
def __hash__(self) -> int: ...

def __init__(
self,
Expand Down Expand Up @@ -100,7 +100,7 @@ class SSHClientBase(_api.ExecHelper, metaclass=_MemorizedSSH):
open_stderr: bool=...,
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
**kwargs
**kwargs: typing.Dict
) -> typing.Tuple[paramiko.Channel, paramiko.ChannelFile, typing.Optional[paramiko.ChannelFile], typing.Optional[paramiko.ChannelFile]]: ...

def _exec_command(
Expand All @@ -112,7 +112,7 @@ class SSHClientBase(_api.ExecHelper, metaclass=_MemorizedSSH):
timeout: typing.Union[int, None],
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
**kwargs
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...

def execute_through_host(
Expand All @@ -124,7 +124,7 @@ class SSHClientBase(_api.ExecHelper, metaclass=_MemorizedSSH):
verbose: bool=...,
timeout: typing.Union[int, None]=...,
get_pty: bool=...,
**kwargs
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...

@classmethod
Expand All @@ -135,7 +135,7 @@ class SSHClientBase(_api.ExecHelper, metaclass=_MemorizedSSH):
timeout: typing.Union[int, None]=...,
expected: typing.Optional[typing.Iterable[int]]=...,
raise_on_err: bool=...,
**kwargs
**kwargs: typing.Dict
) -> typing.Dict[typing.Tuple[str, int], exec_result.ExecResult]: ...

def open(self, path: str, mode: str = ...) -> paramiko.SFTPFile: ...
Expand Down
6 changes: 3 additions & 3 deletions exec_helpers/proc_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class SigNum(enum.IntEnum):
SIGPWR = 30 # Power failure restart (System V).
SIGSYS = 31 # Bad system call.

def __str__(self): # pragma: no cover
def __str__(self): # type: () -> str
"""Representation for logs."""
return "{name}<{value:d}(0x{value:02X})>".format(
return "{name}<{value:d}(0x{value:02X})>".format( # pragma: no cover
name=self.name,
value=self.value
)
Expand Down Expand Up @@ -150,7 +150,7 @@ class ExitCodes(digit_type, enum.Enum):
EX_SIGPWR = 128 + SigNum.SIGPWR
EX_SIGSYS = 128 + SigNum.SIGSYS

def __str__(self):
def __str__(self): # type: () -> str
"""Representation for logs."""
return "{name}<{value:d}(0x{value:02X})>".format(
name=self.name,
Expand Down
25 changes: 19 additions & 6 deletions exec_helpers/subprocess_runner.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class SingletonMeta(type):
_instances: typing.Dict[typing.Type, typing.Any] = ...
_lock: threading.RLock = ...

def __call__(cls, *args, **kwargs): ...
def __call__(cls: typing.Type, *args: typing.Tuple, **kwargs: typing.Dict) -> typing.Any: ...

@classmethod
def __prepare__(mcs, name: str, bases: typing.Iterable[typing.Type], **kwargs) -> collections.OrderedDict: ...
def __prepare__(mcs: typing.Type, name: str, bases: typing.Iterable[typing.Type], **kwargs: typing.Dict) -> collections.OrderedDict: ...


def set_nonblocking_pipe(pipe: typing.Any) -> None: ...
Expand All @@ -40,16 +40,29 @@ class Subprocess(_api.ExecHelper, metaclass=SingletonMeta):
timeout: typing.Union[int, None],
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
**kwargs
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...

@typing.overload # type: ignore
def execute_async(
self,
command: str,
stdin: typing.Union[typing.AnyStr, bytearray, None]=...,
stdin: typing.Union[typing.AnyStr, bytearray]=...,
open_stdout: bool=...,
open_stderr: bool=...,
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
**kwargs
) -> typing.Tuple[subprocess.Popen, None, typing.Optional[typing.IO], typing.Optional[typing.IO]]: ...
**kwargs: typing.Dict
) -> typing.Tuple[subprocess.Popen, None, None, None]: ...

@typing.overload
def execute_async(
self,
command: str,
stdin: None=...,
open_stdout: bool=...,
open_stderr: bool=...,
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
**kwargs: typing.Dict
) -> typing.Tuple[subprocess.Popen, None, typing.IO, typing.IO]: ...
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ commands = pip install ./ -vvv -U
basepython = python3.6
usedevelop = False
deps =
pylint
pylint<2
-r{toxinidir}/CI_REQUIREMENTS.txt
commands = pylint exec_helpers

Expand Down Expand Up @@ -141,3 +141,9 @@ deps =
.
pipdeptree
commands = pipdeptree

[testenv:mypy]
deps =
mypy>=0.620
-r{toxinidir}/CI_REQUIREMENTS.txt
commands = mypy --strict exec_helpers