Skip to content

Commit 0cf01d1

Browse files
committed
🐛 version 1.8.5
1 parent ad81ec5 commit 0cf01d1

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# 更新日志
22

3+
## Alconna 1.8.5
4+
5+
### 修复
6+
7+
- 修复 `Alconna` 的 aliases (继承自subcommand的) 错误
8+
39
## Alconna 1.8.4
410

511
### 新增

src/arclet/alconna/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
from .typing import UnpackVar as UnpackVar
5151
from .typing import Up as Up
5252

53-
__version__ = "1.8.4"
53+
__version__ = "1.8.5"
5454

5555
# backward compatibility
5656
AnyOne = ANY

src/arclet/alconna/core.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Alconna(Subcommand, Generic[TDC]):
114114

115115
def compile(self, compiler: TCompile | None = None, param_ids: set[str] | None = None) -> Analyser[TDC]:
116116
"""编译 `Alconna` 为对应的解析器"""
117-
return Analyser(self, compiler).compile(param_ids)
117+
return Analyser(self, compiler).compile(set() if param_ids is None else param_ids)
118118

119119
def __init__(
120120
self,
@@ -164,6 +164,7 @@ def __init__(
164164
_args = sum((i for i in args if isinstance(i, (Args, Arg))), Args())
165165
super().__init__("ALCONNA::", _args, *options, dest=name, separators=separators or ns_config.separators, help_text=self.meta.description) # noqa: E501
166166
self.name = name
167+
self.aliases = frozenset((name,))
167168
self.behaviors = []
168169
for behavior in behaviors or []:
169170
self.behaviors.extend(requirement_handler(behavior))
@@ -189,7 +190,11 @@ def reset_namespace(self, namespace: Namespace | str, header: bool = True) -> Se
189190
self.path = f"{self.namespace}::{self.name}"
190191
if header:
191192
self.prefixes = namespace.prefixes.copy()
192-
self.options = self.options[:-3]
193+
name = f"{self.command or self.prefixes[0]}" # type: ignore
194+
self.dest = name
195+
self.path = f"{self.namespace}::{name}"
196+
self.aliases = frozenset((name,))
197+
self.options = [opt for opt in self.options if not isinstance(opt, (Help, Completion, Shortcut))]
193198
add_builtin_options(self.options, namespace)
194199
self.meta.fuzzy_match = namespace.fuzzy_match or self.meta.fuzzy_match
195200
self.meta.raise_exception = namespace.raise_exception or self.meta.raise_exception
@@ -310,7 +315,7 @@ def add(self, opt: Option | Subcommand) -> Self:
310315
Self: 命令本身
311316
"""
312317
with command_manager.update(self):
313-
self.options.insert(-3, opt)
318+
self.options.append(opt)
314319
return self
315320

316321
@init_spec(Option, is_method=True)

0 commit comments

Comments
 (0)