Skip to content

Commit b128a3c

Browse files
authored
Merge pull request #8 from cfengine/formatting-action
Reformatted python code using Black formatter
2 parents 9262620 + 6f2bc80 commit b128a3c

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/cfengine_cli/docs.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,25 @@ def fn_extract(origin_path, snippet_path, _language, first_line, last_line):
109109
raise UserError(f"Couldn't open '{origin_path}' or '{snippet_path}'")
110110

111111

112-
def lint_json_file(snippet_abs_path, origin_path, snippet_number, first_line, prefix=None):
112+
def lint_json_file(
113+
snippet_abs_path, origin_path, snippet_number, first_line, prefix=None
114+
):
113115
with open(snippet_abs_path, "r") as f:
114116
json.loads(f.read())
115117
if prefix:
116118
print(prefix, end="")
117119
print(f"PASS: Snippet {snippet_number} at '{origin_path}:{first_line}' (json)")
118120
return 0
119121

122+
120123
def fn_check_syntax(
121-
origin_path, snippet_path, language, first_line, _last_line, snippet_number, prefix=None
124+
origin_path,
125+
snippet_path,
126+
language,
127+
first_line,
128+
_last_line,
129+
snippet_number,
130+
prefix=None,
122131
):
123132
snippet_abs_path = os.path.abspath(snippet_path)
124133

@@ -136,7 +145,9 @@ def fn_check_syntax(
136145
raise UserError(f"Error when checking '{origin_path}'")
137146
case "json":
138147
try:
139-
lint_json_file(snippet_abs_path, origin_path, snippet_number, first_line, prefix)
148+
lint_json_file(
149+
snippet_abs_path, origin_path, snippet_number, first_line, prefix
150+
)
140151
except json.decoder.JSONDecodeError as e:
141152
raise UserError(f"Error when checking '{snippet_abs_path}': {str(e)}")
142153
except Exception as e:
@@ -231,7 +242,7 @@ def _process_markdown_code_blocks(
231242
origin_paths_len = len(origin_paths)
232243

233244
for origin_paths_i, origin_path in enumerate(origin_paths):
234-
percentage = int(100 * (origin_paths_i + 1)/origin_paths_len)
245+
percentage = int(100 * (origin_paths_i + 1) / origin_paths_len)
235246
prefix = f"[{origin_paths_i + 1}/{origin_paths_len} ({percentage}%)] "
236247
offset = 0
237248
for i, code_block in enumerate(
@@ -269,7 +280,7 @@ def _process_markdown_code_blocks(
269280
code_block["first_line"],
270281
code_block["last_line"],
271282
snippet_number,
272-
prefix
283+
prefix,
273284
)
274285
except Exception as e:
275286
if cleanup:

src/cfengine_cli/lint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ def lint_policy_file(
156156
if errors == 0:
157157
if snippet:
158158
assert original_filename and original_line
159-
print(f"PASS: Snippet {snippet} at '{original_filename}:{original_line}' (cf3)")
159+
print(
160+
f"PASS: Snippet {snippet} at '{original_filename}:{original_line}' (cf3)"
161+
)
160162
else:
161163
print(f"PASS: {filename}")
162164
return 0

0 commit comments

Comments
 (0)