Skip to content

Commit 4f76e8b

Browse files
olehermanseclaude
andcommitted
Fixed issues which came after merge
Other PRs were merged to master, and so there are test failures / linting errors I had to fix now. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
1 parent ea63867 commit 4f76e8b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/cfengine_cli/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def deploy() -> int:
5050
return r
5151

5252

53-
def _format_filename(filename, line_length, check):
53+
def _format_filename(filename: str, line_length: int, check: bool) -> int:
5454
if filename.startswith("./."):
5555
return 0
5656
if filename.endswith(".json"):
@@ -60,7 +60,7 @@ def _format_filename(filename, line_length, check):
6060
raise UserError(f"Unrecognized file format: {filename}")
6161

6262

63-
def _format_dirname(directory, line_length, check):
63+
def _format_dirname(directory: str, line_length: int, check: bool) -> int:
6464
ret = 0
6565
for filename in find(directory, extension=".json"):
6666
ret |= _format_filename(filename, line_length, check)

src/cfengine_cli/format.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@
2828
PROMISER_PARTS = {"promiser", "->", "stakeholder"}
2929

3030

31-
def format_json_file(filename: str, check: bool) -> None:
31+
def format_json_file(filename: str, check: bool) -> int:
3232
"""Reformat a JSON file in place using cfbs pretty-printer."""
3333
assert filename.endswith(".json")
3434

3535
if check:
3636
r = not pretty_check_file(filename)
3737
if r:
3838
print(f"JSON file '{filename}' needs reformatting")
39-
return r
39+
return int(r)
4040

4141
r = pretty_file(filename)
4242
if r:
4343
print(f"JSON file '{filename}' was reformatted")
44-
return r
44+
return int(r)
4545

4646

4747
def text(node: Node) -> str:
@@ -654,7 +654,7 @@ def autoformat(
654654
# ---------------------------------------------------------------------------
655655

656656

657-
def format_policy_file(filename: str, line_length: int, check: bool) -> None:
657+
def format_policy_file(filename: str, line_length: int, check: bool) -> int:
658658
"""Format a .cf policy file in place, writing only if content changed."""
659659
assert filename.endswith(".cf")
660660

@@ -685,7 +685,7 @@ def format_policy_file(filename: str, line_length: int, check: bool) -> None:
685685

686686
def format_policy_fin_fout(
687687
fin: IO[str], fout: IO[str], line_length: int, check: bool
688-
) -> None:
688+
) -> int:
689689
"""Format CFEngine policy read from fin, writing the result to fout."""
690690
PY_LANGUAGE = Language(tscfengine.language())
691691
parser = Parser(PY_LANGUAGE)

tests/unit/test_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _format(code: str, line_length: int = 80) -> str:
8282
"""Format CFEngine source via format_policy_fin_fout and return the result."""
8383
fin = io.StringIO(code)
8484
fout = io.StringIO()
85-
format_policy_fin_fout(fin, fout, line_length)
85+
format_policy_fin_fout(fin, fout, line_length, False)
8686
return fout.getvalue()
8787

8888

0 commit comments

Comments
 (0)