Skip to content

Commit

Permalink
Fix type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfies committed Feb 12, 2024
1 parent 7fdb4e7 commit b6beffd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
4 changes: 3 additions & 1 deletion discord/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ def __len__(self) -> int:
return len(self._ids)

def __contains__(self, item: Union[int, Snowflake], /) -> bool:
return getattr(item, 'id', item) in self._ids
if isinstance(item, int):
return item in self._ids
return item.id in self._ids

def __iter__(self) -> Iterator[int]:
return iter(self._ids)
Expand Down
5 changes: 2 additions & 3 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
from .types.embed import EmbedType
from .types.integration import IntegrationType
from .types.message import MessageSearchAuthorType, MessageSearchHasType
from .types.snowflake import SnowflakeList, Snowflake as _Snowflake
from .types.snowflake import SnowflakeList
from .types.widget import EditWidgetSettings
from .types.audit_log import AuditLogEvent
from .types.oauth2 import OAuth2Guild as OAuth2GuildPayload
Expand Down Expand Up @@ -5153,7 +5153,7 @@ async def subscribe(
.. versionadded:: 2.1
Attributes
Parameters
-----------
typing: :class:`bool`
Whether to receive typing events.
Expand All @@ -5168,7 +5168,6 @@ async def subscribe(
member_updates: :class:`bool`
Whether to receive member update events.
"""
state = self._state
await self._state.subscribe_guild(
self, typing=typing, activities=activities, threads=threads, member_updates=member_updates
)
Expand Down
3 changes: 1 addition & 2 deletions discord/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ async def _checked_add(self, changes: gw.BulkGuildSubscribePayload, /) -> None:
# If it is, we need to flush the old payload and start a new one
# If there isn't an old payload and the new payload is larger, this is impossible
EMPTY: Any = {}
new_payload = self._pending.copy()
new_payload: gw.BulkGuildSubscribePayload = self._pending.copy()
for guild_id, subscriptions in changes.items():
old = new_payload.get(guild_id, EMPTY)
new_payload[guild_id] = {**old, **subscriptions}

Check failure on line 645 in discord/state.py

View workflow job for this annotation

GitHub Actions / check

Argument of type "dict[str, object]" cannot be assigned to parameter "__value" of type "BaseGuildSubscribePayload" in function "__setitem__"   "dict[str, object]" is incompatible with "BaseGuildSubscribePayload" (reportGeneralTypeIssues)
Expand Down Expand Up @@ -3443,7 +3443,6 @@ def parse_interaction_modal_create(self, data: gw.InteractionModalCreateEvent) -

# Silence "unknown event" warnings for events parsed elsewhere
parse_nothing = lambda *_: None
parse_thread_member_list_update = parse_nothing # Grabbed directly in Thread.fetch_members
# parse_guild_application_commands_update = parse_nothing # Grabbed directly in command iterators

def _get_reaction_user(self, channel: MessageableChannel, user_id: int) -> Optional[Union[User, Member]]:
Expand Down
1 change: 0 additions & 1 deletion discord/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
from typing_extensions import Self

from .types.gateway import ThreadMemberListUpdateEvent
from .types.member import MemberWithUser
from .types.threads import (
BaseThreadMember as BaseThreadMemberPayload,
Thread as ThreadPayload,
Expand Down
4 changes: 2 additions & 2 deletions discord/types/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from .snowflake import Snowflake
from .sticker import GuildSticker
from .subscriptions import PremiumGuildSubscriptionSlot
from .threads import Thread, ThreadMember, ThreadMemberData
from .threads import BaseThreadMember, Thread, ThreadMember
from .user import (
Connection,
FriendSuggestion,
Expand Down Expand Up @@ -318,7 +318,7 @@ class ThreadMembersUpdate(TypedDict):
class ThreadMemberListUpdateEvent(TypedDict):
guild_id: Snowflake
thread_id: Snowflake
members: List[ThreadMemberData]
members: List[BaseThreadMember]


class GuildMemberAddEvent(MemberWithUser):
Expand Down

0 comments on commit b6beffd

Please sign in to comment.