Skip to content

Commit

Permalink
🐛 fix exception always convert to str
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed May 12, 2023
1 parent 45901d1 commit e2be5a7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# 更新日志

## Alconna 1.7.1

### 修复:

- 修复 `Arparma.error_info` 总为 str 的 bug

## Alconna 1.7.0

**此版本为长期支持版本 (LTS), 也是 2.0 版本前的最后一个版本**
**此版本为长期支持版本 (LTS), 也是 2.0 版本前的最后一个主要版本**

### 破坏性改动:

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 @@ -21,7 +21,7 @@
from .duplication import Duplication
from .stub import ArgsStub, OptionStub, SubcommandStub

__version__ = "1.7.0"
__version__ = "1.7.1"

# 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 @@ -435,7 +435,7 @@ def export(
"""
result = Arparma(self.command.path, argv.origin, not fail, self.header_result)
if fail:
result.error_info = repr(exception or traceback.format_exc(limit=1))
result.error_info = exception or repr(traceback.format_exc(limit=1))
result.error_data = argv.release()
else:
if self.default_opt_result:
Expand Down
10 changes: 8 additions & 2 deletions tests/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,11 @@ def test_shortcut():


def test_help():
from arclet.alconna.exceptions import SpecialOptionTriggered

alc17 = Alconna("core17") + Option("foo", Args["bar", str])
alc17.parse("core17 --help")
res = alc17.parse("core17 --help")
assert isinstance(res.error_info, SpecialOptionTriggered)
alc17.parse("core17 --help foo")
alc17_1 = Alconna(
"core17_1",
Expand All @@ -440,6 +443,8 @@ def test_args_notice():


def test_completion():
from arclet.alconna.exceptions import SpecialOptionTriggered

alc20 = (
"core20"
+ Option("fool")
Expand All @@ -464,7 +469,8 @@ def test_completion():
alc20.parse("core20 off c --comp")

alc20_1 = Alconna("core20_1", Args.foo[int], Option("bar"))
alc20_1.parse("core20_1 -cp")
res = alc20_1.parse("core20_1 -cp")
assert isinstance(res.error_info, SpecialOptionTriggered)


def test_completion_interface():
Expand Down

0 comments on commit e2be5a7

Please sign in to comment.