Skip to content

Commit 5425111

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

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/pre_commit_terraform/terraform_docs_replace.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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',
@@ -50,9 +56,10 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
5056
)
5157

5258
dirs: list[str] = []
53-
for filename in cast_to(list[str], parsed_cli_args.filenames):
54-
if (os.path.realpath(filename) not in dirs and
55-
(filename.endswith(".tf") or filename.endswith(".tfvars"))):
59+
for filename in cast_to('list[str]', parsed_cli_args.filenames):
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
@@ -61,16 +68,15 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
6168
try:
6269
procArgs = []
6370
procArgs.append('terraform-docs')
64-
if cast_to(bool, parsed_cli_args.sort):
71+
if cast_to('bool', parsed_cli_args.sort):
6572
procArgs.append('--sort-by-required')
6673
procArgs.append('md')
67-
procArgs.append("./{dir}".format(dir=dir))
74+
procArgs.append(f'./{dir}')
6875
procArgs.append('>')
6976
procArgs.append(
70-
'./{dir}/{dest}'.
71-
format(dir=dir, dest=cast_to(bool, parsed_cli_args.dest)),
77+
f'./{dir}/{cast_to('bool', 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)