2121from __future__ import annotations
2222
2323import abc
24+ import contextlib
2425import logging
2526import pathlib
27+ import re
2628import threading
2729import typing
30+ from collections .abc import Callable
31+ from collections .abc import Iterable
2832
2933from exec_helpers import constants
3034from exec_helpers import exceptions
5559 "OptionalTimeoutT" ,
5660)
5761
58- CommandT = typing .Union [str , typing . Iterable [str ]]
59- LogMaskReT = typing .Union [str , typing .Pattern [str ], None ]
62+ CommandT = typing .Union [str , Iterable [str ]]
63+ LogMaskReT = typing .Union [str , re .Pattern [str ], None ]
6064ErrorInfoT = typing .Optional [str ]
6165ChRootPathSetT = typing .Optional [typing .Union [str , pathlib .Path ]]
62- ExpectedExitCodesT = typing . Iterable [ExitCodeT ]
66+ ExpectedExitCodesT = Iterable [ExitCodeT ]
6367OptionalTimeoutT = typing .Union [int , float , None ]
64- CalledProcessErrorSubClassT = typing . Type [exceptions .CalledProcessError ]
68+ CalledProcessErrorSubClassT = type [exceptions .CalledProcessError ]
6569
6670
6771class ExecuteAsyncResult (typing .NamedTuple ):
@@ -74,7 +78,7 @@ class ExecuteAsyncResult(typing.NamedTuple):
7478 started : datetime .datetime
7579
7680
77- class ExecuteContext (typing . ContextManager [ExecuteAsyncResult ], abc .ABC ):
81+ class ExecuteContext (contextlib . AbstractContextManager [ExecuteAsyncResult ], abc .ABC ):
7882 """Execute context manager."""
7983
8084 __slots__ = (
@@ -165,7 +169,7 @@ def open_stderr(self) -> bool:
165169
166170
167171# noinspection PyProtectedMember
168- class _ChRootContext (typing . ContextManager [None ]):
172+ class _ChRootContext (contextlib . AbstractContextManager [None ]):
169173 """Context manager for call commands with chroot.
170174
171175 :param conn: Connection instance.
@@ -219,8 +223,8 @@ def __exit__(
219223
220224
221225class ExecHelper (
222- typing . Callable [..., exec_result .ExecResult ], # type: ignore[misc]
223- typing . ContextManager ["ExecHelper" ],
226+ Callable [..., exec_result .ExecResult ], # type: ignore[misc]
227+ contextlib . AbstractContextManager ["ExecHelper" ],
224228 abc .ABC ,
225229):
226230 """ExecHelper global API.
0 commit comments