Browse Source

Update pyright version

pull/10109/head
Josh 2 years ago
committed by dolfies
parent
commit
2a880be6b8
  1. 2
      .github/workflows/lint.yml
  2. 2
      discord/abc.py
  3. 2
      discord/channel.py
  4. 6
      discord/ext/commands/core.py
  5. 4
      discord/ext/commands/flags.py
  6. 2
      discord/ext/commands/parameters.py
  7. 18
      discord/flags.py
  8. 11
      discord/guild.py
  9. 4
      discord/http.py
  10. 6
      discord/invite.py

2
.github/workflows/lint.yml

@ -34,7 +34,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: false no-comments: false

2
discord/abc.py

@ -1511,6 +1511,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:
target_type = None
data = await self._state.http.create_invite( data = await self._state.http.create_invite(
self.id, self.id,

2
discord/channel.py

@ -833,7 +833,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,

6
discord/ext/commands/core.py

@ -773,7 +773,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))
@ -791,7 +791,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
@ -2001,7 +2001,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]:

4
discord/ext/commands/flags.py

@ -465,7 +465,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)
@ -580,7 +580,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)

2
discord/ext/commands/parameters.py

@ -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

18
discord/flags.py

@ -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
@ -200,7 +214,7 @@ class 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

11
discord/guild.py

@ -133,6 +133,7 @@ if TYPE_CHECKING:
from .types.message import MessageSearchAuthorType, MessageSearchHasType from .types.message import MessageSearchAuthorType, MessageSearchHasType
from .types.snowflake import SnowflakeList, Snowflake as _Snowflake from .types.snowflake import SnowflakeList, Snowflake as _Snowflake
from .types.widget import EditWidgetSettings from .types.widget import EditWidgetSettings
from .types.audit_log import AuditLogEvent
from .types.oauth2 import OAuth2Guild as OAuth2GuildPayload from .types.oauth2 import OAuth2Guild as OAuth2GuildPayload
from .message import EmojiInputType, Message from .message import EmojiInputType, Message
from .read_state import ReadState from .read_state import ReadState
@ -4231,7 +4232,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', [])
@ -4247,7 +4248,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', [])
@ -4265,8 +4266,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): if isinstance(before, datetime):
before = Object(id=utils.time_snowflake(before, high=False)) before = Object(id=utils.time_snowflake(before, high=False))

4
discord/http.py

@ -80,7 +80,7 @@ if TYPE_CHECKING:
from .mentions import AllowedMentions from .mentions import AllowedMentions
from .message import Attachment, Message from .message import Attachment, Message
from .flags import MessageFlags from .flags import MessageFlags
from .enums import AuditLogAction, ChannelType, InteractionType from .enums import ChannelType, InteractionType
from .embeds import Embed from .embeds import Embed
from .types import ( from .types import (
@ -2200,7 +2200,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]:
r = Route('GET', '/guilds/{guild_id}/audit-logs', guild_id=guild_id) r = Route('GET', '/guilds/{guild_id}/audit-logs', guild_id=guild_id)
params: Dict[str, Any] = {'limit': limit} params: Dict[str, Any] = {'limit': limit}

6
discord/invite.py

@ -58,6 +58,12 @@ if TYPE_CHECKING:
Invite as InvitePayload, Invite as InvitePayload,
InviteGuild as InviteGuildPayload, InviteGuild as InviteGuildPayload,
) )
from .types.channel import (
PartialChannel as InviteChannelPayload,
)
from .state import ConnectionState
from .guild import Guild
from .abc import GuildChannel
from .user import User from .user import User
InviteGuildType = Union[Guild, 'PartialInviteGuild', Object] InviteGuildType = Union[Guild, 'PartialInviteGuild', Object]

Loading…
Cancel
Save