Skip to content

Commit 8831b60

Browse files
committed
decrease diff
1 parent 53bb73f commit 8831b60

File tree

6 files changed

+40
-27
lines changed

6 files changed

+40
-27
lines changed

ruff.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Assume Python 3.9
22
target-version = "py39"
33

4+
line-length = 79 # To decrease PR diff size
5+
46
[format]
57
quote-style = "single"
68

@@ -19,7 +21,7 @@ ignore = [
1921
]
2022

2123
[lint.isort]
22-
force-single-line = true
24+
# force-single-line = true # To decrease PR diff size
2325
lines-after-imports = 2
2426

2527
[lint.flake8-pytest-style]

src/pre_commit_terraform/_cli.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
from typing import cast as cast_to
55

66
from ._cli_parsing import initialize_argument_parser
7-
from ._errors import PreCommitTerraformBaseError
8-
from ._errors import PreCommitTerraformExit
9-
from ._errors import PreCommitTerraformRuntimeError
7+
from ._errors import (
8+
PreCommitTerraformBaseError,
9+
PreCommitTerraformExit,
10+
PreCommitTerraformRuntimeError,
11+
)
1012
from ._structs import ReturnCode
11-
from ._types import CLIAppEntryPointCallableType
12-
from ._types import ReturnCodeType
13+
from ._types import CLIAppEntryPointCallableType, ReturnCodeType
1314

1415

1516
def invoke_cli_app(cli_args: list[str]) -> ReturnCodeType:
@@ -37,7 +38,8 @@ def invoke_cli_app(cli_args: list[str]) -> ReturnCodeType:
3738
raise
3839
except PreCommitTerraformRuntimeError as unhandled_exc:
3940
print( # noqa: T201 FIXME
40-
f'App execution took an unexpected turn: {unhandled_exc !s}. Exiting...',
41+
f'App execution took an unexpected turn: {unhandled_exc !s}.'
42+
'Exiting...',
4143
file=sys.stderr,
4244
)
4345
return ReturnCode.ERROR

src/pre_commit_terraform/_types.py

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

3-
from argparse import ArgumentParser
4-
from argparse import Namespace
3+
from argparse import ArgumentParser, Namespace
54
from collections.abc import Callable
6-
from typing import Protocol
7-
from typing import Union
5+
from typing import Protocol, Union
86

97
from ._structs import ReturnCode
108

@@ -19,7 +17,10 @@ class CLISubcommandModuleProtocol(Protocol):
1917
CLI_SUBCOMMAND_NAME: str
2018
"""This constant contains a CLI."""
2119

22-
def populate_argument_parser(self, subcommand_parser: ArgumentParser) -> None:
20+
def populate_argument_parser(
21+
self,
22+
subcommand_parser: ArgumentParser,
23+
) -> None:
2324
"""Run a module hook for populating the subcommand parser."""
2425

2526
def invoke_cli_app(self, parsed_cli_args: Namespace) -> ReturnCodeType:

src/pre_commit_terraform/terraform_docs_replace.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import os
44
import subprocess # noqa: S404. We invoke cli tools
55
import warnings
6-
from argparse import ArgumentParser
7-
from argparse import Namespace
6+
from argparse import ArgumentParser, Namespace
87
from typing import cast as cast_to
98

109
from ._structs import ReturnCode

tests/pytest/_cli_test.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
"""Tests for the high-level CLI entry point."""
22

3-
from argparse import ArgumentParser
4-
from argparse import Namespace
3+
from argparse import ArgumentParser, Namespace
54

65
import pytest
76

87
from pre_commit_terraform import _cli_parsing as _cli_parsing_mod
98
from pre_commit_terraform._cli import invoke_cli_app
10-
from pre_commit_terraform._errors import PreCommitTerraformBaseError
11-
from pre_commit_terraform._errors import PreCommitTerraformExit
12-
from pre_commit_terraform._errors import PreCommitTerraformRuntimeError
9+
from pre_commit_terraform._errors import (
10+
PreCommitTerraformBaseError,
11+
PreCommitTerraformExit,
12+
PreCommitTerraformRuntimeError,
13+
)
1314
from pre_commit_terraform._structs import ReturnCode
1415
from pre_commit_terraform._types import ReturnCodeType
1516

@@ -52,7 +53,9 @@ class CustomCmdStub:
5253
CLI_SUBCOMMAND_NAME = 'sentinel'
5354

5455
@staticmethod
55-
def populate_argument_parser(subcommand_parser: ArgumentParser) -> None: # noqa: ARG004
56+
def populate_argument_parser(
57+
subcommand_parser: ArgumentParser, # noqa: ARG004
58+
) -> None:
5659
return None
5760

5861
@staticmethod
@@ -81,7 +84,9 @@ class CustomCmdStub:
8184
CLI_SUBCOMMAND_NAME = 'sentinel'
8285

8386
@staticmethod
84-
def populate_argument_parser(subcommand_parser: ArgumentParser) -> None: # noqa: ARG004
87+
def populate_argument_parser(
88+
subcommand_parser: ArgumentParser,
89+
) -> None:
8590
return None
8691

8792
@staticmethod

tests/pytest/terraform_docs_replace_test.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
"""Tests for the `replace-docs` subcommand."""
22

3-
from argparse import ArgumentParser
4-
from argparse import Namespace
3+
from argparse import ArgumentParser, Namespace
54
from subprocess import CalledProcessError # noqa: S404. We invoke cli tools
65

76
import pytest
87
import pytest_mock
98

109
from pre_commit_terraform._structs import ReturnCode
11-
from pre_commit_terraform.terraform_docs_replace import invoke_cli_app
12-
from pre_commit_terraform.terraform_docs_replace import populate_argument_parser
10+
from pre_commit_terraform.terraform_docs_replace import (
11+
invoke_cli_app,
12+
populate_argument_parser,
13+
)
1314
from pre_commit_terraform.terraform_docs_replace import (
1415
subprocess as replace_docs_subprocess_mod,
1516
)
@@ -53,7 +54,8 @@ def test_check_is_deprecated() -> None:
5354
),
5455
[
5556
'terraform-docs --sort-by-required md ./ > .//SENTINEL.md',
56-
'terraform-docs --sort-by-required md ./thing > ./thing/SENTINEL.md',
57+
'terraform-docs --sort-by-required md ./thing '
58+
'> ./thing/SENTINEL.md',
5759
],
5860
id='two-sorted-files',
5961
),
@@ -84,7 +86,9 @@ def test_control_flow_positive(
8486

8587
assert invoke_cli_app(parsed_cli_args) == ReturnCode.OK
8688

87-
executed_commands = [cmd for ((cmd,), _shell) in check_call_mock.call_args_list]
89+
executed_commands = [
90+
cmd for ((cmd,), _shell) in check_call_mock.call_args_list
91+
]
8892

8993
assert len(expected_cmds) == check_call_mock.call_count
9094
assert expected_cmds == executed_commands

0 commit comments

Comments
 (0)