Skip to content

Commit bc78cbe

Browse files
committed
Maintenance: Update documentation
* update pre-commit
1 parent a99d380 commit bc78cbe

File tree

6 files changed

+205
-205
lines changed

6 files changed

+205
-205
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.1.0
3+
rev: v4.3.0
44
hooks:
55
- id: check-yaml
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88
- id: mixed-line-ending
99

1010
- repo: https://github.com/pycqa/isort
11-
rev: 5.10.1
11+
rev: 5.11.2
1212
hooks:
1313
- id: isort
1414
name: isort (python)
@@ -20,15 +20,14 @@ repos:
2020
types: [pyi]
2121

2222
- repo: https://github.com/psf/black
23-
rev: 22.3.0
23+
rev: 22.12.0
2424
hooks:
2525
- id: black
2626
# It is recommended to specify the latest version of Python
2727
# supported by your project here, or alternatively use
2828
# pre-commit's default_language_version, see
2929
# https://pre-commit.com/#top_level-default_language_version
3030
language_version: python3.9
31-
always_run: true
3231

3332
- repo: https://github.com/pre-commit/pygrep-hooks
3433
rev: v1.9.0 # Use the ref you want to point at
@@ -38,8 +37,8 @@ repos:
3837
- id: rst-directive-colons
3938
- id: rst-inline-touching-normal
4039

41-
- repo: https://gitlab.com/pycqa/flake8
42-
rev: 3.9.2
40+
- repo: https://github.com/PyCQA/flake8
41+
rev: 6.0.0
4342
hooks:
4443
- id: flake8
4544
additional_dependencies: [flake8-bugbear, pep8-naming, flake8-docstrings]

README.rst

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Pros:
4747
Python 3.8
4848
Python 3.9
4949
Python 3.10
50+
Python 3.11
5051

5152
.. note:: Old pythons: For Python 2.7 and PyPy use versions 1.x.x, python 3.4 use versions 2.x.x, python 3.5 and PyPy 3.5 use versions 3.x.x
5253

@@ -97,7 +98,7 @@ Basic initialization of `SSHClient` can be done without construction of specific
9798
client = exec_helpers.SSHClient(host, username="username", password="password")
9899
99100
If ssh agent is running - keys will be collected by paramiko automatically,
100-
but if keys are in specific location - it should be loaded manually and provided as iterable object of `paramiko.RSAKey`.
101+
but if keys are in specific location - it should be loaded manually and provided as iterable object of `paramiko.PKey`.
101102

