fix: textual.suggestion 兼容老版 Textual + 升级最低版本约束
- textual.suggestion 在 Textual < 2.0 中不存在 - 添加 try/except fallback 构造兼容 Suggestion 类 - requirements.txt: textual>=0.40.0 → >=0.47.0 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
rich>=13.0.0
|
rich>=13.0.0
|
||||||
textual>=0.40.0
|
textual>=0.47.0
|
||||||
websockets>=12.0
|
websockets>=12.0
|
||||||
aiohttp>=3.9.0
|
aiohttp>=3.9.0
|
||||||
pyyaml>=6.0
|
pyyaml>=6.0
|
||||||
|
|||||||
@@ -10,7 +10,15 @@ from textual.containers import Container, ScrollableContainer, Horizontal
|
|||||||
from textual.widgets import Static, Input, Header, Footer, LoadingIndicator
|
from textual.widgets import Static, Input, Header, Footer, LoadingIndicator
|
||||||
from textual.reactive import reactive
|
from textual.reactive import reactive
|
||||||
from textual.suggester import Suggester
|
from textual.suggester import Suggester
|
||||||
|
|
||||||
|
try:
|
||||||
from textual.suggestion import Suggestion
|
from textual.suggestion import Suggestion
|
||||||
|
except ImportError:
|
||||||
|
# Textual < 2.0 兼容 — 自行构造 Suggestion
|
||||||
|
class Suggestion:
|
||||||
|
__slots__ = ("value",)
|
||||||
|
def __init__(self, value: str = ""):
|
||||||
|
self.value = value
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|||||||
Reference in New Issue
Block a user