fix: add from __future__ import annotations across codebase

Ensure all modules using PEP 604 union syntax (X | Y) include
the future annotations import for Python <3.10 compatibility.
While the project requires >=3.11, this avoids import-time
TypeErrors when running tests on older interpreters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tink
2026-03-06 19:13:56 +08:00
co-authored by Claude Opus 4.6
parent e868fb32d2
commit 6b3997c463
29 changed files with 58 additions and 0 deletions
+2
View File
@@ -1,5 +1,7 @@
"""Context builder for assembling agent prompts.""" """Context builder for assembling agent prompts."""
from __future__ import annotations
import base64 import base64
import mimetypes import mimetypes
import platform import platform
+2
View File
@@ -1,5 +1,7 @@
"""Subagent manager for background task execution.""" """Subagent manager for background task execution."""
from __future__ import annotations
import asyncio import asyncio
import json import json
import uuid import uuid
+2
View File
@@ -1,5 +1,7 @@
"""Base class for agent tools.""" """Base class for agent tools."""
from __future__ import annotations
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Any from typing import Any
+2
View File
@@ -1,5 +1,7 @@
"""Cron tool for scheduling reminders and tasks.""" """Cron tool for scheduling reminders and tasks."""
from __future__ import annotations
from contextvars import ContextVar from contextvars import ContextVar
from typing import Any from typing import Any
+2
View File
@@ -1,5 +1,7 @@
"""File system tools: read, write, edit.""" """File system tools: read, write, edit."""
from __future__ import annotations
import difflib import difflib
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
+2
View File
@@ -1,5 +1,7 @@
"""MCP client: connects to MCP servers and wraps their tools as native nanobot tools.""" """MCP client: connects to MCP servers and wraps their tools as native nanobot tools."""
from __future__ import annotations
import asyncio import asyncio
from contextlib import AsyncExitStack from contextlib import AsyncExitStack
from typing import Any from typing import Any
+2
View File
@@ -1,5 +1,7 @@
"""Message tool for sending messages to users.""" """Message tool for sending messages to users."""
from __future__ import annotations
from typing import Any, Awaitable, Callable from typing import Any, Awaitable, Callable
from nanobot.agent.tools.base import Tool from nanobot.agent.tools.base import Tool
+2
View File
@@ -1,5 +1,7 @@
"""Tool registry for dynamic tool management.""" """Tool registry for dynamic tool management."""
from __future__ import annotations
from typing import Any from typing import Any
from nanobot.agent.tools.base import Tool from nanobot.agent.tools.base import Tool
+2
View File
@@ -1,5 +1,7 @@
"""Shell execution tool.""" """Shell execution tool."""
from __future__ import annotations
import asyncio import asyncio
import os import os
import re import re
+2
View File
@@ -1,5 +1,7 @@
"""Spawn tool for creating background subagents.""" """Spawn tool for creating background subagents."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any
from nanobot.agent.tools.base import Tool from nanobot.agent.tools.base import Tool
+2
View File
@@ -1,5 +1,7 @@
"""Web tools: web_search and web_fetch.""" """Web tools: web_search and web_fetch."""
from __future__ import annotations
import html import html
import json import json
import os import os
+2
View File
@@ -1,5 +1,7 @@
"""Event types for the message bus.""" """Event types for the message bus."""
from __future__ import annotations
from dataclasses import dataclass, field from dataclasses import dataclass, field
from datetime import datetime from datetime import datetime
from typing import Any from typing import Any
+2
View File
@@ -1,5 +1,7 @@
"""Base channel interface for chat platforms.""" """Base channel interface for chat platforms."""
from __future__ import annotations
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Any from typing import Any
+2
View File
@@ -1,5 +1,7 @@
"""DingTalk/DingDing channel implementation using Stream Mode.""" """DingTalk/DingDing channel implementation using Stream Mode."""
from __future__ import annotations
import asyncio import asyncio
import json import json
import mimetypes import mimetypes
+2
View File
@@ -1,5 +1,7 @@
"""Discord channel implementation using Discord Gateway websocket.""" """Discord channel implementation using Discord Gateway websocket."""
from __future__ import annotations
import asyncio import asyncio
import json import json
from pathlib import Path from pathlib import Path
+2
View File
@@ -1,5 +1,7 @@
"""Email channel implementation using IMAP polling + SMTP replies.""" """Email channel implementation using IMAP polling + SMTP replies."""
from __future__ import annotations
import asyncio import asyncio
import html import html
import imaplib import imaplib
+2
View File
@@ -1,5 +1,7 @@
"""Feishu/Lark channel implementation using lark-oapi SDK with WebSocket long connection.""" """Feishu/Lark channel implementation using lark-oapi SDK with WebSocket long connection."""
from __future__ import annotations
import asyncio import asyncio
import json import json
import os import os
+2
View File
@@ -1,5 +1,7 @@
"""Matrix (Element) channel — inbound sync + outbound message/media delivery.""" """Matrix (Element) channel — inbound sync + outbound message/media delivery."""
from __future__ import annotations
import asyncio import asyncio
import logging import logging
import mimetypes import mimetypes
+2
View File
@@ -1,5 +1,7 @@
"""QQ channel implementation using botpy SDK.""" """QQ channel implementation using botpy SDK."""
from __future__ import annotations
import asyncio import asyncio
from collections import deque from collections import deque
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
+2
View File
@@ -1,5 +1,7 @@
"""Slack channel implementation using Socket Mode.""" """Slack channel implementation using Socket Mode."""
from __future__ import annotations
import asyncio import asyncio
import re import re
from typing import Any from typing import Any
+2
View File
@@ -1,5 +1,7 @@
"""CLI commands for nanobot.""" """CLI commands for nanobot."""
from __future__ import annotations
import asyncio import asyncio
import os import os
import select import select
+2
View File
@@ -1,5 +1,7 @@
"""Configuration loading utilities.""" """Configuration loading utilities."""
from __future__ import annotations
import json import json
from pathlib import Path from pathlib import Path
+2
View File
@@ -1,5 +1,7 @@
"""Configuration schema using Pydantic.""" """Configuration schema using Pydantic."""
from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import Literal from typing import Literal
+2
View File
@@ -1,5 +1,7 @@
"""Cron service for scheduling agent tasks.""" """Cron service for scheduling agent tasks."""
from __future__ import annotations
import asyncio import asyncio
import json import json
import time import time
+2
View File
@@ -1,5 +1,7 @@
"""Cron types.""" """Cron types."""
from __future__ import annotations
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Literal from typing import Literal
+2
View File
@@ -1,5 +1,7 @@
"""Base LLM provider interface.""" """Base LLM provider interface."""
from __future__ import annotations
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Any from typing import Any
+2
View File
@@ -1,5 +1,7 @@
"""LiteLLM provider implementation for multi-provider support.""" """LiteLLM provider implementation for multi-provider support."""
from __future__ import annotations
import os import os
import secrets import secrets
import string import string
+2
View File
@@ -1,5 +1,7 @@
"""Voice transcription provider using Groq.""" """Voice transcription provider using Groq."""
from __future__ import annotations
import os import os
from pathlib import Path from pathlib import Path
+2
View File
@@ -1,5 +1,7 @@
"""Session management for conversation history.""" """Session management for conversation history."""
from __future__ import annotations
import json import json
import shutil import shutil
from dataclasses import dataclass, field from dataclasses import dataclass, field