Skip to content

Commit fc99c51

Browse files
sergeykadSergey
andauthored
refactor(c901): tools_entities.py below C901 threshold (#1692)
* refactor(c901): tools_entities.py below C901 threshold - Convert closure pattern to EntityTools class; register_entity_tools becomes a 1-liner calling register_tool_methods(mcp, EntityTools(client)) - Extract 10 module-level pure helpers and 9 async class methods so all functions stay below McCabe complexity 10 - Remove "src/ha_mcp/tools/tools_entities.py" = ["C901"] exemption from pyproject.toml - Fix bulk categories bug: old code hardcoded None for categories in gather; new code passes parsed_categories matching docstring and validation - Fix updates_applied in Phase-4 error context: expose_to= and device_name entries are now appended after their WS phases run, not pre-appended - Unify _parse_aliases_param/_parse_labels_param into _parse_string_list_field - Flatten double-nested if in _validate_enabled_constraint - Update test fixtures from mcp.tool capture to mcp.add_tool capture - Add test_bulk_categories_set regression test * fix: address Gemini review on PR #1692 - Guard all result.get("result", {}) calls with `or {}` so a null "result" key from HA never produces an AttributeError on .get() - Change expose_to entity-entry fetch guard from has_registry_updates to `not entity_entry` — avoids redundant WS round-trip when options or device_rename already populated entity_entry --------- Co-authored-by: Sergey <sergey@example.com>
1 parent e74031e commit fc99c51

4 files changed

Lines changed: 883 additions & 700 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ ignore = [
150150
# C901 ignores for tools files with complex methods (see #925).
151151
# Remove lines as individual methods are simplified below threshold.
152152
"src/ha_mcp/tools/tools_config_dashboards.py" = ["C901"]
153-
"src/ha_mcp/tools/tools_entities.py" = ["C901"]
154153

155154
[tool.pytest.ini_options]
156155
testpaths = ["tests"]

0 commit comments

Comments
 (0)