mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-13 13:25:26 +00:00
Update pyright version
This commit is contained in:
parent
0871b34fc8
commit
630b2a1e55
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
|||||||
- name: Run Pyright
|
- name: Run Pyright
|
||||||
uses: jakebailey/pyright-action@v1
|
uses: jakebailey/pyright-action@v1
|
||||||
with:
|
with:
|
||||||
version: '1.1.289'
|
version: '1.1.316'
|
||||||
warnings: false
|
warnings: false
|
||||||
no-comments: ${{ matrix.python-version != '3.x' }}
|
no-comments: ${{ matrix.python-version != '3.x' }}
|
||||||
|
|
||||||
|
@ -1246,6 +1246,8 @@ class GuildChannel:
|
|||||||
:class:`~discord.Invite`
|
:class:`~discord.Invite`
|
||||||
The invite that was created.
|
The invite that was created.
|
||||||
"""
|
"""
|
||||||
|
if target_type is InviteTarget.unknown:
|
||||||
|
raise ValueError('Cannot create invite with an unknown target type')
|
||||||
|
|
||||||
data = await self._state.http.create_invite(
|
data = await self._state.http.create_invite(
|
||||||
self.id,
|
self.id,
|
||||||
|
@ -976,7 +976,7 @@ class Command(Generic[GroupT, P, T]):
|
|||||||
if self.binding is not None:
|
if self.binding is not None:
|
||||||
check: Optional[Check] = getattr(self.binding, 'interaction_check', None)
|
check: Optional[Check] = getattr(self.binding, 'interaction_check', None)
|
||||||
if check:
|
if check:
|
||||||
ret = await maybe_coroutine(check, interaction) # type: ignore # Probable pyright bug
|
ret = await maybe_coroutine(check, interaction)
|
||||||
if not ret:
|
if not ret:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -177,8 +177,7 @@ class CommandParameter:
|
|||||||
return choice
|
return choice
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# ParamSpec doesn't understand that transform is a callable since it's unbound
|
return await maybe_coroutine(self._annotation.transform, interaction, value)
|
||||||
return await maybe_coroutine(self._annotation.transform, interaction, value) # type: ignore
|
|
||||||
except AppCommandError:
|
except AppCommandError:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -109,7 +109,7 @@ class TranslationContext(Generic[_L, _D]):
|
|||||||
def __init__(self, location: Literal[TranslationContextLocation.other], data: Any) -> None:
|
def __init__(self, location: Literal[TranslationContextLocation.other], data: Any) -> None:
|
||||||
...
|
...
|
||||||
|
|
||||||
def __init__(self, location: _L, data: _D) -> None:
|
def __init__(self, location: _L, data: _D) -> None: # type: ignore # pyright doesn't like the overloads
|
||||||
self.location: _L = location
|
self.location: _L = location
|
||||||
self.data: _D = data
|
self.data: _D = data
|
||||||
|
|
||||||
|
@ -776,7 +776,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
self.id,
|
self.id,
|
||||||
name=name,
|
name=name,
|
||||||
auto_archive_duration=auto_archive_duration or self.default_auto_archive_duration,
|
auto_archive_duration=auto_archive_duration or self.default_auto_archive_duration,
|
||||||
type=type.value,
|
type=type.value, # type: ignore # we're assuming that the user is passing a valid variant
|
||||||
reason=reason,
|
reason=reason,
|
||||||
invitable=invitable,
|
invitable=invitable,
|
||||||
rate_limit_per_user=slowmode_delay,
|
rate_limit_per_user=slowmode_delay,
|
||||||
|
@ -279,7 +279,7 @@ class SelectMenu(Component):
|
|||||||
|
|
||||||
def to_dict(self) -> SelectMenuPayload:
|
def to_dict(self) -> SelectMenuPayload:
|
||||||
payload: SelectMenuPayload = {
|
payload: SelectMenuPayload = {
|
||||||
'type': self.type.value,
|
'type': self.type.value, # type: ignore # we know this is a select menu.
|
||||||
'custom_id': self.custom_id,
|
'custom_id': self.custom_id,
|
||||||
'min_values': self.min_values,
|
'min_values': self.min_values,
|
||||||
'max_values': self.max_values,
|
'max_values': self.max_values,
|
||||||
|
@ -377,7 +377,7 @@ class Cog(metaclass=CogMeta):
|
|||||||
if len(mapping) > 25:
|
if len(mapping) > 25:
|
||||||
raise TypeError('maximum number of application command children exceeded')
|
raise TypeError('maximum number of application command children exceeded')
|
||||||
|
|
||||||
self.__cog_app_commands_group__._children = mapping # type: ignore # Variance issue
|
self.__cog_app_commands_group__._children = mapping
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ class Context(discord.abc.Messageable, Generic[BotT]):
|
|||||||
if command is None:
|
if command is None:
|
||||||
raise ValueError('interaction does not have command data')
|
raise ValueError('interaction does not have command data')
|
||||||
|
|
||||||
bot: BotT = interaction.client # type: ignore
|
bot: BotT = interaction.client
|
||||||
data: ApplicationCommandInteractionData = interaction.data # type: ignore
|
data: ApplicationCommandInteractionData = interaction.data # type: ignore
|
||||||
if interaction.message is None:
|
if interaction.message is None:
|
||||||
synthetic_payload = {
|
synthetic_payload = {
|
||||||
|
@ -776,7 +776,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
command = self
|
command = self
|
||||||
# command.parent is type-hinted as GroupMixin some attributes are resolved via MRO
|
# command.parent is type-hinted as GroupMixin some attributes are resolved via MRO
|
||||||
while command.parent is not None: # type: ignore
|
while command.parent is not None: # type: ignore
|
||||||
command = command.parent # type: ignore
|
command = command.parent
|
||||||
entries.append(command.name) # type: ignore
|
entries.append(command.name) # type: ignore
|
||||||
|
|
||||||
return ' '.join(reversed(entries))
|
return ' '.join(reversed(entries))
|
||||||
@ -794,7 +794,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
entries = []
|
entries = []
|
||||||
command = self
|
command = self
|
||||||
while command.parent is not None: # type: ignore
|
while command.parent is not None: # type: ignore
|
||||||
command = command.parent # type: ignore
|
command = command.parent
|
||||||
entries.append(command)
|
entries.append(command)
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
@ -2004,7 +2004,7 @@ def check_any(*checks: Check[ContextT]) -> Check[ContextT]:
|
|||||||
# if we're here, all checks failed
|
# if we're here, all checks failed
|
||||||
raise CheckAnyFailure(unwrapped, errors)
|
raise CheckAnyFailure(unwrapped, errors)
|
||||||
|
|
||||||
return check(predicate) # type: ignore
|
return check(predicate)
|
||||||
|
|
||||||
|
|
||||||
def has_role(item: Union[int, str], /) -> Check[Any]:
|
def has_role(item: Union[int, str], /) -> Check[Any]:
|
||||||
|
@ -485,7 +485,7 @@ class FlagConverter(metaclass=FlagsMeta):
|
|||||||
for flag in flags.values():
|
for flag in flags.values():
|
||||||
if callable(flag.default):
|
if callable(flag.default):
|
||||||
# Type checker does not understand that flag.default is a Callable
|
# Type checker does not understand that flag.default is a Callable
|
||||||
default = await maybe_coroutine(flag.default, ctx) # type: ignore
|
default = await maybe_coroutine(flag.default, ctx)
|
||||||
setattr(self, flag.attribute, default)
|
setattr(self, flag.attribute, default)
|
||||||
else:
|
else:
|
||||||
setattr(self, flag.attribute, flag.default)
|
setattr(self, flag.attribute, flag.default)
|
||||||
@ -600,7 +600,7 @@ class FlagConverter(metaclass=FlagsMeta):
|
|||||||
else:
|
else:
|
||||||
if callable(flag.default):
|
if callable(flag.default):
|
||||||
# Type checker does not understand flag.default is a Callable
|
# Type checker does not understand flag.default is a Callable
|
||||||
default = await maybe_coroutine(flag.default, ctx) # type: ignore
|
default = await maybe_coroutine(flag.default, ctx)
|
||||||
setattr(self, flag.attribute, default)
|
setattr(self, flag.attribute, default)
|
||||||
else:
|
else:
|
||||||
setattr(self, flag.attribute, flag.default)
|
setattr(self, flag.attribute, flag.default)
|
||||||
|
@ -398,7 +398,7 @@ class HybridAppCommand(discord.app_commands.Command[CogT, P, T]):
|
|||||||
if self.binding is not None:
|
if self.binding is not None:
|
||||||
try:
|
try:
|
||||||
# Type checker does not like runtime attribute retrieval
|
# Type checker does not like runtime attribute retrieval
|
||||||
check: AppCommandCheck = self.binding.interaction_check # type: ignore
|
check: AppCommandCheck = self.binding.interaction_check
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -920,9 +920,9 @@ def hybrid_group(
|
|||||||
If the function is not a coroutine or is already a command.
|
If the function is not a coroutine or is already a command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func: CommandCallback[CogT, ContextT, P, T]):
|
def decorator(func: CommandCallback[CogT, ContextT, P, T]) -> HybridGroup[CogT, P, T]:
|
||||||
if isinstance(func, Command):
|
if isinstance(func, Command):
|
||||||
raise TypeError('Callback is already a command.')
|
raise TypeError('Callback is already a command.')
|
||||||
return HybridGroup(func, name=name, with_app_command=with_app_command, **attrs)
|
return HybridGroup(func, name=name, with_app_command=with_app_command, **attrs)
|
||||||
|
|
||||||
return decorator # type: ignore
|
return decorator
|
||||||
|
@ -197,7 +197,7 @@ class Parameter(inspect.Parameter):
|
|||||||
"""
|
"""
|
||||||
# pre-condition: required is False
|
# pre-condition: required is False
|
||||||
if callable(self.default):
|
if callable(self.default):
|
||||||
return await maybe_coroutine(self.default, ctx) # type: ignore
|
return await maybe_coroutine(self.default, ctx)
|
||||||
return self.default
|
return self.default
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,21 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from operator import or_
|
from operator import or_
|
||||||
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Dict, Iterator, List, Optional, Tuple, Type, TypeVar, overload
|
from typing import (
|
||||||
|
TYPE_CHECKING,
|
||||||
|
Any,
|
||||||
|
Callable,
|
||||||
|
ClassVar,
|
||||||
|
Dict,
|
||||||
|
Iterator,
|
||||||
|
List,
|
||||||
|
Optional,
|
||||||
|
Sequence,
|
||||||
|
Tuple,
|
||||||
|
Type,
|
||||||
|
TypeVar,
|
||||||
|
overload,
|
||||||
|
)
|
||||||
|
|
||||||
from .enums import UserFlags
|
from .enums import UserFlags
|
||||||
|
|
||||||
@ -1621,7 +1635,7 @@ class ChannelFlags(BaseFlags):
|
|||||||
|
|
||||||
class ArrayFlags(BaseFlags):
|
class ArrayFlags(BaseFlags):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _from_value(cls: Type[Self], value: List[int]) -> Self:
|
def _from_value(cls: Type[Self], value: Sequence[int]) -> Self:
|
||||||
self = cls.__new__(cls)
|
self = cls.__new__(cls)
|
||||||
# This is a micro-optimization given the frequency this object can be created.
|
# This is a micro-optimization given the frequency this object can be created.
|
||||||
# (1).__lshift__ is used in place of lambda x: 1 << x
|
# (1).__lshift__ is used in place of lambda x: 1 << x
|
||||||
|
@ -132,6 +132,7 @@ if TYPE_CHECKING:
|
|||||||
from .types.integration import IntegrationType
|
from .types.integration import IntegrationType
|
||||||
from .types.snowflake import SnowflakeList
|
from .types.snowflake import SnowflakeList
|
||||||
from .types.widget import EditWidgetSettings
|
from .types.widget import EditWidgetSettings
|
||||||
|
from .types.audit_log import AuditLogEvent
|
||||||
from .message import EmojiInputType
|
from .message import EmojiInputType
|
||||||
|
|
||||||
VocalGuildChannel = Union[VoiceChannel, StageChannel]
|
VocalGuildChannel = Union[VoiceChannel, StageChannel]
|
||||||
@ -3853,7 +3854,7 @@ class Guild(Hashable):
|
|||||||
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
|
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
|
||||||
before_id = before.id if before else None
|
before_id = before.id if before else None
|
||||||
data = await self._state.http.get_audit_logs(
|
data = await self._state.http.get_audit_logs(
|
||||||
self.id, limit=retrieve, user_id=user_id, action_type=action, before=before_id
|
self.id, limit=retrieve, user_id=user_id, action_type=action_type, before=before_id
|
||||||
)
|
)
|
||||||
|
|
||||||
entries = data.get('audit_log_entries', [])
|
entries = data.get('audit_log_entries', [])
|
||||||
@ -3869,7 +3870,7 @@ class Guild(Hashable):
|
|||||||
async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Optional[int]):
|
async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Optional[int]):
|
||||||
after_id = after.id if after else None
|
after_id = after.id if after else None
|
||||||
data = await self._state.http.get_audit_logs(
|
data = await self._state.http.get_audit_logs(
|
||||||
self.id, limit=retrieve, user_id=user_id, action_type=action, after=after_id
|
self.id, limit=retrieve, user_id=user_id, action_type=action_type, after=after_id
|
||||||
)
|
)
|
||||||
|
|
||||||
entries = data.get('audit_log_entries', [])
|
entries = data.get('audit_log_entries', [])
|
||||||
@ -3887,8 +3888,10 @@ class Guild(Hashable):
|
|||||||
else:
|
else:
|
||||||
user_id = None
|
user_id = None
|
||||||
|
|
||||||
if action:
|
if action is not MISSING:
|
||||||
action = action.value
|
action_type: Optional[AuditLogEvent] = action.value
|
||||||
|
else:
|
||||||
|
action_type = None
|
||||||
|
|
||||||
if isinstance(before, datetime.datetime):
|
if isinstance(before, datetime.datetime):
|
||||||
before = Object(id=utils.time_snowflake(before, high=False))
|
before = Object(id=utils.time_snowflake(before, high=False))
|
||||||
|
@ -68,7 +68,6 @@ if TYPE_CHECKING:
|
|||||||
from .embeds import Embed
|
from .embeds import Embed
|
||||||
from .message import Attachment
|
from .message import Attachment
|
||||||
from .flags import MessageFlags
|
from .flags import MessageFlags
|
||||||
from .enums import AuditLogAction
|
|
||||||
|
|
||||||
from .types import (
|
from .types import (
|
||||||
appinfo,
|
appinfo,
|
||||||
@ -1727,7 +1726,7 @@ class HTTPClient:
|
|||||||
before: Optional[Snowflake] = None,
|
before: Optional[Snowflake] = None,
|
||||||
after: Optional[Snowflake] = None,
|
after: Optional[Snowflake] = None,
|
||||||
user_id: Optional[Snowflake] = None,
|
user_id: Optional[Snowflake] = None,
|
||||||
action_type: Optional[AuditLogAction] = None,
|
action_type: Optional[audit_log.AuditLogEvent] = None,
|
||||||
) -> Response[audit_log.AuditLog]:
|
) -> Response[audit_log.AuditLog]:
|
||||||
params: Dict[str, Any] = {'limit': limit}
|
params: Dict[str, Any] = {'limit': limit}
|
||||||
if before:
|
if before:
|
||||||
|
@ -47,6 +47,7 @@ if TYPE_CHECKING:
|
|||||||
InviteGuild as InviteGuildPayload,
|
InviteGuild as InviteGuildPayload,
|
||||||
GatewayInvite as GatewayInvitePayload,
|
GatewayInvite as GatewayInvitePayload,
|
||||||
)
|
)
|
||||||
|
from .types.guild import GuildFeature
|
||||||
from .types.channel import (
|
from .types.channel import (
|
||||||
PartialChannel as InviteChannelPayload,
|
PartialChannel as InviteChannelPayload,
|
||||||
)
|
)
|
||||||
@ -189,7 +190,7 @@ class PartialInviteGuild:
|
|||||||
self._state: ConnectionState = state
|
self._state: ConnectionState = state
|
||||||
self.id: int = id
|
self.id: int = id
|
||||||
self.name: str = data['name']
|
self.name: str = data['name']
|
||||||
self.features: List[str] = data.get('features', [])
|
self.features: List[GuildFeature] = data.get('features', [])
|
||||||
self._icon: Optional[str] = data.get('icon')
|
self._icon: Optional[str] = data.get('icon')
|
||||||
self._banner: Optional[str] = data.get('banner')
|
self._banner: Optional[str] = data.get('banner')
|
||||||
self._splash: Optional[str] = data.get('splash')
|
self._splash: Optional[str] = data.get('splash')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user