diff --git a/pyinfra/api/command.py b/pyinfra/api/command.py index 7834e751c..45ff73087 100644 --- a/pyinfra/api/command.py +++ b/pyinfra/api/command.py @@ -236,7 +236,7 @@ def execute(self, state: "State", host: "Host", connector_arguments: ConnectorAr if "state" in argspec.args and "host" in argspec.args: return self.function(state, host, *self.args, **self.kwargs) - def execute_function(): + def execute_function() -> None: with ctx_config.use(state.config.copy()): with ctx_host.use(host): self.function(*self.args, **self.kwargs) diff --git a/pyinfra/api/config.py b/pyinfra/api/config.py index abe61cfe4..3a8a4f6a6 100644 --- a/pyinfra/api/config.py +++ b/pyinfra/api/config.py @@ -224,10 +224,10 @@ def set_current_state(self, config_state): for key, value in config_state: setattr(self, key, value) - def lock_current_state(self): + def lock_current_state(self) -> None: self._locked_config = self.get_current_state() - def reset_locked_state(self): + def reset_locked_state(self) -> None: self.set_current_state(self._locked_config) def copy(self) -> "Config": diff --git a/pyinfra/api/host.py b/pyinfra/api/host.py index badd578bd..bab393a39 100644 --- a/pyinfra/api/host.py +++ b/pyinfra/api/host.py @@ -361,7 +361,7 @@ def get_fact(self, name_or_cls, *args, **kwargs): # Connector proxy # - def _check_state(self): + def _check_state(self) -> None: if not self.state: raise TypeError("Cannot call this function with no state!") @@ -403,7 +403,7 @@ def connect(self, reason=None, show_errors: bool = True, raise_exceptions: bool self.state.trigger_callbacks("host_connect", self) self.connected = True - def disconnect(self): + def disconnect(self) -> None: """ Disconnect from the host using it's configured connector. """ diff --git a/pyinfra/api/state.py b/pyinfra/api/state.py index 773437c09..ab4af5bdb 100644 --- a/pyinfra/api/state.py +++ b/pyinfra/api/state.py @@ -122,7 +122,7 @@ class StateHostMeta: ops_no_change = 0 op_hashes: set[str] - def __init__(self): + def __init__(self) -> None: self.op_hashes = set() diff --git a/pyinfra/connectors/chroot.py b/pyinfra/connectors/chroot.py index a4cd9b34d..5b28c2cf7 100644 --- a/pyinfra/connectors/chroot.py +++ b/pyinfra/connectors/chroot.py @@ -22,7 +22,7 @@ @memoize -def show_warning(): +def show_warning() -> None: logger.warning("The @chroot connector is in beta!") diff --git a/pyinfra/connectors/docker.py b/pyinfra/connectors/docker.py index 8634682c9..e6419bd18 100644 --- a/pyinfra/connectors/docker.py +++ b/pyinfra/connectors/docker.py @@ -129,7 +129,7 @@ def connect(self) -> None: self.container_id = _start_docker_image(docker_identifier) @override - def disconnect(self): + def disconnect(self) -> None: container_id = self.container_id if self.no_stop: diff --git a/pyinfra/connectors/dockerssh.py b/pyinfra/connectors/dockerssh.py index 8c8b85aa3..b3aa750a6 100644 --- a/pyinfra/connectors/dockerssh.py +++ b/pyinfra/connectors/dockerssh.py @@ -22,7 +22,7 @@ @memoize -def show_warning(): +def show_warning() -> None: logger.warning("The @dockerssh connector is in beta!") diff --git a/pyinfra/connectors/local.py b/pyinfra/connectors/local.py index 071f62837..42984211f 100644 --- a/pyinfra/connectors/local.py +++ b/pyinfra/connectors/local.py @@ -210,7 +210,7 @@ def get_file( return True @override - def check_can_rsync(self): + def check_can_rsync(self) -> None: if not which("rsync"): raise NotImplementedError("The `rsync` binary is not available on this system.") diff --git a/pyinfra/connectors/ssh.py b/pyinfra/connectors/ssh.py index cf1893286..593cf1b6f 100644 --- a/pyinfra/connectors/ssh.py +++ b/pyinfra/connectors/ssh.py @@ -543,7 +543,7 @@ def put_file( return True @override - def check_can_rsync(self): + def check_can_rsync(self) -> None: if self.data["ssh_key_password"]: raise NotImplementedError( "Rsync does not currently work with SSH keys needing passwords." diff --git a/pyinfra/connectors/terraform.py b/pyinfra/connectors/terraform.py index dbfc02bed..8a07c8625 100644 --- a/pyinfra/connectors/terraform.py +++ b/pyinfra/connectors/terraform.py @@ -9,7 +9,7 @@ @memoize -def show_warning(): +def show_warning() -> None: logger.warning("The @terraform connector is in beta!") diff --git a/pyinfra/connectors/util.py b/pyinfra/connectors/util.py index 01fe6421c..2ffb7631a 100644 --- a/pyinfra/connectors/util.py +++ b/pyinfra/connectors/util.py @@ -232,7 +232,7 @@ def remove_any_sudo_askpass_file(host) -> None: @memoize -def _show_use_su_login_warning(): +def _show_use_su_login_warning() -> None: logger.warning( ( "Using `use_su_login` may not work: " diff --git a/pyinfra/context.py b/pyinfra/context.py index 1280a8cc4..d774e9724 100644 --- a/pyinfra/context.py +++ b/pyinfra/context.py @@ -27,7 +27,7 @@ class ContextObject: _container_cls = container _base_cls: ModuleType - def __init__(self): + def __init__(self) -> None: self._container = self._container_cls() self._container.module = None @@ -96,7 +96,7 @@ def set(self, module): def set_base(self, module): self.context._base_cls = module - def reset(self): + def reset(self) -> None: self.context._container.module = None def isset(self): diff --git a/pyinfra/facts/iptables.py b/pyinfra/facts/iptables.py index 43ab9d492..121b28ced 100644 --- a/pyinfra/facts/iptables.py +++ b/pyinfra/facts/iptables.py @@ -37,7 +37,7 @@ def parse_iptables_rule(line): args: list[str] = [] not_arg = False - def add_args(): + def add_args() -> None: arg_string = " ".join(args) if key and key in IPTABLES_ARGS: diff --git a/pyinfra/operations/files.py b/pyinfra/operations/files.py index ff4432b35..5730f4f8f 100644 --- a/pyinfra/operations/files.py +++ b/pyinfra/operations/files.py @@ -665,7 +665,7 @@ def sync( @memoize -def show_rsync_warning(): +def show_rsync_warning() -> None: logger.warning("The `files.rsync` operation is in alpha!") diff --git a/pyinfra_cli/main.py b/pyinfra_cli/main.py index 6a48d708d..005a4ab61 100644 --- a/pyinfra_cli/main.py +++ b/pyinfra_cli/main.py @@ -34,7 +34,7 @@ from .virtualenv import init_virtualenv -def _exit(): +def _exit() -> None: if ctx_state.isset() and state.failed_hosts: sys.exit(1) sys.exit(0) diff --git a/pyinfra_cli/prints.py b/pyinfra_cli/prints.py index 7310c8ca0..8701a5cd2 100644 --- a/pyinfra_cli/prints.py +++ b/pyinfra_cli/prints.py @@ -130,7 +130,7 @@ def print_facts(facts): print_fact(data) -def print_support_info(): +def print_support_info() -> None: from importlib.metadata import PackageNotFoundError, requires, version from packaging.requirements import Requirement diff --git a/pyinfra_cli/virtualenv.py b/pyinfra_cli/virtualenv.py index 01bb6ab94..9abcde161 100644 --- a/pyinfra_cli/virtualenv.py +++ b/pyinfra_cli/virtualenv.py @@ -6,7 +6,7 @@ from pyinfra import logger -def init_virtualenv(): +def init_virtualenv() -> None: """ Add a virtualenv to sys.path so the user can import modules from it. This isn't perfect: it doesn't use the Python interpreter with which the