Skip to content

Commit

Permalink
🐛 version 1.7.34
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Nov 14, 2023
1 parent a377953 commit 6dbe1f8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 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.7.34

### 修复

- 修复 `Option``Subcommand` 模糊匹配的文本错误

## Alconna 1.7.33

### 修复
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.7.33"
__version__ = "1.7.34"

# backward compatibility
Arpamar = Arparma
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/_internal/_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def process(self, argv: Argv[TDC]) -> Self:
name, _ = argv.next(sub.separators)
if name != sub.name: # 先匹配节点名称
if argv.fuzzy_match and levenshtein(name, sub.name) >= config.fuzzy_threshold:
raise FuzzyMatchSuccess(lang.require("fuzzy", "matched").format(source=name, target=sub.name))
raise FuzzyMatchSuccess(lang.require("fuzzy", "matched").format(source=sub.name, target=name))
raise ParamsUnmatched(lang.require("subcommand", "name_error").format(target=name, source=sub.name))

self.value_result = sub.action.value
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/_internal/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def handle_option(argv: Argv, opt: Option) -> tuple[str, OptionResult]:
error = False
if error:
if argv.fuzzy_match and levenshtein(name, opt.name) >= config.fuzzy_threshold:
raise FuzzyMatchSuccess(lang.require("fuzzy", "matched").format(source=name, target=opt.name))
raise FuzzyMatchSuccess(lang.require("fuzzy", "matched").format(source=opt.name, target=name))
raise InvalidParam(lang.require("option", "name_error").format(source=opt.name, target=name))
name = opt.dest
return (
Expand Down
7 changes: 7 additions & 0 deletions tests/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ def test_fuzzy():
assert res5.matched is False
assert cap["output"] == '无法解析 "2 core15_2"。您想要输入的是不是 "1 core15_2" ?'

alc15_3 = Alconna("core15_3", Option("rank", compact=True), meta=CommandMeta(fuzzy_match=True))
with output_manager.capture("core15_3") as cap:
output_manager.set_action(lambda x: x, "core15_3")
res6 = alc15_3.parse("core15_3 runk")
assert res6.matched is False
assert cap["output"] == '无法解析 "runk"。您想要输入的是不是 "rank" ?'


def test_shortcut():
# 原始命令
Expand Down

0 comments on commit 6dbe1f8

Please sign in to comment.