diff --git a/requirements.txt b/requirements.txt index 389181e..1cb4f94 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ -wheel==0.41.1 -asyncpg==0.28.0 -sqlalchemy[asyncio]==2.0.19 -typing_extensions==4.7.1 -discord.py==2.3.2 -click==8.1.6 -psutil==5.9.5 -alembic==1.11.2 +wheel +asyncpg +sqlalchemy[asyncio] +typing_extensions +discord.py +click +psutil +alembic topggpy==2.0.0a0 -lingua-language-detector==1.3.2 -aiohttp==3.8.5 -python-dateutil==2.8.2 +lingua-language-detector +aiohttp +python-dateutil diff --git a/src/cogs/poll/edit.py b/src/cogs/poll/edit.py index 6024d1f..033fe61 100644 --- a/src/cogs/poll/edit.py +++ b/src/cogs/poll/edit.py @@ -358,7 +358,7 @@ class AddChoice(Menu["MyBot"], ui.Modal): def __init__(self, parent: EditChoices) -> None: ui.Modal.__init__(self, title=_("Add a new choice")) - Menu.__init__(self, parent=parent) # pyright: ignore [reportUnknownMemberType] + Menu.__init__(self, parent=parent) # type: ignore # TODO async def build(self) -> Self: self.choice = ui.TextInput[Self]( diff --git a/src/cogs/translate/_types.py b/src/cogs/translate/_types.py index 1b1f69f..e88db29 100644 --- a/src/cogs/translate/_types.py +++ b/src/cogs/translate/_types.py @@ -7,7 +7,7 @@ class SendStrategy(Protocol): - async def __call__(self, *, content: str = Any, embeds: Sequence[Embed] = Any, view: ui.View = MISSING) -> Any: + async def __call__(self, *, content: str = ..., embeds: Sequence[Embed] = ..., view: ui.View = MISSING) -> Any: ... diff --git a/src/core/_config.py b/src/core/_config.py index 7746b66..d0b6d30 100644 --- a/src/core/_config.py +++ b/src/core/_config.py @@ -29,7 +29,7 @@ class Config: TRANSLATOR_SERVICES: str = "libretranslate" LOG_WEBHOOK_URL: str | None = None - _instance: ClassVar[Config] | None = None + _instance: ClassVar[Self] | None = None _defined: ClassVar[bool] = False def __new__(cls, *args: Any, **kwargs: Any) -> Self: diff --git a/src/core/response.py b/src/core/response.py index e1ea7db..a3f3aed 100644 --- a/src/core/response.py +++ b/src/core/response.py @@ -1,7 +1,7 @@ import logging from dataclasses import dataclass from enum import Enum, auto -from typing import Any, Iterator, Literal, Mapping, overload +from typing import Any, Iterator, Mapping import discord from discord import Color, Embed @@ -9,13 +9,13 @@ logger = logging.getLogger(__name__) -@dataclass() +@dataclass class MessageDisplay(Mapping[str, Embed | str | None]): """ Used to represent the "display" of a message. It contains the content, the embeds, etc... """ - embed: Embed | None = None + embed: Embed content: str | None = None def __getitem__(self, key: str) -> Any: @@ -43,11 +43,6 @@ def __len__(self) -> int: return 0 -class _ResponseEmbed(MessageDisplay): - embed: Embed - content: str | None = None - - class ResponseType(Enum): success = auto() info = auto() @@ -70,20 +65,6 @@ class ResponseType(Enum): } -@overload -def response_constructor( - response_type: ResponseType, message: str, embedded: Literal[True] = ..., author_url: str | None = ... -) -> _ResponseEmbed: - ... - - -@overload -def response_constructor( - response_type: ResponseType, message: str, embedded: Literal[False] = ..., author_url: str | None = ... -) -> MessageDisplay: - ... - - def response_constructor( response_type: ResponseType, message: str, embedded: bool = True, author_url: str | None = None ) -> MessageDisplay: diff --git a/typings/lingua.pyi b/typings/lingua.pyi new file mode 100644 index 0000000..b01abb4 --- /dev/null +++ b/typings/lingua.pyi @@ -0,0 +1,31 @@ +from enum import Enum, auto +from typing import Self + +class Language(Enum): + ENGLISH = auto() + ARABIC = auto() + CHINESE = auto() + FRENCH = auto() + GERMAN = auto() + HINDI = auto() + INDONESIAN = auto() + IRISH = auto() + ITALIAN = auto() + JAPANESE = auto() + KOREAN = auto() + POLISH = auto() + PORTUGUESE = auto() + RUSSIAN = auto() + SPANISH = auto() + TURKISH = auto() + VIETNAMESE = auto() + +class LanguageDetectorBuilder: + @classmethod + def from_languages(cls, *args: Language) -> Self: ... + def with_low_accuracy_mode(self) -> Self: ... + def with_minimum_relative_distance(self, value: float) -> Self: ... + def build(self) -> LanguageDetector: ... + +class LanguageDetector: + def detect_language_of(self, text: str) -> Language | None: ...