Skip to content

Commit

Permalink
🐛 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Dec 25, 2023
1 parent 94deccf commit 382dcc0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/arclet/alconna/_internal/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def analyse_param(analyser: SubAnalyser, argv: Argv, seps: tuple[str, ...] | Non
if analyser.extra_allow:
analyser.args_result.setdefault("$extra", []).append(_text)
argv.next(seps, move=True)
return True
return False


Expand Down
12 changes: 6 additions & 6 deletions src/arclet/alconna/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ def __calc_eq__(self, other): # pragma: no cover
AllParam = _AllParamPattern()


class KeyWordVar(BasePattern[T]):
class KeyWordVar(BasePattern[T, Any]):
"""对具名参数的包装"""

base: BasePattern

def __init__(self, value: BasePattern[T] | type[T], sep: str = "="):
def __init__(self, value: BasePattern[T, Any] | type[T], sep: str = "="):
"""构建一个具名参数
Args:
Expand All @@ -135,21 +135,21 @@ def __repr__(self):
class _Kw:
__slots__ = ()

def __getitem__(self, item: BasePattern[T] | type[T]):
def __getitem__(self, item: BasePattern[T, Any] | type[T]):
return KeyWordVar(item)

__matmul__ = __getitem__
__rmatmul__ = __getitem__


class MultiVar(BasePattern[T]):
class MultiVar(BasePattern[T, Any]):
"""对可变参数的包装"""

base: BasePattern[T]
base: BasePattern[T, Any]
flag: Literal["+", "*"]
length: int

def __init__(self, value: BasePattern[T] | type[T], flag: int | Literal["+", "*"] = "+"):
def __init__(self, value: BasePattern[T, Any] | type[T], flag: int | Literal["+", "*"] = "+"):
"""构建一个可变参数
Args:
Expand Down
4 changes: 2 additions & 2 deletions tests/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ def test_help():
assert cap["output"] == "[foo] <bar: str> \nFoo bar"
with output_manager.capture("core17") as cap:
alc17.parse("core17 --help baz")
assert cap["output"] == "baz <qux: str> \nBaz qux"
assert cap["output"] == "[baz] <qux: str> \nBaz qux"
with output_manager.capture("core17") as cap:
alc17.parse("core17 baz --help")
assert cap["output"] == "baz <qux: str> \nBaz qux"
assert cap["output"] == "[baz] <qux: str> \nBaz qux"
with output_manager.capture("core17") as cap:
alc17.parse("core17 add --help")
assert cap["output"] == "add <bar: str> \nAdd bar"
Expand Down

0 comments on commit 382dcc0

Please sign in to comment.