Skip to content

Commit bc89992

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1bedda1 commit bc89992

6 files changed

Lines changed: 33 additions & 28 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""A runpy-style CLI entry-point module."""
22

3-
from sys import argv, exit as exit_with_return_code
3+
from sys import argv
4+
from sys import exit as exit_with_return_code
45

56
from ._cli import invoke_cli_app
67

7-
88
return_code = invoke_cli_app(argv[1:])
99
exit_with_return_code(return_code)

src/pre_commit_terraform/_cli.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
from sys import stderr
44

55
from ._cli_parsing import initialize_argument_parser
6-
from ._errors import (
7-
PreCommitTerraformBaseError,
8-
PreCommitTerraformExit,
9-
PreCommitTerraformRuntimeError,
10-
)
6+
from ._errors import PreCommitTerraformBaseError
7+
from ._errors import PreCommitTerraformExit
8+
from ._errors import PreCommitTerraformRuntimeError
119
from ._structs import ReturnCode
1210
from ._types import ReturnCodeType
1311

@@ -28,8 +26,7 @@ def invoke_cli_app(cli_args: list[str]) -> ReturnCodeType:
2826
raise
2927
except PreCommitTerraformRuntimeError as unhandled_exc:
3028
print(
31-
f'App execution took an unexpected turn: {unhandled_exc !s}. '
32-
'Exiting...',
29+
f'App execution took an unexpected turn: {unhandled_exc !s}. ' 'Exiting...',
3330
file=stderr,
3431
)
3532
return ReturnCode.ERROR

src/pre_commit_terraform/_cli_subcommands.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from . import terraform_docs_replace
44
from ._types import CLISubcommandModuleProtocol
55

6-
76
SUBCOMMAND_MODULES: list[CLISubcommandModuleProtocol] = [
87
terraform_docs_replace,
98
]

src/pre_commit_terraform/_errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class PreCommitTerraformBaseError(Exception):
66

77

88
class PreCommitTerraformRuntimeError(
9-
PreCommitTerraformBaseError,
10-
RuntimeError,
9+
PreCommitTerraformBaseError,
10+
RuntimeError,
1111
):
1212
"""An exception representing a runtime error condition."""
1313

src/pre_commit_terraform/_types.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""Composite types for annotating in-project code."""
22

3-
from argparse import ArgumentParser, Namespace
4-
from typing import Final, Protocol
3+
from argparse import ArgumentParser
4+
from argparse import Namespace
5+
from typing import Final
6+
from typing import Protocol
57

68
from ._structs import ReturnCode
79

8-
910
ReturnCodeType = ReturnCode | int
1011

1112

@@ -16,12 +17,14 @@ class CLISubcommandModuleProtocol(Protocol):
1617
"""This constant contains a CLI."""
1718

1819
def populate_argument_parser(
19-
self, subcommand_parser: ArgumentParser,
20+
self,
21+
subcommand_parser: ArgumentParser,
2022
) -> None:
2123
"""Run a module hook for populating the subcommand parser."""
2224

2325
def invoke_cli_app(
24-
self, parsed_cli_args: Namespace,
26+
self,
27+
parsed_cli_args: Namespace,
2528
) -> ReturnCodeType | int:
2629
"""Run a module hook implementing the subcommand logic."""
2730
... # pylint: disable=unnecessary-ellipsis

src/pre_commit_terraform/terraform_docs_replace.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import os
22
import subprocess
33
import warnings
4-
from argparse import ArgumentParser, Namespace
4+
from argparse import ArgumentParser
5+
from argparse import Namespace
56
from typing import Final
67

78
from ._structs import ReturnCode
89
from ._types import ReturnCodeType
910

10-
1111
CLI_SUBCOMMAND_NAME: Final[str] = 'replace-docs'
1212

1313

@@ -18,14 +18,20 @@ def populate_argument_parser(subcommand_parser: ArgumentParser) -> None:
1818
'replace the entire README.md file each time.'
1919
)
2020
subcommand_parser.add_argument(
21-
'--dest', dest='dest', default='README.md',
21+
'--dest',
22+
dest='dest',
23+
default='README.md',
2224
)
2325
subcommand_parser.add_argument(
24-
'--sort-inputs-by-required', dest='sort', action='store_true',
26+
'--sort-inputs-by-required',
27+
dest='sort',
28+
action='store_true',
2529
help='[deprecated] use --sort-by-required instead',
2630
)
2731
subcommand_parser.add_argument(
28-
'--sort-by-required', dest='sort', action='store_true',
32+
'--sort-by-required',
33+
dest='sort',
34+
action='store_true',
2935
)
3036
subcommand_parser.add_argument(
3137
'--with-aggregate-type-defaults',
@@ -51,8 +57,9 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
5157

5258
dirs = []
5359
for filename in parsed_cli_args.filenames:
54-
if (os.path.realpath(filename) not in dirs and
55-
(filename.endswith(".tf") or filename.endswith(".tfvars"))):
60+
if os.path.realpath(filename) not in dirs and (
61+
filename.endswith('.tf') or filename.endswith('.tfvars')
62+
):
5663
dirs.append(os.path.dirname(filename))
5764

5865
retval = ReturnCode.OK
@@ -64,13 +71,12 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
6471
if parsed_cli_args.sort:
6572
procArgs.append('--sort-by-required')
6673
procArgs.append('md')
67-
procArgs.append("./{dir}".format(dir=dir))
74+
procArgs.append('./{dir}'.format(dir=dir))
6875
procArgs.append('>')
6976
procArgs.append(
70-
'./{dir}/{dest}'.
71-
format(dir=dir, dest=parsed_cli_args.dest),
77+
'./{dir}/{dest}'.format(dir=dir, dest=parsed_cli_args.dest),
7278
)
73-
subprocess.check_call(" ".join(procArgs), shell=True)
79+
subprocess.check_call(' '.join(procArgs), shell=True)
7480
except subprocess.CalledProcessError as e:
7581
print(e)
7682
retval = ReturnCode.ERROR

0 commit comments

Comments
 (0)