Remove things past deprecation time (2020-08-05) (#4163)

This commit is contained in:
jack1142 2020-08-15 13:47:28 +02:00 committed by GitHub
parent 0adaebb290
commit 46eb9ce7a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 115 deletions

View File

@ -43,8 +43,6 @@ extend functionalities used throughout the bot, as outlined below.
:exclude-members: UserInputOptional, convert
:no-undoc-members:
.. autoclass:: APIToken
.. autodata:: UserInputOptional
:annotation:

View File

@ -29,7 +29,6 @@ from .converter import (
NoParseOptional as NoParseOptional,
UserInputOptional as UserInputOptional,
Literal as Literal,
__getattr__ as _converter__getattr__, # this contains deprecation of APIToken
)
from .errors import (
ConversionFailure as ConversionFailure,
@ -147,14 +146,3 @@ from discord.ext.commands import (
bot_has_guild_permissions as bot_has_guild_permissions,
CommandRegistrationError as CommandRegistrationError,
)
def __getattr__(name):
try:
return _converter__getattr__(name, stacklevel=3)
except AttributeError:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
def __dir__():
return [*globals().keys(), "APIToken"]

View File

@ -7,7 +7,6 @@ Some of the converters within are included provisionaly and are marked as such.
"""
import functools
import re
import warnings
from datetime import timedelta
from typing import (
TYPE_CHECKING,
@ -155,57 +154,6 @@ class GuildConverter(discord.Guild):
return ret
class _APIToken(discord.ext.commands.Converter):
"""Converts to a `dict` object.
This will parse the input argument separating the key value pairs into a
format to be used for the core bots API token storage.
This will split the argument by a space, comma, or semicolon and return a dict
to be stored. Since all API's are different and have different naming convention,
this leaves the onus on the cog creator to clearly define how to setup the correct
credential names for their cogs.
Note: Core usage of this has been replaced with `DictConverter` use instead.
.. warning::
This will be removed in the first minor release after 2020-08-05.
"""
async def convert(self, ctx: "Context", argument) -> dict:
bot = ctx.bot
result = {}
match = re.split(r";|,| ", argument)
# provide two options to split incase for whatever reason one is part of the api key we're using
if len(match) > 1:
result[match[0]] = "".join(r for r in match[1:])
else:
raise BadArgument(_("The provided tokens are not in a valid format."))
if not result:
raise BadArgument(_("The provided tokens are not in a valid format."))
return result
_APIToken.__name__ = "APIToken"
def __getattr__(name: str, *, stacklevel: int = 2) -> Any:
# honestly, this is awesome (PEP-562)
if name == "APIToken":
warnings.warn(
"`APIToken` is deprecated since Red 3.3.0 and will be removed"
" in the first minor release after 2020-08-05. Use `DictConverter` instead.",
DeprecationWarning,
stacklevel=stacklevel,
)
return globals()["_APIToken"]
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
def __dir__() -> List[str]:
return [*globals().keys(), "APIToken"]
# Below this line are a lot of lies for mypy about things that *end up* correct when
# These are used for command conversion purposes. Please refer to the portion
# which is *not* for type checking for the actual implementation

View File

@ -1,7 +1,6 @@
from __future__ import annotations
import asyncio
import warnings
from asyncio import AbstractEventLoop, as_completed, Semaphore
from asyncio import as_completed, Semaphore
from asyncio.futures import isfuture
from itertools import chain
from typing import (
@ -155,10 +154,7 @@ async def _sem_wrapper(sem, task):
def bounded_gather_iter(
*coros_or_futures,
loop: Optional[AbstractEventLoop] = None,
limit: int = 4,
semaphore: Optional[Semaphore] = None,
*coros_or_futures, limit: int = 4, semaphore: Optional[Semaphore] = None,
) -> Iterator[Awaitable[Any]]:
"""
An iterator that returns tasks as they are ready, but limits the
@ -168,8 +164,6 @@ def bounded_gather_iter(
----------
*coros_or_futures
The awaitables to run in a bounded concurrent fashion.
loop : asyncio.AbstractEventLoop
The event loop to use for the semaphore and :meth:`asyncio.gather`.
limit : Optional[`int`]
The maximum number of concurrent tasks. Used when no ``semaphore``
is passed.
@ -182,14 +176,6 @@ def bounded_gather_iter(
TypeError
When invalid parameters are passed
"""
if loop is not None:
warnings.warn(
"`loop` kwarg is deprecated since Red 3.3.1. It is currently being ignored"
" and will be removed in the first minor release after 2020-08-05.",
DeprecationWarning,
stacklevel=2,
)
loop = asyncio.get_running_loop()
if semaphore is None:
@ -212,7 +198,6 @@ def bounded_gather_iter(
def bounded_gather(
*coros_or_futures,
loop: Optional[AbstractEventLoop] = None,
return_exceptions: bool = False,
limit: int = 4,
semaphore: Optional[Semaphore] = None,
@ -224,8 +209,6 @@ def bounded_gather(
----------
*coros_or_futures
The awaitables to run in a bounded concurrent fashion.
loop : asyncio.AbstractEventLoop
The event loop to use for the semaphore and :meth:`asyncio.gather`.
return_exceptions : bool
If true, gather exceptions in the result list instead of raising.
limit : Optional[`int`]
@ -240,14 +223,6 @@ def bounded_gather(
TypeError
When invalid parameters are passed
"""
if loop is not None:
warnings.warn(
"`loop` kwarg is deprecated since Red 3.3.1. It is currently being ignored"
" and will be removed in the first minor release after 2020-08-05.",
DeprecationWarning,
stacklevel=2,
)
loop = asyncio.get_running_loop()
if semaphore is None:

View File

@ -5,8 +5,7 @@
import asyncio
import contextlib
import functools
import warnings
from typing import Iterable, List, Optional, Union
from typing import Iterable, List, Union
import discord
from .. import commands
@ -170,9 +169,7 @@ async def close_menu(
def start_adding_reactions(
message: discord.Message,
emojis: Iterable[_ReactableEmoji],
loop: Optional[asyncio.AbstractEventLoop] = None,
message: discord.Message, emojis: Iterable[_ReactableEmoji],
) -> asyncio.Task:
"""Start adding reactions to a message.
@ -184,18 +181,12 @@ def start_adding_reactions(
reaction whilst the reactions are still being added - in fact,
this is exactly what `menu` uses to do that.
This spawns a `asyncio.Task` object and schedules it on ``loop``.
If ``loop`` omitted, the loop will be retrieved with
`asyncio.get_event_loop`.
Parameters
----------
message: discord.Message
The message to add reactions to.
emojis : Iterable[Union[str, discord.Emoji]]
The emojis to react to the message with.
loop : Optional[asyncio.AbstractEventLoop]
The event loop.
Returns
-------
@ -210,17 +201,7 @@ def start_adding_reactions(
for emoji in emojis:
await message.add_reaction(emoji)
if loop is None:
loop = asyncio.get_running_loop()
else:
warnings.warn(
"`loop` kwarg is deprecated since Red 3.3.1. It is currently being ignored"
" and will be removed in the first minor release after 2020-08-05.",
DeprecationWarning,
stacklevel=2,
)
return loop.create_task(task())
return asyncio.create_task(task())
DEFAULT_CONTROLS = {