From 187f37f8e772071dc5f6cb65a434b44648ca020d Mon Sep 17 00:00:00 2001 From: Hermes Date: Wed, 8 Jul 2026 12:13:31 +0800 Subject: [PATCH] fix: add 'from __future__ import annotations' for Python <3.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PEP 585 内建泛型 (tuple[str, str], dict[str, int]) 在 Python 3.9 之前不支持。 PEP 563 让所有 type hint 变成字符串, 兼容 Python 3.7+。 错误: 'type' object is not subscriptable 影响: app.py:1184 start_email_scheduler() -> import mailer -> mailer.py:417 修复: mailer.py / app.py 顶部加 from __future__ import annotations --- palladium-monitor/app.py | 2 ++ palladium-monitor/mailer.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/palladium-monitor/app.py b/palladium-monitor/app.py index e20dadd..362d76d 100644 --- a/palladium-monitor/app.py +++ b/palladium-monitor/app.py @@ -10,6 +10,8 @@ Palladium Z1 Monitor — LD逻辑板使用监控系统 2. API 推送 — 在 Palladium 主机运行 collect.py 远程推送 """ +from __future__ import annotations # PEP 563: 兼容 Python 3.7+ (避免 PEP 585 泛型语法) + import os import re import io diff --git a/palladium-monitor/mailer.py b/palladium-monitor/mailer.py index b0c7c65..f817ff1 100644 --- a/palladium-monitor/mailer.py +++ b/palladium-monitor/mailer.py @@ -5,6 +5,8 @@ mailer.py — Palladium Z1 每日报告邮件发送 所有配置都从环境变量读 (生产建议用 systemd EnvironmentFile 或 .env)。 """ +from __future__ import annotations # PEP 563: 让所有 type hint 变字符串, 兼容 Python 3.7+ + import os import smtplib import socket