mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Fix a few more type errors
This commit is contained in:
parent
d01e73fca5
commit
30e7a2e937
@ -1758,7 +1758,7 @@ class HTTPClient:
|
|||||||
'description',
|
'description',
|
||||||
'options',
|
'options',
|
||||||
)
|
)
|
||||||
payload = {k: v for k, v in payload.items() if k in valid_keys} # type: ignore
|
payload = {k: v for k, v in payload.items() if k in valid_keys}
|
||||||
r = Route(
|
r = Route(
|
||||||
'PATCH',
|
'PATCH',
|
||||||
'/applications/{application_id}/commands/{command_id}',
|
'/applications/{application_id}/commands/{command_id}',
|
||||||
@ -1834,7 +1834,7 @@ class HTTPClient:
|
|||||||
'description',
|
'description',
|
||||||
'options',
|
'options',
|
||||||
)
|
)
|
||||||
payload = {k: v for k, v in payload.items() if k in valid_keys} # type: ignore
|
payload = {k: v for k, v in payload.items() if k in valid_keys}
|
||||||
r = Route(
|
r = Route(
|
||||||
'PATCH',
|
'PATCH',
|
||||||
'/applications/{application_id}/guilds/{guild_id}/commands/{command_id}',
|
'/applications/{application_id}/guilds/{guild_id}/commands/{command_id}',
|
||||||
|
@ -215,6 +215,7 @@ class StreamIntegration(Integration):
|
|||||||
@property
|
@property
|
||||||
def role(self) -> Optional[Role]:
|
def role(self) -> Optional[Role]:
|
||||||
"""Optional[:class:`Role`] The role which the integration uses for subscribers."""
|
"""Optional[:class:`Role`] The role which the integration uses for subscribers."""
|
||||||
|
# The key is `int` but `int | None` will return `None` anyway.
|
||||||
return self.guild.get_role(self._role_id) # type: ignore
|
return self.guild.get_role(self._role_id) # type: ignore
|
||||||
|
|
||||||
async def edit(
|
async def edit(
|
||||||
|
@ -124,7 +124,7 @@ class Interaction:
|
|||||||
|
|
||||||
def __init__(self, *, data: InteractionPayload, state: ConnectionState):
|
def __init__(self, *, data: InteractionPayload, state: ConnectionState):
|
||||||
self._state: ConnectionState = state
|
self._state: ConnectionState = state
|
||||||
self._session: ClientSession = state.http._HTTPClient__session
|
self._session: ClientSession = state.http._HTTPClient__session # type: ignore - Mangled attribute for __session
|
||||||
self._original_message: Optional[InteractionMessage] = None
|
self._original_message: Optional[InteractionMessage] = None
|
||||||
self._from_data(data)
|
self._from_data(data)
|
||||||
|
|
||||||
@ -140,6 +140,7 @@ class Interaction:
|
|||||||
|
|
||||||
self.message: Optional[Message]
|
self.message: Optional[Message]
|
||||||
try:
|
try:
|
||||||
|
# The channel and message payloads are mismatched yet handled properly at runtime
|
||||||
self.message = Message(state=self._state, channel=self.channel, data=data['message']) # type: ignore
|
self.message = Message(state=self._state, channel=self.channel, data=data['message']) # type: ignore
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.message = None
|
self.message = None
|
||||||
@ -151,15 +152,16 @@ class Interaction:
|
|||||||
if self.guild_id:
|
if self.guild_id:
|
||||||
guild = self.guild or Object(id=self.guild_id)
|
guild = self.guild or Object(id=self.guild_id)
|
||||||
try:
|
try:
|
||||||
member = data['member'] # type: ignore
|
member = data['member'] # type: ignore - The key is optional and handled
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
# The fallback to Object for guild causes a type check error but is explicitly allowed here
|
||||||
self.user = Member(state=self._state, guild=guild, data=member) # type: ignore
|
self.user = Member(state=self._state, guild=guild, data=member) # type: ignore
|
||||||
self._permissions = int(member.get('permissions', 0))
|
self._permissions = int(member.get('permissions', 0))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.user = User(state=self._state, data=data['user'])
|
self.user = User(state=self._state, data=data['user']) # type: ignore - The key is optional and handled
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -250,6 +252,7 @@ class Interaction:
|
|||||||
session=self._session,
|
session=self._session,
|
||||||
)
|
)
|
||||||
state = _InteractionMessageState(self, self._state)
|
state = _InteractionMessageState(self, self._state)
|
||||||
|
# The state and channel parameters are mocked here
|
||||||
message = InteractionMessage(state=state, channel=channel, data=data) # type: ignore
|
message = InteractionMessage(state=state, channel=channel, data=data) # type: ignore
|
||||||
self._original_message = message
|
self._original_message = message
|
||||||
return message
|
return message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user