Skip to content

Commit

Permalink
Merge pull request #3 from sushi-chaaaan/fix/type-checking
Browse files Browse the repository at this point in the history
fix: use relative import
  • Loading branch information
sushichan044 authored Oct 6, 2023
2 parents d8cab35 + 5e0bdb7 commit ead3b42
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
15 changes: 7 additions & 8 deletions src/ductile/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

import discord

from ductile import State
from ductile.internal import _InternalView

from .type import ViewObjectDictWithAttachment, ViewObjectDictWithFiles
from ..internal import _InternalView # noqa: TID252
from ..state import State # noqa: TID252

if TYPE_CHECKING:
from ductile import View, ViewObject
from ..view import View, ViewObject # noqa: TID252
from .type import ViewObjectDictWithAttachment, ViewObjectDictWithFiles


class ViewResult(NamedTuple):
Expand Down Expand Up @@ -87,17 +86,17 @@ def _get_all_state_in_view(self) -> Generator[tuple[str, State[Any]], None, None
yield k, v

@overload
def _process_view_for_discord(self, mode: Literal["attachment"]) -> ViewObjectDictWithAttachment:
def _process_view_for_discord(self, mode: Literal["attachment"]) -> "ViewObjectDictWithAttachment":
...

@overload
def _process_view_for_discord(self, mode: Literal["files"]) -> ViewObjectDictWithFiles:
def _process_view_for_discord(self, mode: Literal["files"]) -> "ViewObjectDictWithFiles":
...

def _process_view_for_discord(
self,
mode: Literal["attachment", "files"],
) -> ViewObjectDictWithAttachment | ViewObjectDictWithFiles:
) -> "ViewObjectDictWithAttachment | ViewObjectDictWithFiles":
"""
_process_view_for_discord is a helper function to process the view for Discord.
Expand Down
2 changes: 1 addition & 1 deletion src/ductile/controller/interaction_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .controller import ViewController

if TYPE_CHECKING:
from ductile import View
from ..view import View # noqa: TID252


class InteractionController(ViewController):
Expand Down
2 changes: 1 addition & 1 deletion src/ductile/controller/messageable_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .controller import ViewController

if TYPE_CHECKING:
from ductile import View
from ..view import View # noqa: TID252


class MessageableController(ViewController):
Expand Down
9 changes: 6 additions & 3 deletions src/ductile/internal/view.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from typing import TYPE_CHECKING

from discord import ui
from discord.interactions import Interaction
from discord.ui.item import Item

from ductile.types import ViewErrorHandler, ViewTimeoutHandler
if TYPE_CHECKING:
from ..types import ViewErrorHandler, ViewTimeoutHandler # noqa: TID252

__all__ = [
"_InternalView",
Expand All @@ -14,8 +17,8 @@ def __init__(
self,
*,
timeout: float | None = 180,
on_error: ViewErrorHandler | None = None,
on_timeout: ViewTimeoutHandler | None = None,
on_error: "ViewErrorHandler" | None = None,
on_timeout: "ViewTimeoutHandler" | None = None,
) -> None:
super().__init__(timeout=timeout)
self.__on_error = on_error
Expand Down
4 changes: 2 additions & 2 deletions src/ductile/ui/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from discord import Emoji, PartialEmoji, ui
from discord.interactions import Interaction

from ductile.utils import call_any_function
from ..utils import call_any_function # noqa: TID252

if TYPE_CHECKING:
from ductile.types import InteractionCallback
from ..types import InteractionCallback # noqa: TID252


class _ButtonStyleRequired(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion src/ductile/ui/modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from discord import Interaction, TextStyle, ui

if TYPE_CHECKING:
from ductile.types import ModalCallback
from ..types import ModalCallback # noqa: TID252


class TextInputStyle(TypedDict, total=False):
Expand Down
4 changes: 2 additions & 2 deletions src/ductile/ui/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from discord.enums import ChannelType
from pydantic import BaseModel, ConfigDict, Field

from ductile.utils import call_any_function
from ..utils import call_any_function # noqa: TID252

if TYPE_CHECKING:
from ductile.types import (
from ..types import ( # noqa: TID252
ChannelSelectCallback,
MentionableSelectCallback,
RoleSelectCallback,
Expand Down

0 comments on commit ead3b42

Please sign in to comment.