summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/connection/local.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/plugins/connection/local.py')
-rw-r--r--lib/ansible/plugins/connection/local.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/ansible/plugins/connection/local.py b/lib/ansible/plugins/connection/local.py
index 27afd105..d6dccc70 100644
--- a/lib/ansible/plugins/connection/local.py
+++ b/lib/ansible/plugins/connection/local.py
@@ -2,7 +2,7 @@
# (c) 2015, 2017 Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
+from __future__ import (annotations, absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
@@ -24,12 +24,13 @@ import os
import pty
import shutil
import subprocess
+import typing as t
import ansible.constants as C
from ansible.errors import AnsibleError, AnsibleFileNotFound
from ansible.module_utils.compat import selectors
from ansible.module_utils.six import text_type, binary_type
-from ansible.module_utils._text import to_bytes, to_native, to_text
+from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.plugins.connection import ConnectionBase
from ansible.utils.display import Display
from ansible.utils.path import unfrackpath
@@ -43,7 +44,7 @@ class Connection(ConnectionBase):
transport = 'local'
has_pipelining = True
- def __init__(self, *args, **kwargs):
+ def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
super(Connection, self).__init__(*args, **kwargs)
self.cwd = None
@@ -53,7 +54,7 @@ class Connection(ConnectionBase):
display.vv("Current user (uid=%s) does not seem to exist on this system, leaving user empty." % os.getuid())
self.default_user = ""
- def _connect(self):
+ def _connect(self) -> Connection:
''' connect to the local host; nothing to do here '''
# Because we haven't made any remote connection we're running as
@@ -65,7 +66,7 @@ class Connection(ConnectionBase):
self._connected = True
return self
- def exec_command(self, cmd, in_data=None, sudoable=True):
+ def exec_command(self, cmd: str, in_data: bytes | None = None, sudoable: bool = True) -> tuple[int, bytes, bytes]:
''' run a command on the local host '''
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
@@ -163,7 +164,7 @@ class Connection(ConnectionBase):
display.debug("done with local.exec_command()")
return (p.returncode, stdout, stderr)
- def put_file(self, in_path, out_path):
+ def put_file(self, in_path: str, out_path: str) -> None:
''' transfer a file from local to local '''
super(Connection, self).put_file(in_path, out_path)
@@ -181,7 +182,7 @@ class Connection(ConnectionBase):
except IOError as e:
raise AnsibleError("failed to transfer file to {0}: {1}".format(to_native(out_path), to_native(e)))
- def fetch_file(self, in_path, out_path):
+ def fetch_file(self, in_path: str, out_path: str) -> None:
''' fetch a file from local to local -- for compatibility '''
super(Connection, self).fetch_file(in_path, out_path)
@@ -189,6 +190,6 @@ class Connection(ConnectionBase):
display.vvv(u"FETCH {0} TO {1}".format(in_path, out_path), host=self._play_context.remote_addr)
self.put_file(in_path, out_path)
- def close(self):
+ def close(self) -> None:
''' terminate the connection; nothing to do here '''
self._connected = False