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
parent e868fb32d2
commit 6b3997c463
29 changed files with 58 additions and 0 deletions

View File

@ -1,5 +1,7 @@
"""Context builder for assembling agent prompts."""
from __future__ import annotations
import base64
import mimetypes
import platform

View File

@ -1,5 +1,7 @@
"""Subagent manager for background task execution."""
from __future__ import annotations
import asyncio
import json
import uuid

View File

@ -1,5 +1,7 @@
"""Base class for agent tools."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any

View File

@ -1,5 +1,7 @@
"""Cron tool for scheduling reminders and tasks."""
from __future__ import annotations
from contextvars import ContextVar
from typing import Any

View File

@ -1,5 +1,7 @@
"""File system tools: read, write, edit."""
from __future__ import annotations
import difflib
from pathlib import Path
from typing import Any

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,7 @@
"""Shell execution tool."""
from __future__ import annotations
import asyncio
import os
import re

View File

@ -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

View File

@ -1,5 +1,7 @@
"""Web tools: web_search and web_fetch."""
from __future__ import annotations
import html
import json
import os

View File

@ -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

View File

@ -1,5 +1,7 @@
"""Base channel interface for chat platforms."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any

View File

@ -1,5 +1,7 @@
"""DingTalk/DingDing channel implementation using Stream Mode."""
from __future__ import annotations
import asyncio
import json
import mimetypes

View File

@ -1,5 +1,7 @@
"""Discord channel implementation using Discord Gateway websocket."""
from __future__ import annotations
import asyncio
import json
from pathlib import Path

View File

@ -1,5 +1,7 @@
"""Email channel implementation using IMAP polling + SMTP replies."""
from __future__ import annotations
import asyncio
import html
import imaplib

View File

@ -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

View File

@ -1,5 +1,7 @@
"""Matrix (Element) channel — inbound sync + outbound message/media delivery."""
from __future__ import annotations
import asyncio
import logging
import mimetypes

View File

@ -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

View File

@ -1,5 +1,7 @@
"""Slack channel implementation using Socket Mode."""
from __future__ import annotations
import asyncio
import re
from typing import Any

View File

@ -1,5 +1,7 @@
"""CLI commands for nanobot."""
from __future__ import annotations
import asyncio
import os
import select

View File

@ -1,5 +1,7 @@
"""Configuration loading utilities."""
from __future__ import annotations
import json
from pathlib import Path

View File

@ -1,5 +1,7 @@
"""Configuration schema using Pydantic."""
from __future__ import annotations
from pathlib import Path
from typing import Literal

View File

@ -1,5 +1,7 @@
"""Cron service for scheduling agent tasks."""
from __future__ import annotations
import asyncio
import json
import time

View File

@ -1,5 +1,7 @@
"""Cron types."""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Literal

View File

@ -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

View File

@ -1,5 +1,7 @@
"""LiteLLM provider implementation for multi-provider support."""
from __future__ import annotations
import os
import secrets
import string

View File

@ -1,5 +1,7 @@
"""Voice transcription provider using Groq."""
from __future__ import annotations
import os
from pathlib import Path

View File

@ -1,5 +1,7 @@
"""Session management for conversation history."""
from __future__ import annotations
import json
import shutil
from dataclasses import dataclass, field