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
uses: jakebailey/pyright-action@v1
with:
version: '1.1.289'
version: '1.1.316'
warnings: false
no-comments: false

2
discord/abc.py

@ -1511,6 +1511,8 @@ class GuildChannel:
:class:`~discord.Invite`
The invite that was created.
"""
if target_type is InviteTarget.unknown:
target_type = None
data = await self._state.http.create_invite(
self.id,

2
discord/channel.py

@ -833,7 +833,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
self.id,
name=name,
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,
invitable=invitable,
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.parent is type-hinted as GroupMixin some attributes are resolved via MRO
while command.parent is not None: # type: ignore
command = command.parent # type: ignore
command = command.parent
entries.append(command.name) # type: ignore
return ' '.join(reversed(entries))
@ -791,7 +791,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
entries = []
command = self
while command.parent is not None: # type: ignore
command = command.parent # type: ignore
command = command.parent
entries.append(command)
return entries
@ -2001,7 +2001,7 @@ def check_any(*checks: Check[ContextT]) -> Check[ContextT]:
# if we're here, all checks failed
raise CheckAnyFailure(unwrapped, errors)
return check(predicate) # type: ignore
return check(predicate)
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():
if callable(flag.default):
# 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)
else:
setattr(self, flag.attribute, flag.default)
@ -580,7 +580,7 @@ class FlagConverter(metaclass=FlagsMeta):
else:
if callable(flag.default):
# 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)
else:
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
if callable(self.default):
return await maybe_coroutine(self.default, ctx) # type: ignore
return await maybe_coroutine(self.default, ctx)
return self.default

18
discord/flags.py

@ -26,7 +26,21 @@ from __future__ import annotations
from functools import reduce
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
@ -200,7 +214,7 @@ class BaseFlags:
class ArrayFlags(BaseFlags):
@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)
# This is a micro-optimization given the frequency this object can be created.
# (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.snowflake import SnowflakeList, Snowflake as _Snowflake
from .types.widget import EditWidgetSettings
from .types.audit_log import AuditLogEvent
from .types.oauth2 import OAuth2Guild as OAuth2GuildPayload
from .message import EmojiInputType, Message
from .read_state import ReadState
@ -4231,7 +4232,7 @@ class Guild(Hashable):
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
before_id = before.id if before else None
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', [])
@ -4247,7 +4248,7 @@ class Guild(Hashable):
async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Optional[int]):
after_id = after.id if after else None
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', [])
@ -4265,8 +4266,10 @@ class Guild(Hashable):
else:
user_id = None
if action:
action = action.value
if action is not MISSING:
action_type: Optional[AuditLogEvent] = action.value
else:
action_type = None
if isinstance(before, datetime):
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 .message import Attachment, Message
from .flags import MessageFlags
from .enums import AuditLogAction, ChannelType, InteractionType
from .enums import ChannelType, InteractionType
from .embeds import Embed
from .types import (
@ -2200,7 +2200,7 @@ class HTTPClient:
before: Optional[Snowflake] = None,
after: Optional[Snowflake] = None,
user_id: Optional[Snowflake] = None,
action_type: Optional[AuditLogAction] = None,
action_type: Optional[audit_log.AuditLogEvent] = None,
) -> Response[audit_log.AuditLog]:
r = Route('GET', '/guilds/{guild_id}/audit-logs', guild_id=guild_id)
params: Dict[str, Any] = {'limit': limit}

6
discord/invite.py

@ -58,6 +58,12 @@ if TYPE_CHECKING:
Invite as InvitePayload,
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
InviteGuildType = Union[Guild, 'PartialInviteGuild', Object]

Loading…
Cancel
Save