Skip to content

Commit d07573b

Browse files
julienldGemini Code Assist
andcommitted
refactor: simplify nested ternary in ha_set_integration_enabled
Replace nested ternary expression with standard if/else block for better readability and maintainability. Addresses Gemini Code Assist review comment. Co-authored-by: Gemini Code Assist <noreply@google.com>
1 parent 624e7bf commit d07573b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/ha_mcp/tools/tools_integrations.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,17 @@ async def ha_set_integration_enabled(
173173
# Get updated entry info
174174
require_restart = result.get("result", {}).get("require_restart", False)
175175

176+
if require_restart:
177+
note = "Home Assistant restart required for changes to take effect."
178+
else:
179+
note = "Integration has been loaded." if enabled_bool else "Integration has been unloaded."
180+
176181
return {
177182
"success": True,
178183
"message": f"Integration {'enabled' if enabled_bool else 'disabled'} successfully",
179184
"entry_id": entry_id,
180185
"require_restart": require_restart,
181-
"note": (
182-
"Integration has been loaded."
183-
if enabled_bool and not require_restart
184-
else "Integration has been unloaded."
185-
if not enabled_bool and not require_restart
186-
else "Home Assistant restart required for changes to take effect."
187-
),
186+
"note": note,
188187
}
189188

190189
except Exception as e:

0 commit comments

Comments
 (0)