Skip to content

Commit b17f50f

Browse files
committed
chore(core.db): ruff rewrite
1 parent d575969 commit b17f50f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

astrbot/core/db/migration/shared_preferences_v3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, path=None):
1616
def _load_preferences(self):
1717
if os.path.exists(self.path):
1818
try:
19-
with open(self.path, "r") as f:
19+
with open(self.path) as f:
2020
return json.load(f)
2121
except json.JSONDecodeError:
2222
os.remove(self.path)

astrbot/core/db/migration/sqlite_v3.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sqlite3
22
import time
33
from astrbot.core.db.po import Platform, Stats
4-
from typing import Tuple, List, Dict, Any
4+
from typing import Any
55
from dataclasses import dataclass
66

77

@@ -126,7 +126,7 @@ def _get_conn(self, db_path: str) -> sqlite3.Connection:
126126
conn.text_factory = str
127127
return conn
128128

129-
def _exec_sql(self, sql: str, params: Tuple = None):
129+
def _exec_sql(self, sql: str, params: tuple = None):
130130
conn = self.conn
131131
try:
132132
c = self.conn.cursor()
@@ -257,7 +257,7 @@ def new_conversation(self, user_id: str, cid: str):
257257
(user_id, cid, history, updated_at, created_at),
258258
)
259259

260-
def get_conversations(self, user_id: str) -> Tuple:
260+
def get_conversations(self, user_id: str) -> tuple:
261261
try:
262262
c = self.conn.cursor()
263263
except sqlite3.ProgrammingError:
@@ -320,7 +320,7 @@ def delete_conversation(self, user_id: str, cid: str):
320320

321321
def get_all_conversations(
322322
self, page: int = 1, page_size: int = 20
323-
) -> Tuple[List[Dict[str, Any]], int]:
323+
) -> tuple[list[dict[str, Any]], int]:
324324
"""获取所有对话,支持分页,按更新时间降序排序"""
325325
try:
326326
c = self.conn.cursor()
@@ -381,12 +381,12 @@ def get_filtered_conversations(
381381
self,
382382
page: int = 1,
383383
page_size: int = 20,
384-
platforms: List[str] = None,
385-
message_types: List[str] = None,
384+
platforms: list[str] = None,
385+
message_types: list[str] = None,
386386
search_query: str = None,
387-
exclude_ids: List[str] = None,
388-
exclude_platforms: List[str] = None,
389-
) -> Tuple[List[Dict[str, Any]], int]:
387+
exclude_ids: list[str] = None,
388+
exclude_platforms: list[str] = None,
389+
) -> tuple[list[dict[str, Any]], int]:
390390
"""获取筛选后的对话列表"""
391391
try:
392392
c = self.conn.cursor()

0 commit comments

Comments
 (0)