Skip to content

Commit

Permalink
🐛 version 1.8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Mar 10, 2024
1 parent ad81ec5 commit 0cf01d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 更新日志

## Alconna 1.8.5

### 修复

- 修复 `Alconna` 的 aliases (继承自subcommand的) 错误

## Alconna 1.8.4

### 新增
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from .typing import UnpackVar as UnpackVar
from .typing import Up as Up

__version__ = "1.8.4"
__version__ = "1.8.5"

# backward compatibility
AnyOne = ANY
11 changes: 8 additions & 3 deletions src/arclet/alconna/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Alconna(Subcommand, Generic[TDC]):

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

def __init__(
self,
Expand Down Expand Up @@ -164,6 +164,7 @@ def __init__(
_args = sum((i for i in args if isinstance(i, (Args, Arg))), Args())
super().__init__("ALCONNA::", _args, *options, dest=name, separators=separators or ns_config.separators, help_text=self.meta.description) # noqa: E501
self.name = name
self.aliases = frozenset((name,))
self.behaviors = []
for behavior in behaviors or []:
self.behaviors.extend(requirement_handler(behavior))
Expand All @@ -189,7 +190,11 @@ def reset_namespace(self, namespace: Namespace | str, header: bool = True) -> Se
self.path = f"{self.namespace}::{self.name}"
if header:
self.prefixes = namespace.prefixes.copy()
self.options = self.options[:-3]
name = f"{self.command or self.prefixes[0]}" # type: ignore
self.dest = name
self.path = f"{self.namespace}::{name}"
self.aliases = frozenset((name,))
self.options = [opt for opt in self.options if not isinstance(opt, (Help, Completion, Shortcut))]
add_builtin_options(self.options, namespace)
self.meta.fuzzy_match = namespace.fuzzy_match or self.meta.fuzzy_match
self.meta.raise_exception = namespace.raise_exception or self.meta.raise_exception
Expand Down Expand Up @@ -310,7 +315,7 @@ def add(self, opt: Option | Subcommand) -> Self:
Self: 命令本身
"""
with command_manager.update(self):
self.options.insert(-3, opt)
self.options.append(opt)
return self

@init_spec(Option, is_method=True)
Expand Down

0 comments on commit 0cf01d1

Please sign in to comment.