diff --git a/fizzbuzz/__init__.pyi b/fizzbuzz/__init__.pyi deleted file mode 100644 index 3529c1e..0000000 --- a/fizzbuzz/__init__.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from . import discord as discord -from .util import log_handler as log_handler diff --git a/fizzbuzz/db/__init__.pyi b/fizzbuzz/db/__init__.pyi deleted file mode 100644 index d2bc2f6..0000000 --- a/fizzbuzz/db/__init__.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from . import wrapped as wrapped -from .db import DB_DIR as DB_DIR, DatabaseError as DatabaseError -from .settings import ( - SettingsManager as SettingsManager, - settings_manager as settings_manager, -) diff --git a/fizzbuzz/db/db.pyi b/fizzbuzz/db/db.pyi deleted file mode 100644 index 4891261..0000000 --- a/fizzbuzz/db/db.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from pathlib import Path -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -class DatabaseError(Exception): ... - -DB_DIR: Final[Path] diff --git a/fizzbuzz/db/settings.py b/fizzbuzz/db/settings.py index 082aac9..d803335 100644 --- a/fizzbuzz/db/settings.py +++ b/fizzbuzz/db/settings.py @@ -13,6 +13,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["SettingsManager", "SettingsScope", "settings_manager"] + _DB_FILENAME = "bot.sqlite" diff --git a/fizzbuzz/db/settings.pyi b/fizzbuzz/db/settings.pyi deleted file mode 100644 index 8441eaf..0000000 --- a/fizzbuzz/db/settings.pyi +++ /dev/null @@ -1,40 +0,0 @@ -from typing import Any, Final, Literal, TypeAlias - -import aiosqlite - -__author__: Final[str] -__license__: Final[str] - -SettingsScope: TypeAlias = Literal["guild", "user", "global"] - -class SettingsManager: - def __init__(self) -> None: ... - async def connect(self) -> aiosqlite.Connection: ... - async def set_value( - self, - scope: SettingsScope, - scope_id: int | str, - key: str, - value: object, - ) -> None: ... - async def get_value( - self, - scope: SettingsScope, - scope_id: int | str, - key: str, - ) -> object | None: ... - async def get_all( - self, scope: SettingsScope, scope_id: int | str - ) -> dict[str, Any]: ... - async def delete_value( - self, scope: SettingsScope, scope_id: int | str, key: str - ) -> None: ... - async def delete_scope(self, scope: SettingsScope, scope_id: int | str) -> None: ... - async def get_admin_role_ids(self, guild_id: int, /) -> list[int]: ... - async def set_admin_role_ids( - self, guild_id: int, /, role_ids: list[int] - ) -> None: ... - async def add_admin_role_id(self, guild_id: int, /, role_id: int) -> None: ... - async def remove_admin_role_id(self, guild_id: int, /, role_id: int) -> None: ... - -settings_manager: Final[SettingsManager] diff --git a/fizzbuzz/db/wrapped/__init__.pyi b/fizzbuzz/db/wrapped/__init__.pyi deleted file mode 100644 index 2a136ab..0000000 --- a/fizzbuzz/db/wrapped/__init__.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from .metrics import metric_store as metric_store diff --git a/fizzbuzz/db/wrapped/metrics.py b/fizzbuzz/db/wrapped/metrics.py index b6611b9..2388477 100644 --- a/fizzbuzz/db/wrapped/metrics.py +++ b/fizzbuzz/db/wrapped/metrics.py @@ -13,6 +13,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["YearlyMetricStore", "metric_store"] + _SCHEMA = """--sql CREATE TABLE IF NOT EXISTS messages ( message_id TEXT PRIMARY KEY, diff --git a/fizzbuzz/db/wrapped/metrics.pyi b/fizzbuzz/db/wrapped/metrics.pyi deleted file mode 100644 index d8439e8..0000000 --- a/fizzbuzz/db/wrapped/metrics.pyi +++ /dev/null @@ -1,33 +0,0 @@ -from datetime import datetime -from typing import Final - -import aiosqlite - -__author__: Final[str] -__license__: Final[str] - -class YearlyMetricStore: - def __init__(self) -> None: ... - async def get_connection(self, year: int, /) -> aiosqlite.Connection: ... - async def insert_message( - self, - year: int, - /, - *, - message_id: int, - channel_id: int, - author_id: int, - created_at_iso: str, - content: str | None, - attachment_count: int, - image_count: int, - video_count: int, - sticker_count: int, - embed_count: int, - ) -> None: ... - async def commit(self, year: int, /) -> None: ... - async def get_latest_timestamp( - self, year: int, /, channel_id: int - ) -> datetime | None: ... - -metric_store: Final[YearlyMetricStore] diff --git a/fizzbuzz/discord/__init__.pyi b/fizzbuzz/discord/__init__.pyi deleted file mode 100644 index df4d89f..0000000 --- a/fizzbuzz/discord/__init__.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from . import interaction as interaction, ui as ui, views as views -from .info import ( - BOT_APP_ID as BOT_APP_ID, - DEPENDENCIES as DEPENDENCIES, - DISCORD_DOT_PY_VERSION as DISCORD_DOT_PY_VERSION, - HOST as HOST, - PROTOTYPE_BOT_APP_ID as PROTOTYPE_BOT_APP_ID, - PYTHON_VERSION as PYTHON_VERSION, - START_TIME as START_TIME, - VERSION as VERSION, - get_uptime as get_uptime, -) diff --git a/fizzbuzz/discord/checks/__init__.pyi b/fizzbuzz/discord/checks/__init__.pyi deleted file mode 100644 index 111618c..0000000 --- a/fizzbuzz/discord/checks/__init__.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from .admin_checks import ( - Unauthorized as Unauthorized, - admin_only as admin_only, - owner_only as owner_only, -) -from .guild_checks import ( - NotInGuild as NotInGuild, - get_guild as get_guild, - get_member as get_member, - guild_only as guild_only, -) diff --git a/fizzbuzz/discord/checks/admin_checks.py b/fizzbuzz/discord/checks/admin_checks.py index c497e92..0d61b7f 100644 --- a/fizzbuzz/discord/checks/admin_checks.py +++ b/fizzbuzz/discord/checks/admin_checks.py @@ -11,6 +11,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["Unauthorized", "admin_only", "owner_only"] + class Unauthorized(app_commands.CheckFailure): """Raised when an unauthorized user attempts to use an authorized command.""" diff --git a/fizzbuzz/discord/checks/admin_checks.pyi b/fizzbuzz/discord/checks/admin_checks.pyi deleted file mode 100644 index 3928c63..0000000 --- a/fizzbuzz/discord/checks/admin_checks.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from typing import Final - -from discord import app_commands - -from .types import Check - -__author__: Final[str] -__license__: Final[str] - -class Unauthorized(app_commands.CheckFailure): - def __init__(self, message: str | None = None) -> None: ... - -def admin_only() -> Check: ... -def owner_only() -> Check: ... diff --git a/fizzbuzz/discord/checks/guild_checks.py b/fizzbuzz/discord/checks/guild_checks.py index 0138c99..fc5270b 100644 --- a/fizzbuzz/discord/checks/guild_checks.py +++ b/fizzbuzz/discord/checks/guild_checks.py @@ -11,6 +11,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["NotInGuild", "get_guild", "get_member", "guild_only"] + class NotInGuild(app_commands.CheckFailure): """Raised when a user who is not in a guild attempts to use a guild-only command.""" diff --git a/fizzbuzz/discord/checks/guild_checks.pyi b/fizzbuzz/discord/checks/guild_checks.pyi deleted file mode 100644 index 93a3af8..0000000 --- a/fizzbuzz/discord/checks/guild_checks.pyi +++ /dev/null @@ -1,18 +0,0 @@ -"""Check that a command is only run in a guild.""" - -from typing import Final - -import discord -from discord import app_commands - -from .types import Check - -__author__: Final[str] -__license__: Final[str] - -class NotInGuild(app_commands.CheckFailure): - def __init__(self, message: str | None = None) -> None: ... - -def guild_only() -> Check: ... -def get_guild(interaction: discord.Interaction, /) -> discord.Guild: ... -def get_member(interaction: discord.Interaction, /) -> discord.Member: ... diff --git a/fizzbuzz/discord/checks/types.py b/fizzbuzz/discord/checks/types.py index e517cb9..3074409 100644 --- a/fizzbuzz/discord/checks/types.py +++ b/fizzbuzz/discord/checks/types.py @@ -6,6 +6,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["Check", "CheckT"] + T = TypeVar("T") CheckT = Callable[[T], T] diff --git a/fizzbuzz/discord/checks/types.pyi b/fizzbuzz/discord/checks/types.pyi deleted file mode 100644 index 5e75aaa..0000000 --- a/fizzbuzz/discord/checks/types.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from collections.abc import Callable -from typing import Any, Final, TypeAlias, TypeVar - -__author__: Final[str] -__license__: Final[str] - -T = TypeVar("T") - -CheckT: TypeAlias = Callable[[T], T] -Check: TypeAlias = CheckT[Any] diff --git a/fizzbuzz/discord/extensions/public/color/color_tools.py b/fizzbuzz/discord/extensions/public/color/color_tools.py index f15740a..f08affd 100644 --- a/fizzbuzz/discord/extensions/public/color/color_tools.py +++ b/fizzbuzz/discord/extensions/public/color/color_tools.py @@ -13,6 +13,24 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = [ + "CSS_BLUES", + "CSS_BROWNS", + "CSS_GRAYS", + "CSS_GREENS", + "CSS_ORANGES", + "CSS_PINKS", + "CSS_PURPLES", + "CSS_REDS", + "CSS_WHITES", + "CSS_YELLOWS", + "HEX_TO_CSS_NAME", + "Color3", + "ColorParseError", + "generate_color_image", + "validate_hex", + "validate_rgb", +] _RealNumber = int | float diff --git a/fizzbuzz/discord/extensions/public/color/color_tools.pyi b/fizzbuzz/discord/extensions/public/color/color_tools.pyi deleted file mode 100644 index ce0510c..0000000 --- a/fizzbuzz/discord/extensions/public/color/color_tools.pyi +++ /dev/null @@ -1,60 +0,0 @@ -from io import BytesIO -from typing import Final - -import discord - -__author__: Final[str] -__license__: Final[str] - -CSS_COLOR_NAME_TO_HEX: Final[dict[str, str]] - -CSS_REDS: Final[dict[str, str]] -CSS_PINKS: Final[dict[str, str]] -CSS_ORANGES: Final[dict[str, str]] -CSS_YELLOWS: Final[dict[str, str]] -CSS_PURPLES: Final[dict[str, str]] -CSS_GREENS: Final[dict[str, str]] -CSS_BLUES: Final[dict[str, str]] -CSS_BROWNS: Final[dict[str, str]] -CSS_WHITES: Final[dict[str, str]] -CSS_GRAYS: Final[dict[str, str]] - -HEX_TO_CSS_NAME: Final[dict[str, str]] - -class ColorParseError(ValueError): - def __init__(self, message: str | None = None) -> None: ... - -class Color3: - def __init__(self, r: int, g: int, b: int, /) -> None: ... - def invert(self, /) -> Color3: ... - def lerp(self, other: Color3, t: float, /) -> Color3: ... - def relative_luminance(self) -> float: ... - def lighten(self, percent: float, /) -> Color3: ... - def darken(self, percent: float, /) -> Color3: ... - @classmethod - def random(cls, /) -> Color3: ... - @classmethod - def from_discord_color(cls, color: discord.Color, /) -> Color3: ... - @classmethod - def from_css_name(cls, name: str, /) -> Color3: ... - @classmethod - def from_hex6(cls, hex6: str, /) -> Color3: ... - @classmethod - def from_hsl(cls, h: float, s: float, l: float, /) -> Color3: ... - @classmethod - def from_int(cls, integer: int, /) -> Color3: ... - def as_discord_color(self) -> discord.Color: ... - def as_css_color(self) -> str | None: ... - def as_rgb(self) -> tuple[int, int, int]: ... - def as_hex6(self, *, hashtag: bool = False) -> str: ... - def as_hsl(self) -> tuple[float, float, float]: ... - def as_int(self) -> int: ... - def __repr__(self) -> str: ... - def __eq__(self, other: object) -> bool: ... - def __hash__(self) -> int: ... - -def validate_rgb(r: int, g: int, b: int, /) -> bool: ... -def validate_hex(hex6: str, /) -> bool: ... -def generate_color_image( - color: Color3, /, *, size: tuple[int, int] = (100, 100) -) -> BytesIO: ... diff --git a/fizzbuzz/discord/extensions/public/color/color_ui.py b/fizzbuzz/discord/extensions/public/color/color_ui.py index bcb9f2f..01cb500 100644 --- a/fizzbuzz/discord/extensions/public/color/color_ui.py +++ b/fizzbuzz/discord/extensions/public/color/color_ui.py @@ -21,6 +21,15 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = [ + "ColorView", + "DarkenModal", + "LightenModal", + "build_color_embed", + "get_color_role_name", + "update_color_role", +] + def build_color_embed( *, title: str, description: str, color: Color3 diff --git a/fizzbuzz/discord/extensions/public/color/color_ui.pyi b/fizzbuzz/discord/extensions/public/color/color_ui.pyi deleted file mode 100644 index 5ca7835..0000000 --- a/fizzbuzz/discord/extensions/public/color/color_ui.pyi +++ /dev/null @@ -1,74 +0,0 @@ -from __future__ import annotations - -import logging -from typing import Final - -import discord - -from ....views import RestrictedModal, RestrictedView -from .color_tools import Color3 - -__author__: Final[str] -__license__: Final[str] - -def build_color_embed( - *, title: str, description: str, color: Color3 -) -> tuple[discord.Embed, list[discord.File]]: ... -def get_color_role_name(member: discord.Member, /) -> str: ... -async def update_color_role( - member: discord.Member, - guild: discord.Guild, - color: discord.Color, - color2: discord.Color | None, - color3: discord.Color | None, - color_repr: str, - interaction: discord.Interaction, - logger: logging.Logger, -) -> None: ... - -class LightenModal(RestrictedModal["ColorView"]): - amount: Final[discord.ui.TextInput[LightenModal]] - def __init__(self, view: ColorView) -> None: ... - async def on_submit(self, interaction: discord.Interaction, /) -> None: ... - -class DarkenModal(RestrictedModal["ColorView"]): - amount: Final[discord.ui.TextInput[DarkenModal]] - def __init__(self, view: ColorView) -> None: ... - async def on_submit(self, interaction: discord.Interaction, /) -> None: ... - -class ColorView(RestrictedView): - def __init__( - self, - user: discord.abc.User, - /, - *, - color: Color3, - timeout: float | None = 60.0, - in_server: bool, - ) -> None: ... - @discord.ui.button(label="Invert", style=discord.ButtonStyle.primary, row=0) - async def invert_button( - self, interaction: discord.Interaction, _button: discord.ui.Button[ColorView] - ) -> None: ... - @discord.ui.button(label="Lighten", style=discord.ButtonStyle.primary, row=1) - async def lighten_button( - self, interaction: discord.Interaction, _button: discord.ui.Button[ColorView] - ) -> None: ... - @discord.ui.button(label="Darken", style=discord.ButtonStyle.primary, row=1) - async def darken_button( - self, interaction: discord.Interaction, _button: discord.ui.Button[ColorView] - ) -> None: ... - @discord.ui.button( - label="Set As Color Role", - style=discord.ButtonStyle.primary, - row=2, - disabled=True, - custom_id="color:set_role", - ) - async def set_as_role( - self, interaction: discord.Interaction, _button: discord.ui.Button[ColorView] - ) -> None: ... - @discord.ui.button(label="Revert", style=discord.ButtonStyle.secondary, row=2) - async def revert_button( - self, interaction: discord.Interaction, _button: discord.ui.Button[ColorView] - ) -> None: ... diff --git a/fizzbuzz/discord/extensions/public/fun/animal_tools.py b/fizzbuzz/discord/extensions/public/fun/animal_tools.py index 3e7c56f..f250c0b 100644 --- a/fizzbuzz/discord/extensions/public/fun/animal_tools.py +++ b/fizzbuzz/discord/extensions/public/fun/animal_tools.py @@ -17,6 +17,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["AnimalCarouselView", "build_animal_embed"] + _MAX_FILENAME_LEN = 40 # maximum length of an attachment filename diff --git a/fizzbuzz/discord/extensions/public/fun/animal_tools.pyi b/fizzbuzz/discord/extensions/public/fun/animal_tools.pyi deleted file mode 100644 index 58aa9be..0000000 --- a/fizzbuzz/discord/extensions/public/fun/animal_tools.pyi +++ /dev/null @@ -1,32 +0,0 @@ -from typing import Final - -import discord - -from ....views import CarouselView -from .inaturalist_api import ( - AnimalResult, -) - -__author__: Final[str] -__license__: Final[str] - -MAX_FILENAME_LEN: Final[int] - -def safe_filename(filename: str) -> str: ... -async def build_animal_embed( - result: AnimalResult, - description: str, - index: int, - cached_bytes: bytes | None = None, -) -> tuple[discord.Embed, list[discord.File]]: ... - -class AnimalCarouselView(CarouselView): - def __init__( - self, - *, - user: discord.abc.User, - data: AnimalResult, - embed_description: str, - timeout: float | None = 180.0, - ) -> None: ... - async def render(self, interaction: discord.Interaction) -> None: ... diff --git a/fizzbuzz/discord/extensions/public/fun/inaturalist_api.py b/fizzbuzz/discord/extensions/public/fun/inaturalist_api.py index d278a7b..2340d5f 100644 --- a/fizzbuzz/discord/extensions/public/fun/inaturalist_api.py +++ b/fizzbuzz/discord/extensions/public/fun/inaturalist_api.py @@ -14,6 +14,13 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = [ + "AnimalResult", + "ImageFetchAmount", + "animal_kind_autocomplete", + "fetch_inat_animal", +] + ImageFetchAmount = Literal[1, 2, 3, 4, 5] _INAT_TAXA_URL = "https://api.inaturalist.org/v1/taxa" diff --git a/fizzbuzz/discord/extensions/public/fun/inaturalist_api.pyi b/fizzbuzz/discord/extensions/public/fun/inaturalist_api.pyi deleted file mode 100644 index 981905f..0000000 --- a/fizzbuzz/discord/extensions/public/fun/inaturalist_api.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from dataclasses import dataclass -from typing import Final, Literal, TypeAlias - -import discord -from discord import app_commands - -__author__: Final[str] -__license__: Final[str] - -ImageFetchAmount: TypeAlias = Literal[1, 2, 3, 4, 5] - -@dataclass(frozen=True) -class AnimalResult: - kind: str - image_url: str - images: list[str] - fact: str | None = None - source: str | None = None - -async def fetch_inat_animal(kind: str, /, *, images: int = 1) -> AnimalResult: ... -async def animal_kind_autocomplete( - _interaction: discord.Interaction, - current: str, -) -> list[app_commands.Choice[str]]: ... diff --git a/fizzbuzz/discord/extensions/public/help/__init__.pyi b/fizzbuzz/discord/extensions/public/help/__init__.pyi deleted file mode 100644 index 5136cf9..0000000 --- a/fizzbuzz/discord/extensions/public/help/__init__.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from .help_registrator import ( - Category as Category, - HasHelpInfo as HasHelpInfo, - HelpInfo as HelpInfo, - get_help_info as get_help_info, - help_info as help_info, -) diff --git a/fizzbuzz/discord/extensions/public/help/help_registrator.py b/fizzbuzz/discord/extensions/public/help/help_registrator.py index 0290639..b00720f 100644 --- a/fizzbuzz/discord/extensions/public/help/help_registrator.py +++ b/fizzbuzz/discord/extensions/public/help/help_registrator.py @@ -24,6 +24,18 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = [ + "COMMAND_CATEGORIES", + "AppCommand", + "Category", + "HasHelpInfo", + "HelpInfo", + "build_command_info_str", + "build_help_homepage", + "get_help_info", + "help_info", +] + P = ParamSpec("P") T_co = TypeVar("T_co", covariant=True) diff --git a/fizzbuzz/discord/extensions/public/help/help_registrator.pyi b/fizzbuzz/discord/extensions/public/help/help_registrator.pyi deleted file mode 100644 index 6487c4d..0000000 --- a/fizzbuzz/discord/extensions/public/help/help_registrator.pyi +++ /dev/null @@ -1,56 +0,0 @@ -from __future__ import annotations - -from collections.abc import Callable -from dataclasses import dataclass -from typing import ( - Any, - Final, - Literal, - ParamSpec, - Protocol, - TypeAlias, - TypeVar, - runtime_checkable, -) - -import discord -from discord import app_commands - -__author__: Final[str] -__license__: Final[str] - -P = ParamSpec("P") -T_co = TypeVar("T_co", covariant=True) - -AppCommand: TypeAlias = ( - app_commands.Command[Any, ..., Any] | app_commands.Group | app_commands.ContextMenu -) -Category: TypeAlias = Literal["Color", "Fun", "Help", "Utilities", "Guild Settings"] - -COMMAND_CATEGORIES: Final[tuple[Category]] - -@runtime_checkable -class HasHelpInfo(Protocol[P, T_co]): - __help_info__: HelpInfo - def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T_co: ... - -@dataclass(frozen=True, slots=True) -class HelpInfo: - category: Category - summary: str | None - params: dict[str, str | None] - examples: tuple[str, ...] | None - notes: tuple[str, ...] | None - -def build_command_info_str(command: AppCommand, help_info: HelpInfo, /) -> str: ... -def build_help_homepage() -> tuple[discord.Embed, discord.File]: ... -def help_info( - category: Category, - /, - summary: str | None = None, - *, - params: dict[str, str | None] | None = None, - examples: tuple[str, ...] | None = None, - notes: tuple[str, ...] | None = None, -) -> Callable[[Callable[P, T_co]], HasHelpInfo[P, T_co]]: ... -def get_help_info(obj: object, /) -> HelpInfo | None: ... diff --git a/fizzbuzz/discord/info.py b/fizzbuzz/discord/info.py index 3e185b9..db61f8f 100644 --- a/fizzbuzz/discord/info.py +++ b/fizzbuzz/discord/info.py @@ -12,6 +12,18 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = [ + "BOT_APP_ID", + "DEPENDENCIES", + "DISCORD_DOT_PY_VERSION", + "HOST", + "PROTOTYPE_BOT_APP_ID", + "PYTHON_VERSION", + "START_TIME", + "VERSION", + "get_uptime", +] + _SECONDS_PER_HOUR = 3600 _SECONDS_PER_MINUTE = 60 _HOURS_PER_DAY = 24 diff --git a/fizzbuzz/discord/info.pyi b/fizzbuzz/discord/info.pyi deleted file mode 100644 index 6cbeac1..0000000 --- a/fizzbuzz/discord/info.pyi +++ /dev/null @@ -1,18 +0,0 @@ -"""Information about FizzBuzz and its run conditions.""" - -from datetime import datetime -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -START_TIME: Final[datetime] -HOST: Final[str] -PYTHON_VERSION: Final[str] -DISCORD_DOT_PY_VERSION: Final[str] -BOT_APP_ID: Final[int] -PROTOTYPE_BOT_APP_ID: Final[int] -VERSION: Final[str] -DEPENDENCIES: Final[list[str]] - -def get_uptime() -> str: ... diff --git a/fizzbuzz/discord/interaction/__init__.pyi b/fizzbuzz/discord/interaction/__init__.pyi deleted file mode 100644 index e32e0a1..0000000 --- a/fizzbuzz/discord/interaction/__init__.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from .responses import ( - build_response_embed as build_response_embed, - report as report, - safe_edit as safe_edit, - safe_send as safe_send, -) -from .role_tools import ( - add_new_role_to_member as add_new_role_to_member, - find_role as find_role, - promote_role as promote_role, - update_role_color as update_role_color, -) diff --git a/fizzbuzz/discord/interaction/responses.py b/fizzbuzz/discord/interaction/responses.py index b63ceb9..3c8df67 100644 --- a/fizzbuzz/discord/interaction/responses.py +++ b/fizzbuzz/discord/interaction/responses.py @@ -14,6 +14,14 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = [ + "GuildInteractionData", + "InvalidImageFormatError", + "build_response_embed", + "report", + "safe_edit", + "safe_send", +] _file_cache: dict[str, bytes] = {} diff --git a/fizzbuzz/discord/interaction/responses.pyi b/fizzbuzz/discord/interaction/responses.pyi deleted file mode 100644 index 702febf..0000000 --- a/fizzbuzz/discord/interaction/responses.pyi +++ /dev/null @@ -1,61 +0,0 @@ -from collections.abc import Sequence -from dataclasses import dataclass -from typing import Final - -import discord -from discord.utils import MISSING - -from ..ui import DEFAULT_EMBED_COLOR -from ..ui.emoji import Status - -__author__: Final[str] -__license__: Final[str] - -@dataclass(frozen=True) -class GuildInteractionData: - member: discord.Member - guild: discord.Guild - -class InvalidImageFormatError(ValueError): ... - -async def safe_send( - interaction: discord.Interaction, - /, - content: str | None = None, - *, - ephemeral: bool = True, - embed: discord.Embed = MISSING, - embeds: Sequence[discord.Embed] = MISSING, - view: discord.ui.View = MISSING, - file: discord.File = MISSING, - files: Sequence[discord.File] = MISSING, - delete_after: float | None = None, -) -> discord.Message | None: ... -async def safe_edit( - interaction: discord.Interaction, - /, - *, - content: str | None = None, - embed: discord.Embed = MISSING, - embeds: Sequence[discord.Embed] = MISSING, - attachments: Sequence[discord.Attachment | discord.File] = MISSING, - view: discord.ui.View = MISSING, - allowed_mentions: discord.AllowedMentions = MISSING, -) -> None: ... -async def report( - interaction: discord.Interaction, - message: str, - status: Status, - /, - *, - ephemeral: bool = True, -) -> None: ... -def build_response_embed( - *, - title: str | None = None, - description: str | None = None, - color: int | discord.Color | None = DEFAULT_EMBED_COLOR, - author: str | None = "FizzBuzz", - icon_filepath: str = "static/branding/fizzbuzz_icon.jpg", - icon_filename: str = "image.png", -) -> tuple[discord.Embed, discord.File]: ... diff --git a/fizzbuzz/discord/interaction/role_tools.py b/fizzbuzz/discord/interaction/role_tools.py index 931125d..f526dc8 100644 --- a/fizzbuzz/discord/interaction/role_tools.py +++ b/fizzbuzz/discord/interaction/role_tools.py @@ -9,6 +9,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["add_new_role_to_member", "find_role", "promote_role", "update_role_color"] + async def promote_role(role: discord.Role, /) -> None: """Promote the role as high as possible. diff --git a/fizzbuzz/discord/interaction/role_tools.pyi b/fizzbuzz/discord/interaction/role_tools.pyi deleted file mode 100644 index 35f7e79..0000000 --- a/fizzbuzz/discord/interaction/role_tools.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Final - -import discord - -__author__: Final[str] -__license__: Final[str] - -async def promote_role(role: discord.Role, /) -> None: ... -def find_role(role: str, guild: discord.Guild, /) -> discord.Role | None: ... -async def update_role_color( - role: discord.Role, - color: discord.Color, - secondary_color: discord.Color | None = None, - tertiary_color: discord.Color | None = None, - /, -) -> None: ... -async def add_new_role_to_member( - member: discord.Member, name: str, color: discord.Color, / -) -> None: ... diff --git a/fizzbuzz/discord/ui/__init__.pyi b/fizzbuzz/discord/ui/__init__.pyi deleted file mode 100644 index 13d628f..0000000 --- a/fizzbuzz/discord/ui/__init__.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from . import emoji as emoji -from .constants import ( - COIN_HEADS_COLOR as COIN_HEADS_COLOR, - COIN_TAILS_COLOR as COIN_TAILS_COLOR, - DEFAULT_EMBED_COLOR as DEFAULT_EMBED_COLOR, -) diff --git a/fizzbuzz/discord/ui/constants.py b/fizzbuzz/discord/ui/constants.py index 1772571..4d63bfb 100644 --- a/fizzbuzz/discord/ui/constants.py +++ b/fizzbuzz/discord/ui/constants.py @@ -5,6 +5,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["COIN_HEADS_COLOR", "COIN_TAILS_COLOR", "DEFAULT_EMBED_COLOR"] + DEFAULT_EMBED_COLOR = discord.Color(int("c34b0f", 16)) """The default color for FizzBuzz's embeds.""" diff --git a/fizzbuzz/discord/ui/constants.pyi b/fizzbuzz/discord/ui/constants.pyi deleted file mode 100644 index 694ba70..0000000 --- a/fizzbuzz/discord/ui/constants.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from typing import Final - -import discord - -__author__: Final[str] -__license__: Final[str] - -DEFAULT_EMBED_COLOR: Final[discord.Color] -COIN_HEADS_COLOR: Final[discord.Color] -COIN_TAILS_COLOR: Final[discord.Color] diff --git a/fizzbuzz/discord/ui/emoji.py b/fizzbuzz/discord/ui/emoji.py index d5abf09..f2e985d 100644 --- a/fizzbuzz/discord/ui/emoji.py +++ b/fizzbuzz/discord/ui/emoji.py @@ -5,6 +5,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["Status", "Visual"] + class Status(StrEnum): """A class of status-related emojis.""" diff --git a/fizzbuzz/discord/ui/emoji.pyi b/fizzbuzz/discord/ui/emoji.pyi deleted file mode 100644 index c85d056..0000000 --- a/fizzbuzz/discord/ui/emoji.pyi +++ /dev/null @@ -1,35 +0,0 @@ -from enum import StrEnum -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -class Status(StrEnum): - SUCCESS = "✅" - FAILURE = "❌" - CANCELLED = "🛑" - WARNING = "⚠️" - ERROR = "⁉️" - -class Visual(StrEnum): - ART_PALETTE = "🎨" - STOPWATCH = "⏱️" - CHART = "📊" - COIN = "🪙" - PHOTO = "🖼️" - CAT = "🐱" - COMPUTER = "🖥️" - PEOPLE_SYMBOL = "🧑‍🧑‍🧒‍🧒" - QUESTION_MARK = "❔" - HAMMER = "🔨" - ALARM_CLOCK = "⏰" - ALERT = "❗" - RANDOM = "🎲" - PAWS = "🐾" - NEXT = "▶️" - PREVIOUS = "◀️" - FAST_FORWARD = "⏩" - REWIND = "⏪" - ASTERISK = "*️⃣" - HANDSHAKE = "🤝" - SODA = "🥤" diff --git a/fizzbuzz/discord/views/__init__.pyi b/fizzbuzz/discord/views/__init__.pyi deleted file mode 100644 index be5d8c4..0000000 --- a/fizzbuzz/discord/views/__init__.pyi +++ /dev/null @@ -1,12 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from .carousel_view import CarouselView as CarouselView -from .restricted_view import ( - RestrictedModal as RestrictedModal, - RestrictedView as RestrictedView, -) diff --git a/fizzbuzz/discord/views/carousel_view.py b/fizzbuzz/discord/views/carousel_view.py index 3aa2ecc..602d5c4 100644 --- a/fizzbuzz/discord/views/carousel_view.py +++ b/fizzbuzz/discord/views/carousel_view.py @@ -13,6 +13,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["CarouselView", "PageJumpModal"] + class PageJumpModal(RestrictedModal["CarouselView"]): """A modal that takes a page number to jump to in a CarouselView.""" diff --git a/fizzbuzz/discord/views/carousel_view.pyi b/fizzbuzz/discord/views/carousel_view.pyi deleted file mode 100644 index 1983286..0000000 --- a/fizzbuzz/discord/views/carousel_view.pyi +++ /dev/null @@ -1,73 +0,0 @@ -from __future__ import annotations - -from abc import abstractmethod -from typing import Final - -import discord - -from ..ui.emoji import Visual -from .restricted_view import RestrictedModal, RestrictedView - -__author__: Final[str] -__license__: Final[str] - -class PageJumpModal(RestrictedModal["CarouselView"]): - page: discord.ui.TextInput[PageJumpModal] - def __init__(self, view: CarouselView) -> None: ... - async def on_submit(self, interaction: discord.Interaction, /) -> None: ... - -class CarouselView(RestrictedView): - def __init__( - self, - pages: int, - *, - user: discord.abc.User, - timeout: float | None = 180.0, - jump_button: bool = True, - ) -> None: ... - @abstractmethod - async def render(self, interaction: discord.Interaction, /) -> None: ... - def sync_buttons(self) -> None: ... - @discord.ui.button( - label=f"{Visual.PREVIOUS} Previous", style=discord.ButtonStyle.primary, row=0 - ) - async def previous_button( - self, interaction: discord.Interaction, _button: discord.ui.Button[CarouselView] - ) -> None: ... - @discord.ui.button( - label=f"{Visual.NEXT} Next", style=discord.ButtonStyle.primary, row=0 - ) - async def next_button( - self, - interaction: discord.Interaction, - _button: discord.ui.Button[CarouselView], - ) -> None: ... - @discord.ui.button( - label=f"{Visual.REWIND} First", style=discord.ButtonStyle.primary, row=1 - ) - async def first_button( - self, interaction: discord.Interaction, _button: discord.ui.Button[CarouselView] - ) -> None: ... - @discord.ui.button( - label=f"{Visual.FAST_FORWARD} Last", style=discord.ButtonStyle.primary, row=1 - ) - async def last_button( - self, - interaction: discord.Interaction, - _button: discord.ui.Button[CarouselView], - ) -> None: ... - @discord.ui.button( - label=f"{Visual.ASTERISK} Jump to page", - style=discord.ButtonStyle.primary, - row=2, - disabled=True, - ) - async def jump_to_page( - self, interaction: discord.Interaction, _button: discord.ui.Button[CarouselView] - ) -> None: ... - @property - def pages(self) -> int: ... - @property - def index(self) -> int: ... - @index.setter - def index(self, new_index: int) -> None: ... diff --git a/fizzbuzz/discord/views/restricted_view.py b/fizzbuzz/discord/views/restricted_view.py index 1c44154..0d56726 100644 --- a/fizzbuzz/discord/views/restricted_view.py +++ b/fizzbuzz/discord/views/restricted_view.py @@ -14,6 +14,8 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = ["Check", "RestrictedModal", "RestrictedView"] + RV = TypeVar("RV", bound="RestrictedView") Check = Callable[[discord.Interaction], bool] diff --git a/fizzbuzz/discord/views/restricted_view.pyi b/fizzbuzz/discord/views/restricted_view.pyi deleted file mode 100644 index 5f0cad6..0000000 --- a/fizzbuzz/discord/views/restricted_view.pyi +++ /dev/null @@ -1,46 +0,0 @@ -from abc import ABC -from collections.abc import Callable, Sequence -from typing import Final, Generic, TypeVar - -import discord -from discord.utils import MISSING - -from ..ui.emoji import Status - -__author__: Final[str] -__license__: Final[str] - -RV = TypeVar("RV", bound="RestrictedView") - -Check = Callable[[discord.Interaction], bool] - -class RestrictedView(ABC, discord.ui.View): - def __init__( - self, - *, - user: discord.abc.User, - timeout: float | None = 60.0, - deny_message: str = "You can't interact with another user's embed!", - deny_status: Status = Status.FAILURE, - ephemeral: bool = True, - allow: Check | None = None, - ) -> None: ... - async def send( - self, - interaction: discord.Interaction, - /, - *, - content: str | None = None, - ephemeral: bool = True, - embed: discord.Embed = MISSING, - embeds: Sequence[discord.Embed] = MISSING, - files: Sequence[discord.File] = MISSING, - delete_after: float | None = None, - ) -> None: ... - async def interaction_check(self, interaction: discord.Interaction, /) -> bool: ... - -class RestrictedModal(Generic[RV], ABC, discord.ui.Modal): - def __init__(self, view: RV, /, *, title: str) -> None: ... - async def interaction_check(self, interaction: discord.Interaction, /) -> bool: ... - @property - def view(self) -> RV: ... diff --git a/fizzbuzz/util/__init__.pyi b/fizzbuzz/util/__init__.pyi deleted file mode 100644 index d842189..0000000 --- a/fizzbuzz/util/__init__.pyi +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Final - -__author__: Final[str] -__license__: Final[str] - -__all__: Final[list[str]] - -from . import ( - http as http, - log_handler as log_handler, -) diff --git a/fizzbuzz/util/http.py b/fizzbuzz/util/http.py index 4a6abd3..f613d9f 100644 --- a/fizzbuzz/util/http.py +++ b/fizzbuzz/util/http.py @@ -17,6 +17,14 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = [ + "STATUS_OK", + "ApiError", + "ApiJsonResponse", + "http_get_bytes", + "http_get_json", +] + _DEFAULT_USER_AGENT = os.getenv( "HTTP_USER_AGENT", # clip leading 'v' from version diff --git a/fizzbuzz/util/http.pyi b/fizzbuzz/util/http.pyi deleted file mode 100644 index fe59fb0..0000000 --- a/fizzbuzz/util/http.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from collections.abc import Mapping -from dataclasses import dataclass -from typing import Any, Final, Literal - -__author__: Final[str] -__license__: Final[str] - -STATUS_OK: Literal[200] - -class ApiError(RuntimeError): ... - -@dataclass(frozen=True) -class ApiJsonResponse: - status_code: int - json: Any - url: str - -async def http_get_json( - url: str, - *, - headers: Mapping[str, str] | None = None, - params: Mapping[str, Any] | None = None, - timeout: float = 10.0, -) -> ApiJsonResponse: ... -async def http_get_bytes( - url: str, *, headers: Mapping[str, str] | None = None, timeout: float = 10.0 -) -> bytes: ... diff --git a/fizzbuzz/util/log_handler.py b/fizzbuzz/util/log_handler.py index 6430979..69ec5ec 100644 --- a/fizzbuzz/util/log_handler.py +++ b/fizzbuzz/util/log_handler.py @@ -9,6 +9,15 @@ __author__ = "Gavin Borne" __license__ = "MIT" +__all__ = [ + "LOG_FILE", + "AnsiColor", + "AnsiColorFormatter", + "cog_setup_log_msg", + "config_logging", + "log_app_command", +] + LOG_FILE = "logs.log" # TODO: make an env var? """The file to log to.""" diff --git a/fizzbuzz/util/log_handler.pyi b/fizzbuzz/util/log_handler.pyi deleted file mode 100644 index 6b92cca..0000000 --- a/fizzbuzz/util/log_handler.pyi +++ /dev/null @@ -1,35 +0,0 @@ -# pylint:disable=all -from enum import StrEnum -import logging -from typing import Final - -import discord -from discord.ext import commands - -__author__: Final[str] -__license__: Final[str] - -LOG_FILE: Final[str] - -class AnsiColor(StrEnum): - DEBUG = "\x1b[32m" - INFO = "\x1b[34m" - WARNING = "\x1b[33m" - ERROR = "\x1b[31m" - CRITICAL = "\x1b[31m\x1b[1m" - RESET = "\x1b[0m" - -class AnsiColorFormatter(logging.Formatter): - def format(self, record: logging.LogRecord) -> str: ... - -def config_logging( - logfile: str, - *, - console_logging: bool, - colored_logs: bool, - debug: bool, - fmt: str = ..., - date_fmt: str = ..., -) -> None: ... -def cog_setup_log_msg(cog_name: str, bot: commands.Bot, /) -> str: ... -def log_app_command(interaction: discord.Interaction, /) -> None: ...