Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(libraries): use TYPE_CHECKING to resolve import loop in disnake #40

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ build:
- pip install -r requirements.txt
# Poetry setup still seems to fail on readthedocs.
sphinx:
fail_on_warning: true
fail_on_warning: false
46 changes: 26 additions & 20 deletions mafic/__libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from __future__ import annotations

from os import getenv
from typing import Any
from typing import TYPE_CHECKING, Any

from pkg_resources import DistributionNotFound, get_distribution
from pkg_resources import get_distribution # pyright: ignore[reportUnknownVariableType]
from pkg_resources import DistributionNotFound

from .errors import MultipleCompatibleLibraries, NoCompatibleLibraries

Expand Down Expand Up @@ -71,11 +72,13 @@
)
from nextcord.abc import Connectable, GuildChannel
from nextcord.backoff import ExponentialBackoff
from nextcord.types.voice import (
GuildVoiceState as GuildVoiceStatePayload,
VoiceServerUpdate as VoiceServerUpdatePayload,
)
from nextcord.utils import MISSING

if TYPE_CHECKING:
from nextcord.types.voice import (
GuildVoiceState as GuildVoiceStatePayload,
VoiceServerUpdate as VoiceServerUpdatePayload,
)
elif library == "disnake":
from disnake import (
Client,
Expand All @@ -87,17 +90,18 @@
)
from disnake.abc import Connectable, GuildChannel
from disnake.backoff import ExponentialBackoff

if version_info >= (2, 6):
from disnake.types.gateway import (
VoiceServerUpdateEvent as VoiceServerUpdatePayload, # pyright: ignore
)
else:
from disnake.types.voice import (
VoiceServerUpdate as VoiceServerUpdatePayload, # pyright: ignore
)
from disnake.types.voice import GuildVoiceState as GuildVoiceStatePayload
from disnake.utils import MISSING

if TYPE_CHECKING:
if version_info >= (2, 6):
from disnake.types.gateway import (
VoiceServerUpdateEvent as VoiceServerUpdatePayload, # pyright: ignore
)
else:
from disnake.types.voice import (
VoiceServerUpdate as VoiceServerUpdatePayload, # pyright: ignore
)
from disnake.types.voice import GuildVoiceState as GuildVoiceStatePayload
else:
from discord import (
Client,
Expand All @@ -109,12 +113,14 @@
)
from discord.abc import Connectable, GuildChannel
from discord.backoff import ExponentialBackoff
from discord.types.voice import (
GuildVoiceState as GuildVoiceStatePayload,
VoiceServerUpdate as VoiceServerUpdatePayload,
)
from discord.utils import MISSING

if TYPE_CHECKING:
from discord.types.voice import (
GuildVoiceState as GuildVoiceStatePayload,
VoiceServerUpdate as VoiceServerUpdatePayload,
)


try:
from orjson import dumps as _dumps, loads
Expand Down