Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 3, 2023
1 parent af7bac5 commit b0b7175
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 64 deletions.
6 changes: 2 additions & 4 deletions src/graia/ariadne/connection/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ class ConfigTypedDict(TypedDict):


@overload
def from_obj(obj: Sequence[ConfigTypedDict]) -> List["Ariadne"]:
...
def from_obj(obj: Sequence[ConfigTypedDict]) -> List["Ariadne"]: ...


@overload
def from_obj(obj: ConfigTypedDict) -> "Ariadne":
...
def from_obj(obj: ConfigTypedDict) -> "Ariadne": ...


def from_obj(obj: Union[ConfigTypedDict, Sequence[ConfigTypedDict]]) -> Union[List["Ariadne"], "Ariadne"]:
Expand Down
6 changes: 2 additions & 4 deletions src/graia/ariadne/connection/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@


@overload
def validate_response(data: Any, raising: Literal[False]) -> Any | Exception:
...
def validate_response(data: Any, raising: Literal[False]) -> Any | Exception: ...


@overload
def validate_response(data: Any, raising: Literal[True] = True) -> Any:
...
def validate_response(data: Any, raising: Literal[True] = True) -> Any: ...


def validate_response(data: Any, raising: bool = True):
Expand Down
18 changes: 6 additions & 12 deletions src/graia/ariadne/message/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ def parse_obj(cls: Type[Self], obj: Union[List[dict], List[Element]]) -> Self:
return cls(cls.build_chain(obj), inline=True)

@overload
def __init__(self, __root__: Sequence[Element], *, inline: Literal[True]) -> None:
...
def __init__(self, __root__: Sequence[Element], *, inline: Literal[True]) -> None: ...

@overload
def __init__(self, *elements: MessageContainer, inline: Literal[False] = False) -> None:
...
def __init__(self, *elements: MessageContainer, inline: Literal[False] = False) -> None: ...

