Skip to content

Commit

Permalink
🐛 fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Feb 8, 2024
1 parent 83cfc04 commit 6ee17eb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/arclet/alconna/arparma.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ def call(self, target: Callable[..., T]) -> T:
bind.apply_defaults()
return target(*bind.args, **bind.kwargs)

def fail(self, exc: type[Exception] | Exception):
def fail(self, exc: type[Exception] | Exception) -> Self:
"""生成一个失败的 `Arparma`"""
return Arparma(self.source, self.origin, False, self.header_match, error_info=exc)
return Arparma(self.source, self.origin, False, self.header_match, error_info=exc) # type: ignore

def __require__(self, parts: list[str]) -> tuple[dict[str, Any] | OptionResult | SubcommandResult | None, str]:
"""如果能够返回, 除开基本信息, 一定返回该path所在的dict"""
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def __add__(self, other: Option) -> Subcommand:
def __add__(self, other: Args | Arg) -> Option:
...

def __add__(self, other: Option | Args | Arg) -> Self | Subcommand:
def __add__(self, other: Option | Args | Arg) -> Subcommand | Option:
"""连接命令选项与命令节点或命令选项, 生成子命令
Args:
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def set_default(
def set_default(
*,
value: Any = MISSING,
factory: Callable[..., Any] = MISSING,
factory: Callable[..., Any] | _MISSING_TYPE = MISSING,
path: str | None = None,
) -> _SetDefault:
"""
Expand Down
6 changes: 5 additions & 1 deletion tests/analyser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def at(user_id: Union[int, str]):

def gen_unit(type_: str):
return BasePattern(
type_, MatchMode.TYPE_CONVERT, Any, lambda _, seg: seg if seg.type == type_ else None, type_, accepts=[Segment]
model=MatchMode.TYPE_CONVERT,
origin=Any,
converter=lambda _, seg: seg if seg.type == type_ else None,
alias=type_,
accepts=[Segment]
)


Expand Down
2 changes: 1 addition & 1 deletion tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def test_config():
with namespace("cfg1") as np:
np.separators = {";"}
np.separators = (";",)
cfg = Alconna("cfg") + Option("foo")
assert cfg.parse("cfg foo").matched is False
assert cfg.parse("cfg;foo").matched is True
Expand Down

0 comments on commit 6ee17eb

Please sign in to comment.