Skip to content

Commit 2798860

Browse files
committed
add pre-commit & fix new static test failures
1 parent 3e0adfa commit 2798860

19 files changed

+369
-311
lines changed

.pre-commit-config.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.0.1
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- id: mixed-line-ending
9+
10+
- repo: https://github.com/pycqa/isort
11+
rev: 5.9.3
12+
hooks:
13+
- id: isort
14+
name: isort (python)
15+
- id: isort
16+
name: isort (cython)
17+
types: [cython]
18+
- id: isort
19+
name: isort (pyi)
20+
types: [pyi]
21+
22+
- repo: https://github.com/psf/black
23+
rev: 21.10b0
24+
hooks:
25+
- id: black
26+
# It is recommended to specify the latest version of Python
27+
# supported by your project here, or alternatively use
28+
# pre-commit's default_language_version, see
29+
# https://pre-commit.com/#top_level-default_language_version
30+
language_version: python3.7
31+
always_run: true
32+
33+
- repo: https://github.com/pre-commit/pygrep-hooks
34+
rev: v1.9.0 # Use the ref you want to point at
35+
hooks:
36+
- id: python-check-blanket-noqa
37+
- id: python-check-blanket-type-ignore
38+
- id: rst-directive-colons
39+
- id: rst-inline-touching-normal
40+
41+
- repo: https://gitlab.com/pycqa/flake8
42+
rev: 3.9.2
43+
hooks:
44+
- id: flake8
45+
additional_dependencies: [flake8-bugbear, pep8-naming, flake8-docstrings]
46+
exclude: test

exec_helpers/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
"ParallelCallExceptions",
5757
)
5858

59-
__locals: typing.Dict[str, typing.Any] = locals() # use mutable access for pure lazy loading
59+
__locals: dict[str, typing.Any] = locals() # use mutable access for pure lazy loading
6060

6161
__lazy_load_modules: typing.Sequence[str] = (
6262
"async_api",
6363
"exceptions",
6464
"exec_result",
6565
)
6666

67-
__lazy_load_parent_modules: typing.Dict[str, str] = {
67+
__lazy_load_parent_modules: dict[str, str] = {
6868
"HostsSSHConfigs": "_ssh_helpers",
6969
"SSHConfig": "_ssh_helpers",
7070
"SSHClient": "ssh",
@@ -86,7 +86,7 @@
8686
"ParallelCallExceptions": "exceptions",
8787
}
8888

89-
_deprecated: typing.Dict[str, str] = {"ParallelCallExceptions": "ParallelCallExceptionsError"}
89+
_deprecated: dict[str, str] = {"ParallelCallExceptions": "ParallelCallExceptionsError"}
9090

9191

9292
def __getattr__(name: str) -> typing.Any:

exec_helpers/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ __all__ = (
7373
"ParallelCallExceptions",
7474
)
7575

76-
_deprecated: typing.Dict[str, str] = ...
76+
_deprecated: dict[str, str] = ...
7777

7878
def __getattr__(name: str) -> typing.Any:
7979
"""Get attributes lazy.
@@ -84,7 +84,7 @@ def __getattr__(name: str) -> typing.Any:
8484

8585
__author__: str = ...
8686
__author_email__: str = ...
87-
__maintainers__: typing.Dict[str, str] = ...
87+
__maintainers__: dict[str, str] = ...
8888
__url__: str = ...
8989
__description__: str = ...
9090
__license__: str = ...

exec_helpers/_helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import typing
1010

1111

12-
def string_bytes_bytearray_as_bytes(src: typing.Union[str, bytes, bytearray]) -> bytes:
12+
def string_bytes_bytearray_as_bytes(src: str | bytes | bytearray) -> bytes:
1313
"""Get bytes string from string/bytes/bytearray union.
1414
1515
:param src: source string or bytes-like object
@@ -36,7 +36,7 @@ def _mask_command(text: str, rules: str) -> str:
3636
:return: source with all MATCHED groups replaced by '<*masked*>'
3737
:rtype: str
3838
"""
39-
masked: typing.List[str] = []
39+
masked: list[str] = []
4040

4141
# places to exclude
4242
prev = 0
@@ -51,7 +51,7 @@ def _mask_command(text: str, rules: str) -> str:
5151
return "".join(masked)
5252

5353

54-
def mask_command(text: str, *rules: typing.Optional[str]) -> str:
54+
def mask_command(text: str, *rules: str | None) -> str:
5555
"""Apply all rules to command.
5656
5757
:param text: source text
@@ -64,7 +64,7 @@ def mask_command(text: str, *rules: typing.Optional[str]) -> str:
6464
return functools.reduce(_mask_command, (rule for rule in rules if rule is not None), text)
6565

6666

67-
def cmd_to_string(command: typing.Union[str, typing.Iterable[str]]) -> str:
67+
def cmd_to_string(command: str | typing.Iterable[str]) -> str:
6868
"""Convert command to string for usage with shell.
6969
7070
:param command: original command.
@@ -77,7 +77,7 @@ def cmd_to_string(command: typing.Union[str, typing.Iterable[str]]) -> str:
7777
return " ".join(shlex.quote(elem) for elem in command)
7878

7979

80-
def chroot_command(command: str, chroot_path: typing.Optional[str] = None) -> str:
80+
def chroot_command(command: str, chroot_path: str | None = None) -> str:
8181
"""Prepare command for chroot execution.
8282
8383
:param command: original command.

0 commit comments

Comments
 (0)