mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-14 17:59:48 +00:00
Bump Pyright to 1.1.265, fix type errors, and remove unnecessary ignores
This commit is contained in:
parent
60079aee1b
commit
d707019348
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
||||
- name: Run Pyright
|
||||
uses: jakebailey/pyright-action@v1
|
||||
with:
|
||||
version: '1.1.253'
|
||||
version: '1.1.265'
|
||||
warnings: false
|
||||
no-comments: ${{ matrix.python-version != '3.x' }}
|
||||
|
||||
|
@ -1696,7 +1696,7 @@ class Messageable:
|
||||
The message with the message data parsed.
|
||||
"""
|
||||
|
||||
async def _around_strategy(retrieve, around, limit):
|
||||
async def _around_strategy(retrieve: int, around: Optional[Snowflake], limit: Optional[int]):
|
||||
if not around:
|
||||
return []
|
||||
|
||||
@ -1705,7 +1705,7 @@ class Messageable:
|
||||
|
||||
return data, None, limit
|
||||
|
||||
async def _after_strategy(retrieve, after, limit):
|
||||
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.logs_from(channel.id, retrieve, after=after_id)
|
||||
|
||||
@ -1717,7 +1717,7 @@ class Messageable:
|
||||
|
||||
return data, after, limit
|
||||
|
||||
async def _before_strategy(retrieve, before, limit):
|
||||
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.logs_from(channel.id, retrieve, before=before_id)
|
||||
|
||||
|
@ -822,7 +822,7 @@ def create_activity(data: Optional[ActivityPayload], state: ConnectionState) ->
|
||||
return Game(**data)
|
||||
elif game_type is ActivityType.custom:
|
||||
try:
|
||||
name = data.pop('name')
|
||||
name = data.pop('name') # type: ignore
|
||||
except KeyError:
|
||||
ret = Activity(**data)
|
||||
else:
|
||||
|
@ -442,7 +442,7 @@ class Choice(Generic[ChoiceT]):
|
||||
)
|
||||
|
||||
def to_dict(self) -> ApplicationCommandOptionChoice:
|
||||
return {
|
||||
return { # type: ignore
|
||||
'name': self.name,
|
||||
'value': self.value,
|
||||
}
|
||||
|
@ -1442,7 +1442,7 @@ class Client:
|
||||
The guild with the guild data parsed.
|
||||
"""
|
||||
|
||||
async def _before_strategy(retrieve, before, limit):
|
||||
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
|
||||
before_id = before.id if before else None
|
||||
data = await self.http.get_guilds(retrieve, before=before_id)
|
||||
|
||||
@ -1454,7 +1454,7 @@ class Client:
|
||||
|
||||
return data, before, limit
|
||||
|
||||
async def _after_strategy(retrieve, after, limit):
|
||||
async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Optional[int]):
|
||||
after_id = after.id if after else None
|
||||
data = await self.http.get_guilds(retrieve, after=after_id)
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ async def _actual_conversion(ctx: Context[BotT], converter: Any, argument: str,
|
||||
if inspect.ismethod(converter.convert):
|
||||
return await converter.convert(ctx, argument)
|
||||
else:
|
||||
return await converter().convert(ctx, argument) # type: ignore
|
||||
return await converter().convert(ctx, argument)
|
||||
elif isinstance(converter, Converter):
|
||||
return await converter.convert(ctx, argument) # type: ignore
|
||||
except CommandError:
|
||||
|
@ -888,7 +888,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
||||
|
||||
if self._max_concurrency is not None:
|
||||
# For this application, context can be duck-typed as a Message
|
||||
await self._max_concurrency.acquire(ctx) # type: ignore
|
||||
await self._max_concurrency.acquire(ctx)
|
||||
|
||||
try:
|
||||
if self.cooldown_after_parsing:
|
||||
@ -901,7 +901,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
||||
await self.call_before_hooks(ctx)
|
||||
except:
|
||||
if self._max_concurrency is not None:
|
||||
await self._max_concurrency.release(ctx) # type: ignore
|
||||
await self._max_concurrency.release(ctx)
|
||||
raise
|
||||
|
||||
def is_on_cooldown(self, ctx: Context[BotT], /) -> bool:
|
||||
@ -2426,7 +2426,7 @@ def cooldown(
|
||||
if isinstance(func, Command):
|
||||
func._buckets = CooldownMapping(Cooldown(rate, per), type)
|
||||
else:
|
||||
func.__commands_cooldown__ = CooldownMapping(Cooldown(rate, per), type) # type: ignore # typevar cannot be inferred without annotation
|
||||
func.__commands_cooldown__ = CooldownMapping(Cooldown(rate, per), type)
|
||||
return func
|
||||
|
||||
return decorator # type: ignore
|
||||
|
@ -220,7 +220,7 @@ def _not_overridden(f: FuncT) -> FuncT:
|
||||
|
||||
class _HelpCommandImpl(Command):
|
||||
def __init__(self, inject: HelpCommand, *args: Any, **kwargs: Any) -> None:
|
||||
super().__init__(inject.command_callback, *args, **kwargs) # type: ignore
|
||||
super().__init__(inject.command_callback, *args, **kwargs)
|
||||
self._original: HelpCommand = inject
|
||||
self._injected: HelpCommand = inject
|
||||
self.params: Dict[str, Parameter] = get_signature_parameters(inject.command_callback, globals(), skip_parameters=1)
|
||||
@ -228,7 +228,7 @@ class _HelpCommandImpl(Command):
|
||||
async def prepare(self, ctx: Context[Any]) -> None:
|
||||
self._injected = injected = self._original.copy()
|
||||
injected.context = ctx
|
||||
self.callback = injected.command_callback # type: ignore
|
||||
self.callback = injected.command_callback
|
||||
self.params = get_signature_parameters(injected.command_callback, globals(), skip_parameters=1)
|
||||
|
||||
on_error = injected.on_help_command_error
|
||||
|
@ -140,7 +140,7 @@ class ConverterTransformer(app_commands.Transformer):
|
||||
if inspect.ismethod(converter.convert):
|
||||
return await converter.convert(ctx, value)
|
||||
else:
|
||||
return await converter().convert(ctx, value) # type: ignore
|
||||
return await converter().convert(ctx, value)
|
||||
elif isinstance(converter, Converter):
|
||||
return await converter.convert(ctx, value)
|
||||
except CommandError:
|
||||
@ -205,7 +205,7 @@ def replace_parameter(
|
||||
args = getattr(converter, '__args__', [])
|
||||
if isinstance(converter, Range):
|
||||
r = converter
|
||||
param = param.replace(annotation=app_commands.Range[r.annotation, r.min, r.max]) # type: ignore
|
||||
param = param.replace(annotation=app_commands.Range[r.annotation, r.min, r.max])
|
||||
elif isinstance(converter, Greedy):
|
||||
# Greedy is "optional" in ext.commands
|
||||
# However, in here, it probably makes sense to make it required.
|
||||
|
@ -29,8 +29,8 @@ import datetime
|
||||
import logging
|
||||
from typing import (
|
||||
Any,
|
||||
Awaitable,
|
||||
Callable,
|
||||
Coroutine,
|
||||
Generic,
|
||||
List,
|
||||
Optional,
|
||||
@ -56,10 +56,10 @@ __all__ = (
|
||||
# fmt: on
|
||||
|
||||
T = TypeVar('T')
|
||||
_func = Callable[..., Awaitable[Any]]
|
||||
_func = Callable[..., Coroutine[Any, Any, Any]]
|
||||
LF = TypeVar('LF', bound=_func)
|
||||
FT = TypeVar('FT', bound=_func)
|
||||
ET = TypeVar('ET', bound=Callable[[Any, BaseException], Awaitable[Any]])
|
||||
ET = TypeVar('ET', bound=Callable[[Any, BaseException], Coroutine[Any, Any, Any]])
|
||||
|
||||
|
||||
def is_ambiguous(dt: datetime.datetime) -> bool:
|
||||
@ -619,7 +619,7 @@ class Loop(Generic[LF]):
|
||||
if not inspect.iscoroutinefunction(coro):
|
||||
raise TypeError(f'Expected coroutine function, received {coro.__class__.__name__!r}.')
|
||||
|
||||
self._error = coro # type: ignore
|
||||
self._error = coro
|
||||
return coro
|
||||
|
||||
def _get_next_sleep_time(self, now: datetime.datetime = MISSING) -> datetime.datetime:
|
||||
|
@ -812,7 +812,7 @@ class DiscordVoiceWebSocket:
|
||||
self._close_code: Optional[int] = None
|
||||
self.secret_key: Optional[str] = None
|
||||
if hook:
|
||||
self._hook = hook # type: ignore # type-checker doesn't like overriding methods
|
||||
self._hook = hook
|
||||
|
||||
async def _hook(self, *args: Any) -> None:
|
||||
pass
|
||||
|
@ -2227,7 +2227,7 @@ class Guild(Hashable):
|
||||
# This endpoint paginates in ascending order.
|
||||
endpoint = self._state.http.get_bans
|
||||
|
||||
async def _before_strategy(retrieve, before, limit):
|
||||
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
|
||||
before_id = before.id if before else None
|
||||
data = await endpoint(self.id, limit=retrieve, before=before_id)
|
||||
|
||||
@ -2239,7 +2239,7 @@ class Guild(Hashable):
|
||||
|
||||
return data, before, limit
|
||||
|
||||
async def _after_strategy(retrieve, after, limit):
|
||||
async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Optional[int]):
|
||||
after_id = after.id if after else None
|
||||
data = await endpoint(self.id, limit=retrieve, after=after_id)
|
||||
|
||||
@ -3539,7 +3539,7 @@ class Guild(Hashable):
|
||||
The audit log entry.
|
||||
"""
|
||||
|
||||
async def _before_strategy(retrieve, before, limit):
|
||||
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
|
||||
@ -3555,7 +3555,7 @@ class Guild(Hashable):
|
||||
|
||||
return data, entries, before, limit
|
||||
|
||||
async def _after_strategy(retrieve, after, limit):
|
||||
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
|
||||
|
@ -512,7 +512,7 @@ class ScheduledEvent(Hashable):
|
||||
All subscribed users of this event.
|
||||
"""
|
||||
|
||||
async def _before_strategy(retrieve, before, limit):
|
||||
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
|
||||
before_id = before.id if before else None
|
||||
users = await self._state.http.get_scheduled_event_users(
|
||||
self.guild_id, self.id, limit=retrieve, with_member=False, before=before_id
|
||||
@ -526,7 +526,7 @@ class ScheduledEvent(Hashable):
|
||||
|
||||
return users, before, limit
|
||||
|
||||
async def _after_strategy(retrieve, after, limit):
|
||||
async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Optional[int]):
|
||||
after_id = after.id if after else None
|
||||
users = await self._state.http.get_scheduled_event_users(
|
||||
self.guild_id, self.id, limit=retrieve, with_member=False, after=after_id
|
||||
|
@ -247,7 +247,7 @@ class ConnectionState:
|
||||
self._command_tree: Optional[CommandTree] = None
|
||||
|
||||
if not intents.members or cache_flags._empty:
|
||||
self.store_user = self.store_user_no_intents # type: ignore # This reassignment is on purpose
|
||||
self.store_user = self.store_user_no_intents
|
||||
|
||||
self.parsers: Dict[str, Callable[[Any], None]]
|
||||
self.parsers = parsers = {}
|
||||
@ -1329,7 +1329,7 @@ class ConnectionState:
|
||||
_log.debug('GUILD_INTEGRATIONS_UPDATE referencing an unknown guild ID: %s. Discarding.', data['guild_id'])
|
||||
|
||||
def parse_integration_create(self, data: gw.IntegrationCreateEvent) -> None:
|
||||
guild_id = int(data.pop('guild_id'))
|
||||
guild_id = int(data['guild_id'])
|
||||
guild = self._get_guild(guild_id)
|
||||
if guild is not None:
|
||||
cls, _ = _integration_factory(data['type'])
|
||||
@ -1339,7 +1339,7 @@ class ConnectionState:
|
||||
_log.debug('INTEGRATION_CREATE referencing an unknown guild ID: %s. Discarding.', guild_id)
|
||||
|
||||
def parse_integration_update(self, data: gw.IntegrationUpdateEvent) -> None:
|
||||
guild_id = int(data.pop('guild_id'))
|
||||
guild_id = int(data['guild_id'])
|
||||
guild = self._get_guild(guild_id)
|
||||
if guild is not None:
|
||||
cls, _ = _integration_factory(data['type'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user