Skip to content

Your lightweight open-source personal agent.

fix: add from __future__ import annotations across codebase

Tink6b3997c463df
diff --git a/nanobot/agent/context.py b/nanobot/agent/context.py
index 6a43d3e91..905562a98 100644
--- a/nanobot/agent/context.py
+++ b/nanobot/agent/context.py
@@ -1,5 +1,7 @@
"""Context builder for assembling agent prompts."""
+from __future__ import annotations
+
import base64
import mimetypes
import platform
diff --git a/nanobot/agent/subagent.py b/nanobot/agent/subagent.py
index f2d6ee5f2..20dbaede0 100644
--- a/nanobot/agent/subagent.py
+++ b/nanobot/agent/subagent.py
@@ -1,5 +1,7 @@
"""Subagent manager for background task execution."""
+from __future__ import annotations
+
import asyncio
import json
import uuid
diff --git a/nanobot/agent/tools/base.py b/nanobot/agent/tools/base.py
index 051fc9acf..ea5b66318 100644
--- a/nanobot/agent/tools/base.py
+++ b/nanobot/agent/tools/base.py
@@ -1,5 +1,7 @@
"""Base class for agent tools."""
+from __future__ import annotations
+
from abc import ABC, abstractmethod
from typing import Any
diff --git a/nanobot/agent/tools/cron.py b/nanobot/agent/tools/cron.py
index f8e737b39..350e261f8 100644
--- a/nanobot/agent/tools/cron.py
+++ b/nanobot/agent/tools/cron.py
@@ -1,5 +1,7 @@
"""Cron tool for scheduling reminders and tasks."""
+from __future__ import annotations
+
from contextvars import ContextVar
from typing import Any
diff --git a/nanobot/agent/tools/filesystem.py b/nanobot/agent/tools/filesystem.py
index 7b0b86725..c13464e69 100644
--- a/nanobot/agent/tools/filesystem.py
+++ b/nanobot/agent/tools/filesystem.py
@@ -1,5 +1,7 @@
"""File system tools: read, write, edit."""
+from __future__ import annotations
+
import difflib
from pathlib import Path
from typing import Any
diff --git a/nanobot/agent/tools/mcp.py b/nanobot/agent/tools/mcp.py
index 2cbffd09d..dd6ce8c52 100644
--- a/nanobot/agent/tools/mcp.py
+++ b/nanobot/agent/tools/mcp.py
@@ -1,5 +1,7 @@
"""MCP client: connects to MCP servers and wraps their tools as native nanobot tools."""
+from __future__ import annotations
+
import asyncio
from contextlib import AsyncExitStack
from typing import Any
diff --git a/nanobot/agent/tools/message.py b/nanobot/agent/tools/message.py
index 35e519a00..9d7cfbdca 100644
--- a/nanobot/agent/tools/message.py
+++ b/nanobot/agent/tools/message.py
@@ -1,5 +1,7 @@
"""Message tool for sending messages to users."""
+from __future__ import annotations
+
from typing import Any, Awaitable, Callable
from nanobot.agent.tools.base import Tool
diff --git a/nanobot/agent/tools/registry.py b/nanobot/agent/tools/registry.py
index 5d36e52cd..6edb88e16 100644
--- a/nanobot/agent/tools/registry.py
+++ b/nanobot/agent/tools/registry.py
@@ -1,5 +1,7 @@
"""Tool registry for dynamic tool management."""
+from __future__ import annotations
+
from typing import Any
from nanobot.agent.tools.base import Tool
diff --git a/nanobot/agent/tools/shell.py b/nanobot/agent/tools/shell.py
index ce1992092..74d1923f5 100644
--- a/nanobot/agent/tools/shell.py
+++ b/nanobot/agent/tools/shell.py
@@ -1,5 +1,7 @@
"""Shell execution tool."""
+from __future__ import annotations
+
import asyncio
import os
import re
diff --git a/nanobot/agent/tools/spawn.py b/nanobot/agent/tools/spawn.py
index fc62bf8df..935dd319f 100644
--- a/nanobot/agent/tools/spawn.py
+++ b/nanobot/agent/tools/spawn.py
@@ -1,5 +1,7 @@
"""Spawn tool for creating background subagents."""
+from __future__ import annotations
+
from typing import TYPE_CHECKING, Any
from nanobot.agent.tools.base import Tool
diff --git a/nanobot/agent/tools/web.py b/nanobot/agent/tools/web.py
index 0d8f4d167..61920d981 100644
--- a/nanobot/agent/tools/web.py
+++ b/nanobot/agent/tools/web.py
@@ -1,5 +1,7 @@
"""Web tools: web_search and web_fetch."""
+from __future__ import annotations
+
import html
import json
import os
diff --git a/nanobot/bus/events.py b/nanobot/bus/events.py
index 018c25b3d..0bc8f3971 100644
--- a/nanobot/bus/events.py
+++ b/nanobot/bus/events.py
@@ -1,5 +1,7 @@
"""Event types for the message bus."""
+from __future__ import annotations
+
from dataclasses import dataclass, field
from datetime import datetime
from typing import Any
diff --git a/nanobot/channels/base.py b/nanobot/channels/base.py
index b38fcaf28..296426c68 100644
--- a/nanobot/channels/base.py
+++ b/nanobot/channels/base.py
@@ -1,5 +1,7 @@
"""Base channel interface for chat platforms."""
+from __future__ import annotations
+
from abc import ABC, abstractmethod
from typing import Any
diff --git a/nanobot/channels/dingtalk.py b/nanobot/channels/dingtalk.py
index 8d02fa6cd..76f25d11a 100644
--- a/nanobot/channels/dingtalk.py
+++ b/nanobot/channels/dingtalk.py
@@ -1,5 +1,7 @@
"""DingTalk/DingDing channel implementation using Stream Mode."""
+from __future__ import annotations
+
import asyncio
import json
import mimetypes
diff --git a/nanobot/channels/discord.py b/nanobot/channels/discord.py
index c868bbf3a..fd4926742 100644
--- a/nanobot/channels/discord.py
+++ b/nanobot/channels/discord.py
@@ -1,5 +1,7 @@
"""Discord channel implementation using Discord Gateway websocket."""
+from __future__ import annotations
+
import asyncio
import json
from pathlib import Path
diff --git a/nanobot/channels/email.py b/nanobot/channels/email.py
index 16771fb64..d0e1b61d1 100644
--- a/nanobot/channels/email.py
+++ b/nanobot/channels/email.py
@@ -1,5 +1,7 @@
"""Email channel implementation using IMAP polling + SMTP replies."""
+from __future__ import annotations
+
import asyncio
import html
import imaplib
diff --git a/nanobot/channels/feishu.py b/nanobot/channels/feishu.py
index 8f69c0952..e56b7da23 100644
--- a/nanobot/channels/feishu.py
+++ b/nanobot/channels/feishu.py
@@ -1,5 +1,7 @@
"""Feishu/Lark channel implementation using lark-oapi SDK with WebSocket long connection."""
+from __future__ import annotations
+
import asyncio
import json
import os
diff --git a/nanobot/channels/matrix.py b/nanobot/channels/matrix.py
index 4967ac13c..488b607ec 100644
--- a/nanobot/channels/matrix.py
+++ b/nanobot/channels/matrix.py
@@ -1,5 +1,7 @@
"""Matrix (Element) channel — inbound sync + outbound message/media delivery."""
+from __future__ import annotations
+
import asyncio
import logging
import mimetypes
diff --git a/nanobot/channels/qq.py b/nanobot/channels/qq.py
index 6c5804900..1a4c8af03 100644
--- a/nanobot/channels/qq.py
+++ b/nanobot/channels/qq.py
@@ -1,5 +1,7 @@
"""QQ channel implementation using botpy SDK."""
+from __future__ import annotations
+
import asyncio
from collections import deque
from typing import TYPE_CHECKING
diff --git a/nanobot/channels/slack.py b/nanobot/channels/slack.py
index afd1d2dcd..7301ced67 100644
--- a/nanobot/channels/slack.py
+++ b/nanobot/channels/slack.py
@@ -1,5 +1,7 @@
"""Slack channel implementation using Socket Mode."""
+from __future__ import annotations
+
import asyncio
import re
from typing import Any
diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py
index b28dcedc9..8035b2639 100644
--- a/nanobot/cli/commands.py
+++ b/nanobot/cli/commands.py
@@ -1,5 +1,7 @@
"""CLI commands for nanobot."""
+from __future__ import annotations
+
import asyncio
import os
import select
diff --git a/nanobot/config/loader.py b/nanobot/config/loader.py
index c789efdaf..d16c0d468 100644
--- a/nanobot/config/loader.py
+++ b/nanobot/config/loader.py
@@ -1,5 +1,7 @@
"""Configuration loading utilities."""
+from __future__ import annotations
+
import json
from pathlib import Path
diff --git a/nanobot/config/schema.py b/nanobot/config/schema.py
index 2073eeb07..5eefa831a 100644
--- a/nanobot/config/schema.py
+++ b/nanobot/config/schema.py
@@ -1,5 +1,7 @@
"""Configuration schema using Pydantic."""
+from __future__ import annotations
+
from pathlib import Path
from typing import Literal
diff --git a/nanobot/cron/service.py b/nanobot/cron/service.py
index 1ed71f0f4..c9cd86811 100644
--- a/nanobot/cron/service.py
+++ b/nanobot/cron/service.py
@@ -1,5 +1,7 @@
"""Cron service for scheduling agent tasks."""
+from __future__ import annotations
+
import asyncio
import json
import time
diff --git a/nanobot/cron/types.py b/nanobot/cron/types.py
index 2b4206057..209fddf57 100644
--- a/nanobot/cron/types.py
+++ b/nanobot/cron/types.py
@@ -1,5 +1,7 @@
"""Cron types."""
+from __future__ import annotations
+
from dataclasses import dataclass, field
from typing import Literal
diff --git a/nanobot/providers/base.py b/nanobot/providers/base.py
index 55bd80571..7a90db4d1 100644
--- a/nanobot/providers/base.py
+++ b/nanobot/providers/base.py
@@ -1,5 +1,7 @@
"""Base LLM provider interface."""
+from __future__ import annotations
+
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Any
diff --git a/nanobot/providers/litellm_provider.py b/nanobot/providers/litellm_provider.py
index 620424e61..5a76cb0ea 100644
--- a/nanobot/providers/litellm_provider.py
+++ b/nanobot/providers/litellm_provider.py
@@ -1,5 +1,7 @@
"""LiteLLM provider implementation for multi-provider support."""
+from __future__ import annotations
+
import os
import secrets
import string
diff --git a/nanobot/providers/transcription.py b/nanobot/providers/transcription.py
index 1c8cb6a3f..d7fa9b3d0 100644
--- a/nanobot/providers/transcription.py
+++ b/nanobot/providers/transcription.py
@@ -1,5 +1,7 @@
"""Voice transcription provider using Groq."""
+from __future__ import annotations
+
import os
from pathlib import Path
diff --git a/nanobot/session/manager.py b/nanobot/session/manager.py
index dce4b2ec4..2cde436ed 100644
--- a/nanobot/session/manager.py
+++ b/nanobot/session/manager.py
@@ -1,5 +1,7 @@
"""Session management for conversation history."""
+from __future__ import annotations
+
import json
import shutil
from dataclasses import dataclass, field