Skip to content

Commit 194cdbc

Browse files
author
Sergey
committed
fixup: ruff format + address Gemini review comments
- ruff format all changed files (CI enforces ruff format --check) - _process_menu_flow_result: str | None type hint for intro_flow_id - _process_menu_flow_result: narrow except to (HomeAssistantAPIError, TimeoutError) - fetch_helper_flow_info: remove `and intro_flow_id` guard from MENU branch (restores menu_options surfacing when intro_flow_id is absent) - _try_raw_cdn: narrow except to httpx.RequestError - test_tools_updates: use httpx.ConnectError in exception-continue test
1 parent de3847c commit 194cdbc

9 files changed

Lines changed: 388 additions & 254 deletions

src/ha_mcp/tools/best_practice_checker.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,7 @@ def _check_template_string(
279279
# reframes #695 from "enumerate bad shapes" to "surface every template
280280
# in a logic position". Specific detectors above keep their tailored
281281
# messages.
282-
if (
283-
len(warnings) == initial_count
284-
and _RE_ANY_TEMPLATE.search(template)
285-
):
282+
if len(warnings) == initial_count and _RE_ANY_TEMPLATE.search(template):
286283
warnings.append(
287284
f"Template detected in {position} — if this maps to a native option "
288285
"(`numeric_state`, `state`, `time`, `sun`, `zone`, `device`), use that "
@@ -304,9 +301,7 @@ def _check_choose_actions(
304301
_check_condition_templates(
305302
option.get("conditions", []), warnings, skill_prefix
306303
)
307-
_check_action_tree(
308-
option.get("sequence", []), warnings, skill_prefix
309-
)
304+
_check_action_tree(option.get("sequence", []), warnings, skill_prefix)
310305

311306

312307
def _check_repeat_actions(
@@ -445,15 +440,19 @@ def _check_target_dict(
445440
f"hardcode the literal value instead. The self-reference is always "
446441
f"resolvable at write time, so the template adds runtime cost without "
447442
f"any flexibility."
448-
+ _ref(skill_prefix, "template-guidelines.md#when-to-avoid-templates")
443+
+ _ref(
444+
skill_prefix, "template-guidelines.md#when-to-avoid-templates"
445+
)
449446
)
450447
else:
451448
warnings.append(
452449
f"Action `target.{field}` uses a template — prefer a hardcoded literal, "
453450
f"or use a `choose` action with native conditions to dispatch to different "
454451
f"hardcoded targets. Templates in target fields fail silently if they "
455452
f"resolve to a non-existent entity."
456-
+ _ref(skill_prefix, "template-guidelines.md#when-to-avoid-templates")
453+
+ _ref(
454+
skill_prefix, "template-guidelines.md#when-to-avoid-templates"
455+
)
457456
)
458457

459458

src/ha_mcp/tools/tools_bug_report.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -423,17 +423,21 @@ def _build_formatted_report(
423423
for key, value in config_toggles.items():
424424
report_lines.append(f" {key}: {value}")
425425
if startup_logs:
426-
report_lines.extend([
427-
"",
428-
f"=== Startup Logs ({len(startup_logs)} entries) ===",
429-
startup_log_summary,
430-
])
426+
report_lines.extend(
427+
[
428+
"",
429+
f"=== Startup Logs ({len(startup_logs)} entries) ===",
430+
startup_log_summary,
431+
]
432+
)
431433
if recent_logs:
432-
report_lines.extend([
433-
"",
434-
f"=== Recent Tool Calls ({len(recent_logs)} entries) ===",
435-
log_summary,
436-
])
434+
report_lines.extend(
435+
[
436+
"",
437+
f"=== Recent Tool Calls ({len(recent_logs)} entries) ===",
438+
log_summary,
439+
]
440+
)
437441
if addon_logs:
438442
report_lines.extend(["", "=== Add-on Container Logs ===", addon_logs])
439443
return "\n".join(report_lines)

0 commit comments

Comments
 (0)