def __init__(
self,
Expand Down Expand Up @@ -146,20 +144,16 @@ def __repr_args__(self) -> "ReprArgs":
return [(None, list(self.content))]

@overload
def __getitem__(self, item: Tuple[Type[Element_T], int]) -> List[Element_T]:
...
def __getitem__(self, item: Tuple[Type[Element_T], int]) -> List[Element_T]: ...

@overload
def __getitem__(self, item: Type[Element_T]) -> List[Element_T]:
...
def __getitem__(self, item: Type[Element_T]) -> List[Element_T]: ...

@overload
def __getitem__(self, item: int) -> Element:
...
def __getitem__(self, item: int) -> Element: ...

@overload
def __getitem__(self, item: slice) -> Self:
...
def __getitem__(self, item: slice) -> Self: ...

def __getitem__(self, item: Union[Tuple[Type[Element], int], Type[Element], int, slice]) -> Any:
"""
Expand Down
6 changes: 2 additions & 4 deletions src/graia/ariadne/message/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,10 @@ def parse_obj(cls, obj: Any) -> Self:
return cls(**obj)

@overload
def __getitem__(self, key: int) -> ForwardNode:
...
def __getitem__(self, key: int) -> ForwardNode: ...

@overload
def __getitem__(self, key: slice) -> List[ForwardNode]:
...
def __getitem__(self, key: slice) -> List[ForwardNode]: ...

def __getitem__(self, key: Union[int, slice]) -> Union[ForwardNode, List[ForwardNode]]:
return self.node_list[key]
Expand Down
5 changes: 3 additions & 2 deletions src/graia/ariadne/message/parser/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class ChainDecorator(abc.ABC, Decorator, Derive[MessageChain]):
pre = True

@abc.abstractmethod
async def __call__(self, chain: MessageChain, interface: DispatcherInterface) -> Optional[MessageChain]:
...
async def __call__(
self, chain: MessageChain, interface: DispatcherInterface
) -> Optional[MessageChain]: ...

async def target(self, interface: DecoratorInterface):
return await self(
Expand Down
9 changes: 3 additions & 6 deletions src/graia/ariadne/message/parser/twilight.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,16 +443,13 @@ def __init__(self, match_result: Dict[Union[int, str], MatchResult]):
self.res = match_result

@overload
def __getitem__(self, item: Union[int, str]) -> MatchResult:
...
def __getitem__(self, item: Union[int, str]) -> MatchResult: ...

@overload
def __getitem__(self, item: Type[int]) -> List[MatchResult]:
...
def __getitem__(self, item: Type[int]) -> List[MatchResult]: ...

@overload
def __getitem__(self, item: Type[str]) -> Dict[str, MatchResult]:
...
def __getitem__(self, item: Type[str]) -> Dict[str, MatchResult]: ...

def __getitem__(self, item: Union[int, str, Type[int], Type[str]]):
if not isinstance(item, type):
Expand Down
6 changes: 2 additions & 4 deletions src/graia/ariadne/message/parser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ def get_help(
*,
prefix_src: Literal["brief", "usage", "description"] = "brief",
fmt_cls: Type[argparse.HelpFormatter] = argparse.HelpFormatter,
) -> str:
...
) -> str: ...

@overload
def get_help(
Expand All @@ -237,8 +236,7 @@ def get_help(
prefix_src: Literal["brief", "usage", "description"] = "brief",
fmt_func: Callable[[str], T],
fmt_cls: Type[argparse.HelpFormatter] = argparse.HelpFormatter,
) -> T:
...
) -> T: ...

def get_help(
self,
Expand Down
6 changes: 2 additions & 4 deletions src/graia/ariadne/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,10 @@ def loop(self) -> asyncio.AbstractEventLoop:
return it(asyncio.AbstractEventLoop)

@overload
def get_interface(self, interface_type: Type[ConnectionInterface]) -> ConnectionInterface:
...
def get_interface(self, interface_type: Type[ConnectionInterface]) -> ConnectionInterface: ...

@overload
def get_interface(self, interface_type: type) -> None:
...
def get_interface(self, interface_type: type) -> None: ...

def get_interface(self, interface_type: type):
if interface_type is ConnectionInterface:
Expand Down
9 changes: 3 additions & 6 deletions src/graia/ariadne/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,11 @@ async def exception(item: SendMessageException) -> Optional[T]:

@runtime_checkable
class SendMessageActionProtocol(Protocol[T_co]):
async def param(self, item: SendMessageDict) -> SendMessageDict:
...
async def param(self, item: SendMessageDict) -> SendMessageDict: ...

async def result(self, item: "ActiveMessage") -> T_co:
...
async def result(self, item: "ActiveMessage") -> T_co: ...

async def exception(self, item: SendMessageException) -> Any:
...
async def exception(self, item: SendMessageException) -> Any: ...


def generic_issubclass(cls: Any, par: Union[type, Any, Tuple[type, ...]]) -> bool:
Expand Down
8 changes: 4 additions & 4 deletions src/graia/ariadne/util/cooldown.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ async def afterDispatch(

@overload
@contextlib.asynccontextmanager
async def trigger(self, target: int) -> AsyncGenerator[Tuple[Optional[datetime], bool], None]:
...
async def trigger(self, target: int) -> AsyncGenerator[Tuple[Optional[datetime], bool], None]: ...

@overload
@contextlib.asynccontextmanager
async def trigger(self, target: int, type: Type[T_Time]) -> AsyncGenerator[Tuple[T_Time, bool], None]:
...
async def trigger(
self, target: int, type: Type[T_Time]
) -> AsyncGenerator[Tuple[T_Time, bool], None]: ...

@contextlib.asynccontextmanager
async def trigger(
Expand Down
9 changes: 3 additions & 6 deletions src/graia/ariadne/util/interrupt.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ def __init__(
self.block_propagation = block_propagation

@overload
async def wait(self, timeout: float, default: T) -> T:
...
async def wait(self, timeout: float, default: T) -> T: ...

@overload
async def wait(self, timeout: float, default: Optional[T] = None) -> Optional[T]:
...
async def wait(self, timeout: float, default: Optional[T] = None) -> Optional[T]: ...

@overload
async def wait(self, timeout: None = None) -> T:
...
async def wait(self, timeout: None = None) -> T: ...

async def wait(self, timeout: Optional[float] = None, default: Optional[T] = None):
"""等待 Waiter, 如果超时则返回默认值
Expand Down
6 changes: 2 additions & 4 deletions src/graia/ariadne/util/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ def __init__(self, ignore: bool = False) -> None:

@overload
@staticmethod
async def exception(item) -> ActiveMessage:
...
async def exception(item) -> ActiveMessage: ...

@overload
async def exception(self, item) -> ActiveMessage:
...
async def exception(self, item) -> ActiveMessage: ...

@staticmethod
async def _handle(item: SendMessageException, ignore: bool):
Expand Down
6 changes: 2 additions & 4 deletions src/test_old/commander_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ async def m():
for _ in range(handles):

@cmd.command(".test foo bar fox mop {v}")
def _(v: At):
...
def _(v: At): ...

async def disp(entry, dispatchers):
debug(dispatchers[0].data)
Expand All @@ -34,8 +33,7 @@ async def disp(entry, dispatchers):

await cmd.execute(msg)

async def a(*args, **kwargs):
...
async def a(*args, **kwargs): ...

cmd.broadcast.Executor = a

Expand Down

0 comments on commit b0b7175

Please sign in to comment.