Skip to content

Commit eaed0fb

Browse files
committed
Make typing annotations in docstrings better
1 parent aa3a8db commit eaed0fb

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

exec_helpers/_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def mask_command(text: str, *rules: str | None) -> str:
6161
:param text: source text
6262
:type text: str
6363
:param rules: regex rules to mask.
64-
:type rules: typing.Optional[str]
64+
:type rules: str | None
6565
:return: source with all MATCHED groups replaced by '<*masked*>'
6666
:rtype: str
6767
"""

exec_helpers/_ssh_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ class SSHClientBase(api.ExecHelper):
448448
:param ssh_auth_map: SSH authentication information mapped to host names. Useful for complex SSH Proxy cases.
449449
:type ssh_auth_map: dict[str, ssh_auth.SSHAuth] | ssh_auth.SSHAuthMapping | None
450450
:param sock: socket for connection. Useful for ssh proxies support
451-
:type sock: typing.Optional[typing.Union[paramiko.ProxyCommand, paramiko.Channel, socket.socket]]
451+
:type sock: paramiko.ProxyCommand | paramiko.Channel | socket.socket | None
452452
:param keepalive: keepalive period
453453
:type keepalive: int | bool
454454

exec_helpers/_ssh_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _parse_ssh_config_file(file_path: pathlib.Path) -> paramiko.SSHConfig | None
3434
:param file_path: file path for parsing
3535
:type file_path: pathlib.Path
3636
:return: SSH config if file found and parsed else None
37-
:rtype: typing.Optional[paramiko.SSHConfig]
37+
:rtype: paramiko.SSHConfig | None
3838
"""
3939
if not file_path.exists():
4040
return None

