mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
Remove things past deprecation time (2020-08-05) (#4163)
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user