fix(tools): remove duplicate datetime import in get_weather handler

The local `from datetime import datetime, timezone as _tz` inside
execute_tool() shadowed the module-level datetime import for the entire
function scope, causing UnboundLocalError in all calendar tool handlers
(list_events, create_event, update_event). Fixed by importing only
timezone as _tz — datetime is already available at module level.

Also removes the now-unnecessary noqa: F823 suppression.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-25 14:59:05 -04:00
parent 0277f5744f
commit df1194ee96
+2 -2
View File
@@ -1238,7 +1238,7 @@ async def execute_tool(user_id: int, tool_name: str, arguments: dict) -> dict:
all_day = True
start_str = f"{start_str}T00:00:00"
try:
start_dt = datetime.fromisoformat(start_str) # noqa: F823 (false positive — datetime is imported at module level)
start_dt = datetime.fromisoformat(start_str)
except (ValueError, TypeError):
return {"success": False, "error": f"Invalid start datetime: {start_str!r}"}
end_dt = None
@@ -1705,7 +1705,7 @@ async def execute_tool(user_id: int, tool_name: str, arguments: dict) -> dict:
from fabledassistant.services.weather import (
get_cached_weather, geocode, _fetch_open_meteo, parse_forecast
)
from datetime import datetime, timezone as _tz
from datetime import timezone as _tz
location = (arguments.get("location") or "").strip()
_known = {"home", "work", "all", ""}
if location.lower() not in _known: