Skip to content

Commit 3a07b7a

Browse files
authored
Make valid typehints for *args **kwargs (#69)
* Make valid typehints for *args **kwargs * do not lookup for pyi
1 parent 3bb7809 commit 3a07b7a

File tree

4 files changed

+25
-31
lines changed

4 files changed

+25
-31
lines changed

exec_helpers/_ssh_client_base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __prepare__( # pylint: disable=unused-argument
9494
mcs: typing.Type['_MemorizedSSH'],
9595
name: str,
9696
bases: typing.Iterable[typing.Type],
97-
**kwargs: typing.Dict
97+
**kwargs: typing.Any
9898
) -> collections.OrderedDict:
9999
"""Metaclass magic for object storage.
100100
@@ -565,7 +565,7 @@ def execute_async(
565565
open_stderr: bool = True,
566566
verbose: bool = False,
567567
log_mask_re: typing.Optional[str] = None,
568-
**kwargs: typing.Dict
568+
**kwargs: typing.Any
569569
) -> _type_execute_async:
570570
"""Execute command in async mode and return channel with IO objects.
571571
@@ -646,7 +646,7 @@ def _exec_command(
646646
timeout: typing.Union[int, float, None],
647647
verbose: bool = False,
648648
log_mask_re: typing.Optional[str] = None,
649-
**kwargs: typing.Dict
649+
**kwargs: typing.Any
650650
) -> exec_result.ExecResult:
651651
"""Get exit status from channel with timeout.
652652
@@ -746,7 +746,7 @@ def execute_through_host(
746746
verbose: bool = False,
747747
timeout: typing.Union[int, float, None] = constants.DEFAULT_TIMEOUT,
748748
get_pty: bool = False,
749-
**kwargs: typing.Dict
749+
**kwargs: typing.Any
750750
) -> exec_result.ExecResult:
751751
"""Execute command on remote host through currently connected host.
752752
@@ -770,7 +770,7 @@ def execute_through_host(
770770
.. versionchanged:: 1.2.0 default timeout 1 hour
771771
.. versionchanged:: 1.2.0 log_mask_re regex rule for masking cmd
772772
"""
773-
cmd_for_log = self._mask_command( # type: ignore
773+
cmd_for_log = self._mask_command(
774774
cmd=command,
775775
log_mask_re=kwargs.get('log_mask_re', None)
776776
)
@@ -808,7 +808,7 @@ def execute_through_host(
808808
channel.exec_command(command) # nosec # Sanitize on caller side
809809

810810
# noinspection PyDictCreation
811-
result = self._exec_command( # type: ignore
811+
result = self._exec_command(
812812
command, channel, stdout, stderr, timeout, verbose=verbose,
813813
log_mask_re=kwargs.get('log_mask_re', None),
814814
)
@@ -825,7 +825,7 @@ def execute_together(
825825
timeout: typing.Union[int, float, None] = constants.DEFAULT_TIMEOUT,
826826
expected: typing.Optional[typing.Iterable[int]] = None,
827827
raise_on_err: bool = True,
828-
**kwargs: typing.Dict
828+
**kwargs: typing.Any
829829
) -> typing.Dict[typing.Tuple[str, int], exec_result.ExecResult]:
830830
"""Execute command on multiple remotes in async mode.
831831
@@ -855,7 +855,7 @@ def get_result(remote: 'SSHClientBase') -> exec_result.ExecResult:
855855
_,
856856
stderr,
857857
stdout,
858-
) = remote.execute_async( # type: ignore
858+
) = remote.execute_async(
859859
command,
860860
**kwargs
861861
) # type: _type_execute_async
@@ -864,7 +864,7 @@ def get_result(remote: 'SSHClientBase') -> exec_result.ExecResult:
864864
exit_code = chan.recv_exit_status()
865865

866866
# pylint: disable=protected-access
867-
cmd_for_log = remote._mask_command( # type: ignore
867+
cmd_for_log = remote._mask_command(
868868
cmd=command,
869869
log_mask_re=kwargs.get('log_mask_re', None)
870870
)

exec_helpers/api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def execute_async(
134134
open_stderr: bool = True,
135135
verbose: bool = False,
136136
log_mask_re: typing.Optional[str] = None,
137-
**kwargs: typing.Dict
137+
**kwargs: typing.Any
138138
) -> typing.Tuple[typing.Any, typing.Any, typing.Any, typing.Any]:
139139
"""Execute command in async mode and return remote interface with IO objects.
140140
@@ -167,7 +167,7 @@ def _exec_command(
167167
timeout: typing.Union[int, float, None],
168168
verbose: bool = False,
169169
log_mask_re: typing.Optional[str] = None,
170-
**kwargs: typing.Dict
170+
**kwargs: typing.Any
171171
) -> exec_result.ExecResult:
172172
"""Get exit status from channel with timeout.
173173
@@ -198,7 +198,7 @@ def execute(
198198
command: str,
199199
verbose: bool = False,
200200
timeout: typing.Union[int, float, None] = constants.DEFAULT_TIMEOUT,
201-
**kwargs: typing.Dict
201+
**kwargs: typing.Any
202202
) -> exec_result.ExecResult:
203203
"""Execute command and wait for return code.
204204
@@ -221,13 +221,13 @@ def execute(
221221
_,
222222
stderr,
223223
stdout,
224-
) = self.execute_async( # type: ignore
224+
) = self.execute_async(
225225
command,
226226
verbose=verbose,
227227
**kwargs
228228
)
229229

230-
result = self._exec_command( # type: ignore
230+
result = self._exec_command(
231231
command=command,
232232
interface=iface,
233233
stdout=stdout,
@@ -251,7 +251,7 @@ def check_call(
251251
error_info: typing.Optional[str] = None,
252252
expected: typing.Optional[typing.Iterable[typing.Union[int, proc_enums.ExitCodes]]] = None,
253253
raise_on_err: bool = True,
254-
**kwargs: typing.Dict
254+
**kwargs: typing.Any
255255
) -> exec_result.ExecResult:
256256
"""Execute command and check for return code.
257257
@@ -300,7 +300,7 @@ def check_stderr(
300300
timeout: typing.Union[int, float, None] = constants.DEFAULT_TIMEOUT,
301301
error_info: typing.Optional[str] = None,
302302
raise_on_err: bool = True,
303-
**kwargs: typing.Dict
303+
**kwargs: typing.Any
304304
) -> exec_result.ExecResult:
305305
"""Execute command expecting return code 0 and empty STDERR.
306306
@@ -334,7 +334,7 @@ def check_stderr(
334334
))
335335
self.logger.error(message)
336336
if raise_on_err:
337-
raise exceptions.CalledProcessError( # type: ignore
337+
raise exceptions.CalledProcessError(
338338
result=ret,
339339
expected=kwargs.get('expected'),
340340
)

exec_helpers/subprocess_runner.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SingletonMeta(type):
4343
_instances = {} # type: typing.Dict[typing.Type, typing.Any]
4444
_lock = threading.RLock() # type: threading.RLock
4545

46-
def __call__(cls: 'SingletonMeta', *args: typing.Tuple, **kwargs: typing.Dict) -> typing.Any:
46+
def __call__(cls: 'SingletonMeta', *args: typing.Any, **kwargs: typing.Any) -> typing.Any:
4747
"""Singleton."""
4848
with cls._lock:
4949
if cls not in cls._instances:
@@ -56,7 +56,7 @@ def __prepare__( # pylint: disable=unused-argument
5656
mcs: typing.Type['SingletonMeta'],
5757
name: str,
5858
bases: typing.Iterable[typing.Type],
59-
**kwargs: typing.Dict
59+
**kwargs: typing.Any
6060
) -> collections.OrderedDict:
6161
"""Metaclass magic for object storage.
6262
@@ -91,7 +91,7 @@ def _exec_command(
9191
timeout: typing.Union[int, float, None],
9292
verbose: bool = False,
9393
log_mask_re: typing.Optional[str] = None,
94-
**kwargs: typing.Dict
94+
**kwargs: typing.Any
9595
) -> exec_result.ExecResult:
9696
"""Get exit status from channel with timeout.
9797
@@ -184,7 +184,7 @@ def execute_async( # pylint: disable=signature-differs
184184
open_stderr: bool = True,
185185
verbose: bool = False,
186186
log_mask_re: typing.Optional[str] = None,
187-
**kwargs: typing.Dict
187+
**kwargs: typing.Any
188188
) -> typing.Tuple[subprocess.Popen, None, None, None]:
189189
"""Overload: with stdin."""
190190
pass # pragma: no cover
@@ -198,7 +198,7 @@ def execute_async(
198198
open_stderr: bool = True,
199199
verbose: bool = False,
200200
log_mask_re: typing.Optional[str] = None,
201-
**kwargs: typing.Dict
201+
**kwargs: typing.Any
202202
) -> typing.Tuple[subprocess.Popen, None, typing.IO, typing.IO]:
203203
"""Overload: no stdin."""
204204
pass # pragma: no cover
@@ -212,7 +212,7 @@ def execute_async( # type: ignore # noqa: F811
212212
open_stderr: bool = True,
213213
verbose: bool = False,
214214
log_mask_re: typing.Optional[str] = None,
215-
**kwargs: typing.Dict
215+
**kwargs: typing.Any
216216
) -> typing.Tuple[subprocess.Popen, None, typing.Optional[typing.IO], typing.Optional[typing.IO]]:
217217
"""Execute command in async mode and return Popen with IO objects.
218218
@@ -245,7 +245,7 @@ def execute_async( # type: ignore # noqa: F811
245245
msg=_log_templates.CMD_EXEC.format(cmd=cmd_for_log)
246246
)
247247

248-
process = subprocess.Popen( # type: ignore
248+
process = subprocess.Popen(
249249
args=[command],
250250
stdout=subprocess.PIPE if open_stdout else subprocess.DEVNULL,
251251
stderr=subprocess.PIPE if open_stderr else subprocess.DEVNULL,

setup.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import collections
2626
from distutils.command import build_ext
2727
import distutils.errors
28-
import glob
2928
import os.path
3029
import shutil
3130
import sys
@@ -270,12 +269,7 @@ def get_simple_vars_from_src(src):
270269
"!=36.2.0",
271270
install_requires=required,
272271
package_data={
273-
str('exec_helpers'): [
274-
os.path.basename(filename)
275-
for filename in glob.glob(os.path.join('exec_helpers', '*.pyi'))
276-
] + [
277-
'py.typed'
278-
],
272+
'exec_helpers': ['py.typed'],
279273
},
280274
)
281275
if cythonize is not None:

0 commit comments

Comments
 (0)