Skip to content

Commit

Permalink
fix: 直せる範囲で型エラーを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Feb 20, 2024
1 parent d0caa63 commit 8e5a58d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions mipa/ext/commands/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async def _load_from_module(self, spec: ModuleType, key: str) -> None:
@staticmethod
def _resolve_name(name: str, package: Optional[str]) -> str:
try:
return importlib.util.resolve_name(name, package)
return importlib.util.resolve_name(name, package) # pyright: ignore
except ImportError as e:
raise InvalidCogPath(name) from e

Expand Down Expand Up @@ -286,7 +286,7 @@ async def __on_error(event_method: str) -> None:
async def on_error(self, err):
await self.event_dispatch("error", err)

def get_cog(self, name: str) -> Optional[str]:
def get_cog(self, name: str) -> Cog | None:
return self.__cogs.get(name)

async def get_context(self, message, cmd, cls=Context) -> Context:
Expand Down
14 changes: 8 additions & 6 deletions mipa/ext/commands/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
TYPE_CHECKING,
Any,
Callable,
ClassVar,
Dict,
List,
Optional,
Expand All @@ -51,8 +50,11 @@

class CogMeta(type):
__cog_name__: str
__cog_settings__: dict[str, Any] = {}
__cog_listeners__: list[Tuple[str, str]]
__cog_commands__: list[Command] = []

def __new__(cls, *args: Tuple[Any], **kwargs: Dict[str, Any]):
def __new__(cls, *args: Any, **kwargs: Dict[str, Any]):
name, bases, attrs = args
attrs["__cog_name__"] = kwargs.pop("name", name)
attrs["__cog_settings__"] = kwargs.pop("command_attrs", {})
Expand Down Expand Up @@ -107,10 +109,10 @@ def qualified_name(cls) -> str:


class Cog(metaclass=CogMeta):
__cog_name__ = ClassVar[str]
__cog_settings__: Dict[str, Any] = {}
__cog_listeners__: ClassVar[List[Tuple[str, str]]]
__cog_commands__: List[Command] = []
__cog_name__: str
__cog_settings__: dict[str, Any] = {}
__cog_listeners__: list[Tuple[str, str]]
__cog_commands__: list[Command] = []

def __new__(cls, *args: Any, **kwargs: Any):
self = super().__new__(cls)
Expand Down
4 changes: 2 additions & 2 deletions mipa/ext/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import asyncio
import functools
from typing import TYPE_CHECKING, List, Optional
from typing import TYPE_CHECKING, List

from mipa.ext.commands._types import _BaseCommand

Expand Down Expand Up @@ -102,7 +102,7 @@ async def invoke(self, ctx: Context, *args, **kwargs):
await self.callback(*ctx.args, **ctx.kwargs)


def mention_command(regex: Optional[str] = None, text: Optional[str] = None):
def mention_command(regex: str | None = None, text: str | None = None):
def decorator(func, **kwargs):
return Command(func, regex=regex, text=text, **kwargs)

Expand Down

0 comments on commit 8e5a58d

Please sign in to comment.