exec_helpers/api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ def _execute_async(
378378
'ExecuteAsyncResult',
379379
[
380380
('interface', typing.Any),
381-
('stdin', typing.Optional[typing.Any]),
382-
('stderr', typing.Optional[typing.Any]),
383-
('stdout', typing.Optional[typing.Any]),
381+
('stdin', typing.Any | None),
382+
('stderr', typing.Any | None),
383+
('stdout', typing.Any | None),
384384
("started", datetime.datetime),
385385
]
386386
)
@@ -640,7 +640,7 @@ def check_call(
640640
"""Execute command and check for return code.
641641
642642
:param command: Command for execution
643-
:type command: typing.Union[str, typing.Iterable[str]]
643+
:type command: str | Iterable[str]
644644
:param verbose: Produce log.info records for command call and output
645645
:type verbose: bool
646646
:param timeout: Timeout for command execution.
@@ -755,7 +755,7 @@ def check_stderr(
755755
"""Execute command expecting return code 0 and empty STDERR.
756756
757757
:param command: Command for execution
758-
:type command: typing.Union[str, typing.Iterable[str]]
758+
:type command: str | Iterable[str]
759759
:param verbose: Produce log.info records for command call and output
760760
:type verbose: bool
761761
:param timeout: Timeout for command execution.

exec_helpers/async_api/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ async def check_call(
611611
:param error_info: Text for error details, if fail happens
612612
:type error_info: str | None
613613
:param expected: expected return codes (0 by default)
614-
:type expected: typing.Iterable[typing.Union[int, proc_enums.ExitCodes]]
614+
:type expected: Iterable[int | proc_enums.ExitCodes]
615615
:param raise_on_err: Raise exception on unexpected return code
616616
:type raise_on_err: bool
617617
:param log_mask_re: regex lookup rule to mask command for logger.
@@ -726,7 +726,7 @@ async def check_stderr(
726726
:param raise_on_err: Raise exception on unexpected return code
727727
:type raise_on_err: bool
728728
:param expected: expected return codes (0 by default)
729-
:type expected: typing.Iterable[typing.Union[int, proc_enums.ExitCodes]]
729+
:type expected: Iterable[int | proc_enums.ExitCodes]
730730
:param log_mask_re: regex lookup rule to mask command for logger.
731731
all MATCHED groups will be replaced by '<*masked*>'
732732
:type log_mask_re: str | None

exec_helpers/async_api/subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ async def _execute_async(
385385
:param command: Command for execution
386386
:type command: str
387387
:param stdin: pass STDIN text to the process
388-
:type stdin: typing.Union[str, bytes, bytearray, None]
388+
:type stdin: str | bytes | bytearray | None
389389
:param open_stdout: open STDOUT stream for read
390390
:type open_stdout: bool
391391
:param open_stderr: open STDERR stream for read

exec_helpers/exec_result.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __getitem__(
156156
"""Access magic.
157157
158158
:param item: index
159-
:type item: typing.Union[int, slice, Iterable[typing.Union[int, slice, ellipsis]]]
159+
:type item: int | slice | Iterable[int | slice | ellipsis]
160160
:return: Joined selected lines
161161
:rtype: str
162162
:raises TypeError: Unexpected key
@@ -238,7 +238,7 @@ def __init__(
238238
:param cmd: command
239239
:type cmd: str
240240
:param stdin: string STDIN
241-
:type stdin: typing.Union[bytes, str, bytearray, None]
241+
:type stdin: bytes | str | bytearray | None
242242
:param stdout: binary STDOUT
243243
:type stdout: Iterable[bytes] | None
244244
:param stderr: binary STDERR
@@ -327,7 +327,7 @@ def _get_brief(cls, data: tuple[bytes, ...]) -> str:
327327
"""Get brief output: 7 lines maximum (3 first + ... + 3 last).
328328
329329
:param data: source to process
330-
:type data: typing.Tuple[bytes, ...]
330+
:type data: tuple[bytes, ...]
331331
:return: brief from source
332332
:rtype: str
333333
"""
@@ -349,7 +349,7 @@ def stdin(self) -> str | None:
349349
"""Stdin input as string.
350350
351351
:return: STDIN content if applicable.
352-
:rtype: typing.Optional[str]
352+
:rtype: str | None
353353
"""
354354
return self.__stdin
355355

@@ -358,7 +358,7 @@ def stdout(self) -> tuple[bytes, ...]:
358358
"""Stdout output as list of binaries.
359359
360360
:return: STDOUT as tuple of binary strings
361-
:rtype: typing.Tuple[bytes, ...]
361+
:rtype: tuple[bytes, ...]
362362
"""
363363
return self._stdout
364364

@@ -367,7 +367,7 @@ def stderr(self) -> tuple[bytes, ...]:
367367
"""Stderr output as list of binaries.
368368
369369
:return: STDERR as tuple of binary strings
370-
:rtype: typing.Tuple[bytes, ...]
370+
:rtype: tuple[bytes, ...]
371371
"""
372372
return self._stderr
373373

exec_helpers/ssh_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def __init__(
6565
:param key: Main connection key
6666
:type key: paramiko.PKey | None
6767
:param keys: Alternate connection keys
68-
:type keys: Sequence[tparamiko.PKey | None] | None
68+
:type keys: Sequence[paramiko.PKey | None] | None
6969
:param key_filename: filename(s) for additional key files
70-
:type key_filename: typing.Union[Iterable[str], str, None]
70+
:type key_filename: Iterable[str] | str | None
7171
:param passphrase: passphrase for keys. Need, if differs from password
7272
:type passphrase: str | None
7373

exec_helpers/subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def _execute_async(
397397
:param command: Command for execution
398398
:type command: str
399399
:param stdin: pass STDIN text to the process
400-
:type stdin: typing.Union[str, bytes, bytearray, None]
400+
:type stdin: str | bytes | bytearray | None
401401
:param open_stdout: open STDOUT stream for read
402402
:type open_stdout: bool
403403
:param open_stderr: open STDERR stream for read

0 commit comments

Comments
 (0)