2525import logging
2626import re
2727import threading
28- import typing
29-
30- import six # noqa # pylint: disable=unused-import
28+ import typing # noqa # pylint: disable=unused-import
3129
3230from exec_helpers import constants
3331from exec_helpers import exceptions
3432from exec_helpers import exec_result # noqa # pylint: disable=unused-import
3533from exec_helpers import proc_enums
3634
37- _type_exit_codes = typing .Union [int , proc_enums .ExitCodes ]
38- _type_expected = typing .Optional [typing .Iterable [_type_exit_codes ]]
39-
4035
4136class ExecHelper (object ):
4237 """ExecHelper global API."""
@@ -136,19 +131,19 @@ def mask(text, rules): # type: (str, str) -> str
136131 def execute_async (
137132 self ,
138133 command , # type: str
139- stdin = None , # type: typing.Union[six.text_type, six.binary_type , bytearray, None]
134+ stdin = None , # type: typing.Union[typing.AnyStr , bytearray, None]
140135 open_stdout = True , # type: bool
141136 open_stderr = True , # type: bool
142137 verbose = False , # type: bool
143138 log_mask_re = None , # type: typing.Optional[str]
144139 ** kwargs
145- ):
140+ ): # type: (...) -> typing.Tuple[typing.Any, typing.Any, typing.Any, typing.Any,]
146141 """Execute command in async mode and return remote interface with IO objects.
147142
148143 :param command: Command for execution
149144 :type command: str
150145 :param stdin: pass STDIN text to the process
151- :type stdin: typing.Union[six.text_type, six.binary_type , bytearray, None]
146+ :type stdin: typing.Union[typing.AnyStr , bytearray, None]
152147 :param open_stdout: open STDOUT stream for read
153148 :type open_stdout: bool
154149 :param open_stderr: open STDERR stream for read
@@ -176,7 +171,7 @@ def _exec_command(
176171 interface , # type: typing.Any
177172 stdout , # type: typing.Any
178173 stderr , # type: typing.Any
179- timeout , # type: int
174+ timeout , # type: typing.Union[ int, None]
180175 verbose = False , # type: bool
181176 log_mask_re = None , # type: typing.Optional[str]
182177 ** kwargs
@@ -209,7 +204,7 @@ def execute(
209204 self ,
210205 command , # type: str
211206 verbose = False , # type: bool
212- timeout = constants .DEFAULT_TIMEOUT , # type: typing.Optional [int]
207+ timeout = constants .DEFAULT_TIMEOUT , # type: typing.Union [int, None ]
213208 ** kwargs
214209 ): # type: (...) -> exec_result.ExecResult
215210 """Execute command and wait for return code.
@@ -221,7 +216,7 @@ def execute(
221216 :param verbose: Produce log.info records for command call and output
222217 :type verbose: bool
223218 :param timeout: Timeout for command execution.
224- :type timeout: typing.Optional [int]
219+ :type timeout: typing.Union [int, None ]
225220 :rtype: ExecResult
226221 :raises ExecHelperTimeoutError: Timeout exceeded
227222
@@ -259,9 +254,9 @@ def check_call(
259254 self ,
260255 command , # type: str
261256 verbose = False , # type: bool
262- timeout = constants .DEFAULT_TIMEOUT , # type: typing.Optional [int]
257+ timeout = constants .DEFAULT_TIMEOUT , # type: typing.Union [int, None ]
263258 error_info = None , # type: typing.Optional[str]
264- expected = None , # type: _type_expected
259+ expected = None , # type: typing.Optional[typing.Iterable[typing.Union[int, proc_enums.ExitCodes]]]
265260 raise_on_err = True , # type: bool
266261 ** kwargs
267262 ): # type: (...) -> exec_result.ExecResult
@@ -274,11 +269,11 @@ def check_call(
274269 :param verbose: Produce log.info records for command call and output
275270 :type verbose: bool
276271 :param timeout: Timeout for command execution.
277- :type timeout: typing.Optional [int]
272+ :type timeout: typing.Union [int, None ]
278273 :param error_info: Text for error details, if fail happens
279274 :type error_info: typing.Optional[str]
280275 :param expected: expected return codes (0 by default)
281- :type expected: typing.Optional[typing.Iterable[int]]
276+ :type expected: typing.Optional[typing.Iterable[typing.Union[ int, proc_enums.ExitCodes] ]]
282277 :param raise_on_err: Raise exception on unexpected return code
283278 :type raise_on_err: bool
284279 :rtype: ExecResult
@@ -309,7 +304,7 @@ def check_stderr(
309304 self ,
310305 command , # type: str
311306 verbose = False , # type: bool
312- timeout = constants .DEFAULT_TIMEOUT , # type: typing.Optional [int]
307+ timeout = constants .DEFAULT_TIMEOUT , # type: typing.Union [int, None ]
313308 error_info = None , # type: typing.Optional[str]
314309 raise_on_err = True , # type: bool
315310 ** kwargs
@@ -323,7 +318,7 @@ def check_stderr(
323318 :param verbose: Produce log.info records for command call and output
324319 :type verbose: bool
325320 :param timeout: Timeout for command execution.
326- :type timeout: typing.Optional [int]
321+ :type timeout: typing.Union [int, None ]
327322 :param error_info: Text for error details, if fail happens
328323 :type error_info: typing.Optional[str]
329324 :param raise_on_err: Raise exception on unexpected return code
0 commit comments