fix: restore top-level import order

This commit is contained in:
chengyongru
2026-06-03 16:57:29 +08:00
committed by Xubin Ren
parent 3b46386887
commit facdc41a16
4 changed files with 33 additions and 38 deletions
+24 -24
View File
@@ -19,8 +19,9 @@ if sys.platform == "win32":
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
import typer
from loguru import logger
# Keep console encoding setup before importing CLI UI/logging libraries.
import typer # noqa: E402
from loguru import logger # noqa: E402
# Remove default handler and re-add with unified nanobot format
logger.remove()
@@ -37,18 +38,28 @@ _log_handler_id = logger.add(
filter=lambda record: record["extra"].setdefault("channel", "-") or True,
)
from prompt_toolkit import PromptSession, print_formatted_text
from prompt_toolkit.application import run_in_terminal
from prompt_toolkit.formatted_text import ANSI, HTML
from prompt_toolkit.history import FileHistory
from prompt_toolkit.patch_stdout import patch_stdout
from rich.console import Console
from rich.markdown import Markdown
from rich.table import Table
from rich.text import Text
from prompt_toolkit import PromptSession, print_formatted_text # noqa: E402
from prompt_toolkit.application import run_in_terminal # noqa: E402
from prompt_toolkit.formatted_text import ANSI, HTML # noqa: E402
from prompt_toolkit.history import FileHistory # noqa: E402
from prompt_toolkit.patch_stdout import patch_stdout # noqa: E402
from rich.console import Console # noqa: E402
from rich.markdown import Markdown # noqa: E402
from rich.table import Table # noqa: E402
from rich.text import Text # noqa: E402
from nanobot import __logo__, __version__
from nanobot.agent.loop import AgentLoop
from nanobot import __logo__, __version__ # noqa: E402
from nanobot.agent.loop import AgentLoop # noqa: E402
from nanobot.cli.stream import StreamRenderer, ThinkingSpinner # noqa: E402
from nanobot.config.paths import get_workspace_path, is_default_workspace # noqa: E402
from nanobot.config.schema import Config # noqa: E402
from nanobot.utils.evaluator import evaluate_response # noqa: E402
from nanobot.utils.helpers import sync_workspace_templates # noqa: E402
from nanobot.utils.restart import ( # noqa: E402
consume_restart_notice_from_env,
format_restart_completed_message,
should_show_cli_restart_notice,
)
def _sanitize_surrogates(text: str) -> str:
@@ -72,17 +83,6 @@ class SafeFileHistory(FileHistory):
def store_string(self, string: str) -> None:
super().store_string(_sanitize_surrogates(string))
from nanobot.cli.stream import StreamRenderer, ThinkingSpinner
from nanobot.config.paths import get_workspace_path, is_default_workspace
from nanobot.config.schema import Config
from nanobot.utils.evaluator import evaluate_response
from nanobot.utils.helpers import sync_workspace_templates
from nanobot.utils.restart import (
consume_restart_notice_from_env,
format_restart_completed_message,
should_show_cli_restart_notice,
)
app = typer.Typer(
name="nanobot",
context_settings={"help_option_names": ["-h", "--help"]},