Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ convention = "pep257"
[lint]
select = ["ALL"]
preview = true
external = ["WPS"] # Do not remove noqa for wemake-python-style (WPS) checks
ignore = [
"CPY001", # Skip copyright notice requirement at top of files
]
Expand Down
21 changes: 21 additions & 0 deletions setup.cfg
Comment thread
MaxymVlasov marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Configuration of wemake-python-styleguide
# Docs: https://wemake-python-styleguide.readthedocs.io
#
[flake8]

# Ruff set to 79, but we have some noqa comments which are a bit longer, and wemake does not forgive that
max-line-length = 88
# Suppress WPS410 warning
allowed-module-metadata=__all__

ignore =
# Allow relative imports to the current folder.
WPS300,


per-file-ignores =
# Tests contain similar string literals
tests/pytest/_cli_test.py: WPS226
# We will not spend time on fixing coplexity in depprecated hook
src/pre_commit_terraform/terraform_docs_replace.py: WPS232
14 changes: 7 additions & 7 deletions src/pre_commit_terraform/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ def invoke_cli_app(cli_args: list[str]) -> ReturnCodeType:
parsed_cli_args.invoke_cli_app,
)

try:
try: # noqa: WPS225 - too many `except` cases
return invoke_cli_app(parsed_cli_args)
except PreCommitTerraformExit as exit_err:
# T201 - FIXME here and below - we will replace 'print' with
# logging later
print(f'App exiting: {exit_err!s}', file=sys.stderr) # noqa: T201
# T201,WPS421 - FIXME here and below - we will replace 'print'
# with logging later
print(f'App exiting: {exit_err!s}', file=sys.stderr) # noqa: T201,WPS421
raise
except PreCommitTerraformRuntimeError as unhandled_exc:
print( # noqa: T201
print( # noqa: T201,WPS421
f'App execution took an unexpected turn: {unhandled_exc!s}. '
'Exiting...',
file=sys.stderr,
)
return ReturnCode.ERROR
except PreCommitTerraformBaseError as unhandled_exc:
print( # noqa: T201
print( # noqa: T201,WPS421
f'A surprising exception happened: {unhandled_exc!s}. Exiting...',
file=sys.stderr,
)
return ReturnCode.ERROR
except KeyboardInterrupt as ctrl_c_exc:
print( # noqa: T201
print( # noqa: T201,WPS421
f'User-initiated interrupt: {ctrl_c_exc!s}. Exiting...',
file=sys.stderr,
)
Expand Down
8 changes: 4 additions & 4 deletions src/pre_commit_terraform/terraform_docs_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def populate_argument_parser(subcommand_parser: ArgumentParser) -> None:
)


def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType: # noqa: WPS231
Comment thread
MaxymVlasov marked this conversation as resolved.
"""Run the entry-point of the CLI app.

Returns:
Expand Down Expand Up @@ -86,7 +86,7 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
retval = ReturnCode.OK

for directory in dirs:
try:
try: # noqa: WPS229 - ignore as it's deprecated hook
proc_args = []
proc_args.append('terraform-docs')
if cast_to('bool', parsed_cli_args.sort):
Expand All @@ -107,8 +107,8 @@ def invoke_cli_app(parsed_cli_args: Namespace) -> ReturnCodeType:
subprocess.check_call(' '.join(proc_args), shell=True) # noqa: S602
# PERF203 - try-except shouldn't be in a loop, but it's deprecated
# hook, so leave as is
except subprocess.CalledProcessError as e: # noqa: PERF203
except subprocess.CalledProcessError as e: # noqa: PERF203,WPS111
# T201 - Leave print statement as is, as this is deprecated hook
print(e) # noqa: T201
print(e) # noqa: T201,WPS421
retval = ReturnCode.ERROR
return retval