mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
Major dependency update (#1974)
* [V3] Stop `tmp` dir showing up * [V3] Remove requirements.txt and declare in install_requires * Remove requirements.txt from tox.ini * Update and pin all dependencies and sub-dependencies * Update for breaking changes * Reformat * Update docs/requirements.txt and tox.ini requirements * Add 3.7 to identifiers and travis/tox builds * Attempt at fixing the travis build matrix * Attempt #2 * Attempt 3 * aiohttp.ClientSession.close() -> detach() in sync code * Add raven-aiohttp to requirements * Fix stuff in setup.py - Added discord.py back into requirements list - Fix typo in alabaster extra requirement Also in the Pipfile: - Removed allow_prereleases and explicitly pinned black, since this is the only dep we want a prerelease for. * Update to Rapptz/discord.py@8ccb98d395 * Add proper 3.7 build in Travis See travis-ci/travis-ci#9815 * Which version of 3.6 does Xenial install then? * Maybe we should stop pipenv installing useless stuff * Nevermind, back to specific minor version * Remove lots of WET dependency stuff * Fix egg fragment for dependency link
This commit is contained in:
@@ -1926,7 +1926,7 @@ class Audio:
|
||||
pass
|
||||
|
||||
def __unload(self):
|
||||
self.session.close()
|
||||
self.session.detach()
|
||||
lavalink.unregister_event_listener(self.event_handler)
|
||||
self.bot.loop.create_task(lavalink.close())
|
||||
shutdown_lavalink_server()
|
||||
|
||||
@@ -24,7 +24,7 @@ class Image:
|
||||
self.imgur_base_url = "https://api.imgur.com/3/"
|
||||
|
||||
def __unload(self):
|
||||
self.session.close()
|
||||
self.session.detach()
|
||||
|
||||
@commands.group(name="imgur")
|
||||
async def _imgur(self, ctx):
|
||||
|
||||
@@ -71,7 +71,9 @@ class Command(commands.Command):
|
||||
cmd = cmd.parent
|
||||
return sorted(entries, key=lambda x: len(x.qualified_name), reverse=True)
|
||||
|
||||
async def do_conversion(self, ctx: "Context", converter, argument: str):
|
||||
async def do_conversion(
|
||||
self, ctx: "Context", converter, argument: str, param: inspect.Parameter
|
||||
):
|
||||
"""Convert an argument according to its type annotation.
|
||||
|
||||
Raises
|
||||
@@ -90,14 +92,14 @@ class Command(commands.Command):
|
||||
return argument
|
||||
|
||||
try:
|
||||
return await super().do_conversion(ctx, converter, argument)
|
||||
return await super().do_conversion(ctx, converter, argument, param)
|
||||
except commands.BadArgument as exc:
|
||||
raise ConversionFailure(converter, argument, *exc.args) from exc
|
||||
raise ConversionFailure(converter, argument, param, *exc.args) from exc
|
||||
except ValueError as exc:
|
||||
# Some common converters need special treatment...
|
||||
if converter in (int, float):
|
||||
message = _('"{argument}" is not a number.').format(argument=argument)
|
||||
raise ConversionFailure(converter, argument, message) from exc
|
||||
raise ConversionFailure(converter, argument, param, message) from exc
|
||||
|
||||
# We should expose anything which might be a bug in the converter
|
||||
raise exc
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Errors module for the commands package."""
|
||||
import inspect
|
||||
from discord.ext import commands
|
||||
|
||||
__all__ = ["ConversionFailure"]
|
||||
@@ -7,7 +8,8 @@ __all__ = ["ConversionFailure"]
|
||||
class ConversionFailure(commands.BadArgument):
|
||||
"""Raised when converting an argument fails."""
|
||||
|
||||
def __init__(self, converter, argument: str, *args):
|
||||
def __init__(self, converter, argument: str, param: inspect.Parameter, *args):
|
||||
self.converter = converter
|
||||
self.argument = argument
|
||||
self.param = param
|
||||
super().__init__(*args)
|
||||
|
||||
@@ -2,7 +2,7 @@ import asyncio
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp_json_rpc import JsonRpc
|
||||
from aiohttp_json_rpc.rpc import unpack_request_args
|
||||
from aiohttp_json_rpc.rpc import JsonRpcMethod
|
||||
|
||||
import logging
|
||||
|
||||
@@ -11,7 +11,7 @@ log = logging.getLogger("red.rpc")
|
||||
__all__ = ["RPC", "RPCMixin", "get_name"]
|
||||
|
||||
|
||||
def get_name(func, prefix=None):
|
||||
def get_name(func, prefix=""):
|
||||
class_name = prefix or func.__self__.__class__.__name__.lower()
|
||||
func_name = func.__name__.strip("_")
|
||||
if class_name == "redrpc":
|
||||
@@ -24,13 +24,13 @@ class RedRpc(JsonRpc):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.add_methods(("", self.get_method_info))
|
||||
|
||||
def _add_method(self, method, prefix=""):
|
||||
def _add_method(self, method, name="", prefix=""):
|
||||
if not asyncio.iscoroutinefunction(method):
|
||||
return
|
||||
|
||||
name = get_name(method, prefix)
|
||||
name = name or get_name(method, prefix)
|
||||
|
||||
self.methods[name] = method
|
||||
self.methods[name] = JsonRpcMethod(method)
|
||||
|
||||
def remove_method(self, method):
|
||||
meth_name = get_name(method)
|
||||
@@ -90,7 +90,7 @@ class RPC:
|
||||
if not asyncio.iscoroutinefunction(method):
|
||||
raise TypeError("RPC methods must be coroutines.")
|
||||
|
||||
self._rpc.add_methods((prefix, unpack_request_args(method)))
|
||||
self._rpc.add_methods((prefix, method))
|
||||
|
||||
def add_multi_method(self, *methods, prefix: str = None):
|
||||
if not all(asyncio.iscoroutinefunction(m) for m in methods):
|
||||
|
||||
@@ -178,7 +178,7 @@ def red(config_fr):
|
||||
|
||||
yield red
|
||||
|
||||
red.http._session.close()
|
||||
red.http._session.detach()
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
Reference in New Issue
Block a user