Bump Pyright to 1.1.265, fix type errors, and remove unnecessary ignores

This commit is contained in:
Bryan Forbes
2022-08-04 21:46:02 -05:00
committed by GitHub
parent 60079aee1b
commit d707019348
14 changed files with 30 additions and 30 deletions

View File

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

View File

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

View File

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

View File

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

View File

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