Skip to content

Commit 49f5087

Browse files
authored
Merge branch 'master' into introduce_ruff
2 parents 460031a + 8d38688 commit 49f5087

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/pre_commit_terraform/_cli_parsing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def initialize_argument_parser() -> ArgumentParser:
3636
3737
Returns:
3838
ArgumentParser: The root parser with sub-commands attached.
39-
4039
"""
4140
root_cli_parser = ArgumentParser(prog=f'python -m {__package__ !s}')
4241
attach_subcommand_parsers_to(root_cli_parser)

src/pre_commit_terraform/terraform_docs_replace.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
def populate_argument_parser(subcommand_parser: ArgumentParser) -> None:
15+
"""Populate the parser for the subcommand."""
1516
subcommand_parser.description = (
1617
'Run terraform-docs on a set of files. Follows the standard '
1718
'convention of pulling the documentation from main.tf in order to '
@@ -47,13 +48,19 @@ def populate_argument_parser(subcommand_parser: ArgumentParser) -> None:
4748

4849

4950
def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
51+
"""Run the entry-point of the CLI app.
52+
53+
Returns:
54+
ReturnCodeType: The return code of the app.
55+
"""
5056
warnings.warn(
5157
'`terraform_docs_replace` hook is DEPRECATED.'
5258
'For migration instructions see '
5359
'https://github.com/antonbabenko/pre-commit-terraform/issues/248'
5460
'#issuecomment-1290829226',
5561
category=UserWarning,
56-
stacklevel=1, # It's should be 2, but tests are failing w/ values >1. As it's deprecated hook, it's safe to leave it as is w/o fixing it later.
62+
stacklevel=1, # It's should be 2, but tests are failing w/ values >1.
63+
# As it's deprecated hook, it's safe to leave it as is w/o fixing it.
5764
)
5865

5966
dirs: list[str] = []
@@ -65,24 +72,24 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
6572

6673
retval = ReturnCode.OK
6774

68-
for dir in dirs:
75+
for directory in dirs:
6976
try:
70-
procArgs = []
71-
procArgs.append('terraform-docs')
77+
proc_args = []
78+
proc_args.append('terraform-docs')
7279
if cast_to('bool', parsed_cli_args.sort):
73-
procArgs.append('--sort-by-required')
74-
procArgs.extend(
80+
proc_args.append('--sort-by-required')
81+
proc_args.extend(
7582
(
7683
'md',
77-
f'./{dir}',
84+
f'./{directory}',
7885
'>',
7986
'./{dir}/{dest}'.format(
80-
dir=dir,
87+
dir=directory,
8188
dest=cast_to('str', parsed_cli_args.dest),
8289
),
8390
),
8491
)
85-
subprocess.check_call(' '.join(procArgs), shell=True)
92+
subprocess.check_call(' '.join(proc_args), shell=True)
8693
except subprocess.CalledProcessError as e:
8794
print(e)
8895
retval = ReturnCode.ERROR

0 commit comments

Comments
 (0)