Skip to content

Commit 21ae352

Browse files
committed
sync: 1.8.37 - 1.8.38
1 parent 29b8d21 commit 21ae352

5 files changed

Lines changed: 29 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@
1111
- Sistana (及其上游库)仅支持 Python 3.9 及以上版本。
1212
- Sistana 对各种特性的兼容性尚未完全测试。
1313

14+
## 1.8.38
15+
16+
### 修复
17+
18+
- 修复 `command_manager.get_commands` 无法使用 `Namespace` 对象
19+
- 修复 `ShortcutArgs` 的导出问题
20+
21+
## 1.8.37
22+
23+
### 修复
24+
25+
- 修复命令的启用/禁用问题
26+
- 修复快捷指令在帮助信息里打印时前缀显示不正确的问题
27+
28+
## 1.8.36
29+
30+
### 修复
31+
32+
- 修复当目标指令携带命令前缀时删除快捷指令无法完全清理所有对应的指令的错误
33+
34+
1435
## 1.8.35
1536

1637
### 改进

src/arclet/alconna/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
from .shortcut import ShortcutArgs as ShortcutArgs
4040
from .manager import command_manager as command_manager
4141

42-
__version__ = "1.8.36"
42+
__version__ = "1.8.38"

src/arclet/alconna/formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def shortcut(self, shortcuts: dict[str, Any]) -> str:
239239
for key, short in shortcuts.items():
240240
if isinstance(short, InnerShortcutArgs):
241241
_key = key + (" ...args" if short.fuzzy else "")
242-
prefixes = f"[{'│'.join(short.prefixes)}]" if short.prefixes else ""
242+
prefixes = f"[{'│'.join(short.prefixes)}]" if any(short.prefixes) else ""
243243
result.append(f"'{prefixes}{_key}' => {prefixes}{short.command} {' '.join(map(str, short.args))}")
244244
else:
245245
result.append(f"'{key}' => {short.origin!r}")

src/arclet/alconna/manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def set_enabled(self, command: Alconna | str, enabled: bool):
180180
command = self.get_command(command)
181181
if enabled and command._hash in self.__abandons:
182182
self.__abandons.remove(command._hash)
183-
if not enabled and command not in self.__abandons:
183+
if not enabled and command._hash not in self.__abandons:
184184
self.__abandons.append(command._hash)
185185

186186
def add_shortcut(self, target: Alconna, key: str | TPattern, source: ShortcutArgs):
@@ -285,14 +285,14 @@ def delete_shortcut(self, target: Alconna, key: str | TPattern | None = None):
285285
for prefix in args.prefixes:
286286
_shortcut[1].pop(f"{re.escape(prefix)}{args.origin_key}")
287287
_shortcut[1].pop(args.origin_key, None)
288-
return i18n.require("shortcut", "delete_success").format(shortcut=f"[*]{args.origin_key}", target=target.path)
288+
return i18n.require("shortcut.delete_success").format(shortcut=f"[*]{args.origin_key}", target=target.path)
289289
for key, args in _shortcut[1].items():
290290
if re.fullmatch(key, _key, args.flags):
291291
args = _shortcut[1][key]
292292
break
293293
else:
294294
raise ValueError(
295-
i18n.require("manager", "shortcut_parse_error").format(target=f"{namespace}.{name}", query=_key)
295+
i18n.require("manager.shortcut_parse_error").format(target=f"{namespace}.{name}", query=_key)
296296
)
297297
for prefix in args.prefixes:
298298
_shortcut[1].pop(f"{re.escape(prefix)}{args.origin_key}")
@@ -301,10 +301,10 @@ def delete_shortcut(self, target: Alconna, key: str | TPattern | None = None):
301301
if short.origin_key == args.origin_key:
302302
_shortcut[0].pop(key)
303303
break
304-
return i18n.require("shortcut", "delete_success").format(shortcut=f"[*]{args.origin_key}", target=target.path)
304+
return i18n.require("shortcut.delete_success").format(shortcut=f"[*]{args.origin_key}", target=target.path)
305305
else:
306306
self._shortcuts.pop(f"{namespace}.{name}")
307-
return i18n.require("shortcut", "delete_success").format(shortcut="[all]", target=target.path)
307+
return i18n.require("shortcut.delete_success").format(shortcut="[all]", target=target.path)
308308

309309
def get_command(self, command: str) -> Alconna:
310310
"""获取命令"""

src/arclet/alconna/shortcut.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def __repr__(self):
8686

8787
def dump(self):
8888
return {
89+
"origin_key": self.origin_key,
8990
"command": self.command,
9091
"args": self.args,
9192
"fuzzy": self.fuzzy,

0 commit comments

Comments
 (0)