102103
For advanced cases or re-use of credentials, `SSHAuth` object should be used.
103104
It can be collected from connection object via property `auth`.
@@ -107,12 +108,12 @@ Creation from scratch:
107108
.. code-block:: python
108109
109110
auth = exec_helpers.SSHAuth(
110-
username='username', # type: Optional[str]
111-
password='password', # type: Optional[str]
112-
key=None, # type: Optional[paramiko.RSAKey]
113-
keys=None, # type: Optional[Iterable[paramiko.RSAKey]],
114-
key_filename=None, # type: Union[List[str], None]
115-
passphrase=None, # type: Optional[str]
111+
username='username', # str | None
112+
password='password', # str | None
113+
key=None, # type: paramiko.PKey | None
114+
keys=None, # type: Iterable[paramiko.PKey] | None
115+
key_filename=None, # type: List[str] | None
116+
passphrase=None, # str | None
116117
)
117118
118119
Key is a main connection key (always tried first) and keys are alternate keys.
@@ -141,12 +142,12 @@ This methods are almost the same for `SSHClient` and `Subprocess`, except specif
141142
.. code-block:: python
142143
143144
result: ExecResult = helper.execute(
144-
command, # type: Union[str, Iterable[str]]
145+
command, # type: str | Iterable[str]
145146
verbose=False, # type: bool
146-
timeout=1 * 60 * 60, # type: Union[int, float, None]
147+
timeout=1 * 60 * 60, # type: int | float | None
147148
# Keyword only:
148-
log_mask_re=None, # type: Optional[str]
149-
stdin=None, # type: Union[bytes, str, bytearray, None]
149+
log_mask_re=None, # str | None
150+
stdin=None, # type: bytes | str | bytearray | None
150151
open_stdout=True, # type: bool
151152
log_stdout=True, # type: bool
152153
open_stderr=True, # type: bool
@@ -158,51 +159,51 @@ This methods are almost the same for `SSHClient` and `Subprocess`, except specif
158159
.. code-block:: python
159160
160161
result: ExecResult = helper.check_call(
161-
command, # type: Union[str, Iterable[str]]
162+
command, # type: str | Iterable[str]
162163
verbose=False, # type: bool
163-
timeout=1 * 60 * 60, # type: type: Union[int, float, None]
164-
error_info=None, # type: Optional[str]
165-
expected=(0,), # type: Iterable[Union[int, ExitCodes]]
164+
timeout=1 * 60 * 60, # type: type: int | float | None
165+
error_info=None, # str | None
166+
expected=(0,), # type: Iterable[int | ExitCodes]
166167
raise_on_err=True, # type: bool
167168
# Keyword only:
168-
log_mask_re=None, # type: Optional[str]
169-
stdin=None, # type: Union[bytes, str, bytearray, None]
169+
log_mask_re=None, # str | None
170+
stdin=None, # type: bytes | str | bytearray | None
170171
open_stdout=True, # type: bool
171172
log_stdout=True, # type: bool
172173
open_stderr=True, # type: bool
173174
log_stderr=True, # type: bool
174-
exception_class=CalledProcessError, # Type[CalledProcessError]
175+
exception_class=CalledProcessError, # type[CalledProcessError]
175176
**kwargs
176177
)
177178
178179
.. code-block:: python
179180
180181
result: ExecResult = helper.check_stderr(
181-
command, # type: Union[str, Iterable[str]]
182+
command, # type: str | Iterable[str]
182183
verbose=False, # type: bool
183-
timeout=1 * 60 * 60, # type: type: Union[int, float, None]
184-
error_info=None, # type: Optional[str]
184+
timeout=1 * 60 * 60, # type: type: int | float | None
185+
error_info=None, # str | None
185186
raise_on_err=True, # type: bool
186187
# Keyword only:
187-
expected=(0,), # Iterable[Union[int, ExitCodes]]
188-
log_mask_re=None, # type: Optional[str]
189-
stdin=None, # type: Union[bytes, str, bytearray, None]
188+
expected=(0,), # Iterable[int | ExitCodes]
189+
log_mask_re=None, # str | None
190+
stdin=None, # type: bytes | str | bytearray | None
190191
open_stdout=True, # type: bool
191192
log_stdout=True, # type: bool
192193
open_stderr=True, # type: bool
193194
log_stderr=True, # type: bool
194-
exception_class=CalledProcessError, # Type[CalledProcessError]
195+
exception_class=CalledProcessError, # type[CalledProcessError]
195196
)
196197
197198
.. code-block:: python
198199
199200
result: ExecResult = helper( # Lazy way: instances are callable and uses `execute`.
200-
command, # type: Union[str, Iterable[str]]
201+
command, # type: str | Iterable[str]
201202
verbose=False, # type: bool
202-
timeout=1 * 60 * 60, # type: Union[int, float, None]
203+
timeout=1 * 60 * 60, # type: int | float | None
203204
# Keyword only:
204-
log_mask_re=None, # type: Optional[str]
205-
stdin=None, # type: Union[bytes, str, bytearray, None]
205+
log_mask_re=None, # str | None
206+
stdin=None, # type: bytes | str | bytearray | None
206207
open_stdout=True, # type: bool
207208
log_stdout=True, # type: bool
208209
open_stderr=True, # type: bool
@@ -226,10 +227,10 @@ All regex matched groups will be replaced by `'<*masked*>'`.
226227
.. code-block:: python
227228
228229
result: ExecResult = helper.execute(
229-
command="AUTH='top_secret_key'; run command", # type: Union[str, Iterable[str]]
230+
command="AUTH='top_secret_key'; run command", # type: str | Iterable[str]
230231
verbose=False, # type: bool
231232
timeout=1 * 60 * 60, # type: Optional[int]
232-
log_mask_re=r"AUTH\s*=\s*'(\w+)'" # type: Optional[str]
233+
log_mask_re=r"AUTH\s*=\s*'(\w+)'" # str | None
233234
)
234235
235236
`result.cmd` will be equal to `AUTH='<*masked*>'; run command`
@@ -276,18 +277,18 @@ Possible to call commands in parallel on multiple hosts if it's not produce huge
276277
277278
results: Dict[Tuple[str, int], ExecResult] = SSHClient.execute_together(
278279
remotes, # type: Iterable[SSHClient]
279-
command, # type: Union[str, Iterable[str]]
280-
timeout=1 * 60 * 60, # type: type: Union[int, float, None]
281-
expected=(0,), # type: Iterable[Union[int, ExitCodes]]
280+
command, # type: str | Iterable[str]
281+
timeout=1 * 60 * 60, # type: type: int | float | None
282+
expected=(0,), # type: Iterable[int | ExitCodes]
282283
raise_on_err=True, # type: bool
283284
# Keyword only:
284-
stdin=None, # type: Union[bytes, str, bytearray, None]
285+
stdin=None, # type: bytes | str | bytearray | None
285286
open_stdout=True, # type: bool
286287
open_stderr=True, # type: bool
287-
log_mask_re=None, # type: Optional[str]
288-
exception_class=ParallelCallProcessError # Type[ParallelCallProcessError]
288+
log_mask_re=None, # str | None
289+
exception_class=ParallelCallProcessError # type[ParallelCallProcessError]
289290
)
290-
results # type: Dict[Tuple[str, int], exec_result.ExecResult]
291+
results # type: dict[Tuple[str, int], exec_result.ExecResult]
291292
292293
Results is a dict with keys = (hostname, port) and and results in values.
293294
By default execute_together raises exception if unexpected return code on any remote.
@@ -306,18 +307,18 @@ For execute through SSH host can be used `execute_through_host` method:
306307
307308
result: ExecResult = client.execute_through_host(
308309
hostname, # type: str
309-
command, # type: Union[str, Iterable[str]]
310+
command, # type: str | Iterable[str]
310311
# Keyword only:
311-
auth=None, # type: Optional[SSHAuth]
312+
auth=None, # type: SSHAuth | None
312313
port=22, # type: int
313-
timeout=1 * 60 * 60, # type: type: Union[int, float, None]
314+
timeout=1 * 60 * 60, # type: type: int | float | None
314315
verbose=False, # type: bool
315-
stdin=None, # type: Union[bytes, str, bytearray, None]
316+
stdin=None, # type: bytes | str | bytearray | None
316317
open_stdout=True, # type: bool
317318
log_stdout=True, # type: bool
318319
open_stderr=True, # type: bool
319320
log_stderr=True, # type: bool
320-
log_mask_re=None, # type: Optional[str]
321+
log_mask_re=None, # str | None
321322
get_pty=False, # type: bool
322323
width=80, # type: int
323324
height=24 # type: int
@@ -416,9 +417,9 @@ Example:
416417
417418
async with helper:
418419
result: ExecResult = await helper.execute(
419-
command, # type: Union[str, Iterable[str]]
420+
command, # type: str | Iterable[str]
420421
verbose=False, # type: bool
421-
timeout=1 * 60 * 60, # type: Union[int, float, None]
422+
timeout=1 * 60 * 60, # type: int | float | None
422423
**kwargs
423424
)
424425

doc/source/ExecResult.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ API: ExecResult
1515
:param cmd: command
1616
:type cmd: ``str``
1717
:param stdin: STDIN
18-
:type stdin: ``Union[bytes, str, bytearray, None]``
18+
:type stdin: ``bytes | str | bytearray | None``
1919
:param stdout: binary STDOUT
20-
:type stdout: ``Optional[Iterable[bytes]]``
20+
:type stdout: ``Iterable[bytes] | None``
2121
:param stderr: binary STDERR
22-
:type stderr: ``Optional[Iterable[bytes]]``
22+
:type stderr: ``Iterable[bytes] | None``
2323
:param exit_code: Exit code. If integer - try to convert to BASH enum.
24-
:type exit_code: Union[int, ExitCodes]
24+
:type exit_code: int | ExitCodes
2525
:param started: Timestamp of command start
26-
:type started: ``Optional[datetime.datetime]``
26+
:type started: ``datetime.datetime | None``
2727

2828
.. py:attribute:: stdout_lock
2929
@@ -41,7 +41,7 @@ API: ExecResult
4141

4242
.. py:attribute:: timestamp
4343
44-
``Optional(datetime.datetime)``
44+
``datetime.datetime | None``
4545
Timestamp
4646

4747
.. py:method:: set_timestamp()
@@ -59,17 +59,17 @@ API: ExecResult
5959

6060
.. py:attribute:: stdin
6161
62-
``Optional[str]``
62+
``str | None``
6363
Stdin input as string.
6464

6565
.. py:attribute:: stdout
6666
67-
``Tuple[bytes, ...]``
67+
``tuple[bytes, ...]``
6868
Stdout output as list of binaries.
6969

7070
.. py:attribute:: stderr
7171
72-
``Tuple[bytes, ...]``
72+
``tuple[bytes, ...]``
7373
Stderr output as list of binaries.
7474

7575
.. py:attribute:: stdout_bin
@@ -124,7 +124,7 @@ API: ExecResult
124124
125125
Return(exit) code of command.
126126

127-
:rtype: Union[int, ExitCodes]
127+
:rtype: int | ExitCodes
128128

129129
.. py:attribute:: started
130130
@@ -171,9 +171,9 @@ API: ExecResult
171171
Read stdout file-like object to stdout.
172172

173173
:param src: source
174-
:type src: ``Optional[Iterable]``
174+
:type src: ``Iterable[bytes] | None``
175175
:param log: logger
176-
:type log: ``Optional[logging.Logger]``
176+
:type log: ``logging.Logger | None``
177177
:param verbose: use log.info instead of log.debug
178178
:type verbose: ``bool``
179179

@@ -184,9 +184,9 @@ API: ExecResult
184184
Read stderr file-like object to stderr.
185185

186186
:param src: source
187-
:type src: ``Optional[Iterable]``
187+
:type src: ``Iterable[bytes] | None``
188188
:param log: logger
189-
:type log: ``Optional[logging.Logger]``
189+
:type log: ``logging.Logger | None``
190190
:param verbose: use log.info instead of log.debug
191191
:type verbose: ``bool``
192192

@@ -209,7 +209,7 @@ API: ExecResult
209209
Access magic.
210210

211211
:param item: index
212-
:type item: ``Union[int, slice, Iterable[Union[int, slice, ellipsis]]]``
212+
:type item: ``int | slice | Iterable[int | slice | ellipsis]``
213213
:return: Joined selected lines
214214
:rtype: ``str``
215215
:raises TypeError: Unexpected key

0 commit comments

Comments
 (0)