Reformat with Black 22.1.0

This commit is contained in:
jack1142
2022-03-22 18:06:46 +01:00
parent f6d9632c8f
commit c69e8d31fd
39 changed files with 25 additions and 78 deletions

View File

@@ -46,7 +46,7 @@ __all__ = [
"is_owner_if_bank_global",
]
_MAX_BALANCE = 2 ** 63 - 1
_MAX_BALANCE = 2**63 - 1
_SCHEMA_VERSION = 1

View File

@@ -489,7 +489,7 @@ class Red(
@property
def uptime(self) -> datetime:
""" Allow access to the value, but we don't want cog creators setting it """
"""Allow access to the value, but we don't want cog creators setting it"""
return self._uptime
@uptime.setter

View File

@@ -316,7 +316,7 @@ class CogManagerUI(commands.Cog):
"""Commands to interface with Red's cog manager."""
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete (Core Config is handled in a bot method ) """
"""Nothing to delete (Core Config is handled in a bot method )"""
return
@commands.command()

View File

@@ -72,7 +72,7 @@ DisablerDictType = MutableMapping[discord.Guild, Callable[["Context"], Awaitable
class RedUnhandledAPI(Exception):
""" An exception which can be raised to signal a lack of handling specific APIs """
"""An exception which can be raised to signal a lack of handling specific APIs"""
pass
@@ -661,7 +661,6 @@ class Command(CogCommandMixin, DPYCommand):
@a_command.error
async def a_command_error_handler(self, ctx, error):
if isinstance(error.original, MyErrorType):
self.log_exception(error.original)
else:
@@ -1131,10 +1130,10 @@ class _RuleDropper(CogCommandMixin):
"""
def allow_for(self, model_id: Union[int, str], guild_id: int) -> None:
""" This will do nothing. """
"""This will do nothing."""
def deny_to(self, model_id: Union[int, str], guild_id: int) -> None:
""" This will do nothing. """
"""This will do nothing."""
def clear_rule_for(
self, model_id: Union[int, str], guild_id: int
@@ -1146,7 +1145,7 @@ class _RuleDropper(CogCommandMixin):
return cur_rule, cur_rule
def set_default_rule(self, rule: Optional[bool], guild_id: int) -> None:
""" This will do nothing. """
"""This will do nothing."""
class _AlwaysAvailableCommand(_AlwaysAvailableMixin, _RuleDropper, Command):

View File

@@ -93,7 +93,7 @@ class Context(DPYContext):
return await super().send(content=content, **kwargs)
async def send_help(self, command=None):
""" Send the command help message. """
"""Send the command help message."""
# This allows people to manually use this similarly
# to the upstream d.py version, while retaining our use.
command = command or self.command
@@ -360,7 +360,6 @@ if TYPE_CHECKING or os.getenv("BUILDING_DOCS", False):
def me(self) -> discord.Member:
...
else:
GuildContext = Context
DMContext = Context

View File

@@ -274,7 +274,6 @@ if TYPE_CHECKING:
def get_dict_converter(*expected_keys: str, delims: Optional[List[str]] = None) -> Type[dict]:
...
else:
def get_dict_converter(*expected_keys: str, delims: Optional[List[str]] = None) -> Type[dict]:
@@ -354,7 +353,6 @@ if TYPE_CHECKING:
) -> Type[timedelta]:
...
else:
def get_timedelta_converter(

View File

@@ -107,7 +107,7 @@ class HelpSettings:
@property
def pretty(self):
""" Returns a discord safe representation of the settings """
"""Returns a discord safe representation of the settings"""
def bool_transformer(val):
if val is False:
@@ -306,7 +306,6 @@ class RedHelpFormatter(HelpFormatterABC):
async def format_command_help(
self, ctx: Context, obj: commands.Command, help_settings: HelpSettings
):
send = help_settings.verify_exists
if not send:
async for __ in self.help_filter_func(
@@ -450,7 +449,6 @@ class RedHelpFormatter(HelpFormatterABC):
@staticmethod
def group_embed_fields(fields: List[EmbedField], max_chars=1000):
curr_group = []
ret = []
current_count = 0
@@ -473,7 +471,6 @@ class RedHelpFormatter(HelpFormatterABC):
return ret
async def make_and_send_embeds(self, ctx, embed_dict: dict, help_settings: HelpSettings):
pages = []
page_char_limit = help_settings.page_char_limit
@@ -544,7 +541,6 @@ class RedHelpFormatter(HelpFormatterABC):
await self.send_pages(ctx, pages, embed=True, help_settings=help_settings)
async def format_cog_help(self, ctx: Context, obj: commands.Cog, help_settings: HelpSettings):
coms = await self.get_cog_help_mapping(ctx, obj, help_settings=help_settings)
if not (coms or help_settings.verify_exists):
return
@@ -613,7 +609,6 @@ class RedHelpFormatter(HelpFormatterABC):
await self.send_pages(ctx, pages, embed=False, help_settings=help_settings)
async def format_bot_help(self, ctx: Context, help_settings: HelpSettings):
coms = await self.get_bot_help_mapping(ctx, help_settings=help_settings)
if not coms:
return
@@ -622,7 +617,6 @@ class RedHelpFormatter(HelpFormatterABC):
tagline = (help_settings.tagline) or self.get_default_tagline(ctx)
if await self.embed_requested(ctx):
emb = {"embed": {"title": "", "description": ""}, "footer": {"text": ""}, "fields": []}
emb["footer"]["text"] = tagline
@@ -630,7 +624,6 @@ class RedHelpFormatter(HelpFormatterABC):
emb["embed"]["title"] = f"*{description[:250]}*"
for cog_name, data in coms:
if cog_name:
title = underline(bold(f"{cog_name}:"), escape_formatting=False)
else:
@@ -676,7 +669,6 @@ class RedHelpFormatter(HelpFormatterABC):
yield nm, doc, max_width - width_gap
for cog_name, data in coms:
title = f"{cog_name}:" if cog_name else _("No Category:")
to_join.append(title)
@@ -830,7 +822,6 @@ class RedHelpFormatter(HelpFormatterABC):
and channel_permissions.read_message_history
and help_settings.use_menus
):
max_pages_in_guild = help_settings.max_pages_in_guild
use_DMs = len(pages) > max_pages_in_guild
destination = ctx.author if use_DMs else ctx.channel
@@ -862,7 +853,6 @@ class RedHelpFormatter(HelpFormatterABC):
and delete_delay > 0 # delete delay is enabled
and channel_permissions.manage_messages # we can manage messages here
):
# We need to wrap this in a task to not block after-sending-help interactions.
# The channel has to be TextChannel as we can't bulk-delete from DMs
async def _delete_delay_help(

View File

@@ -268,7 +268,6 @@ PermStateAllowedStates = (
def transition_permstate_to(prev: PermState, next_state: PermState) -> TransitionResult:
# Transforms here are used so that the
# informational ALLOWED_BY_HOOK/DENIED_BY_HOOK
# remain, while retaining the behavior desired.

View File

@@ -645,7 +645,6 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
)
async def get_serious_confirmation(self, ctx: commands.Context, prompt: str) -> bool:
confirm_token = "".join(random.choices((*ascii_letters, *digits), k=8))
await ctx.send(f"{prompt}\n\n{confirm_token}")
@@ -4002,9 +4001,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
)
else:
successful = True
else:
msg_text = "{}\nMessage:\n\n{}\n{}".format(description, message, footer)
try:

View File

@@ -198,7 +198,6 @@ def init_events(bot, cli_flags):
@bot.event
async def on_command_error(ctx, error, unhandled_by_cog=False):
if not unhandled_by_cog:
if hasattr(ctx.command, "on_error"):
return

View File

@@ -98,7 +98,6 @@ async def _init(bot: Red):
await register_casetypes(all_generics)
async def on_member_ban(guild: discord.Guild, member: discord.Member):
if not guild.me.guild_permissions.view_audit_log:
return

View File

@@ -178,7 +178,6 @@ class IgnoreManager:
async def set_ignored_channel(
self, channel: Union[discord.TextChannel, discord.CategoryChannel], set_to: bool
):
cid: int = channel.id
self._cached_channels[cid] = set_to
if set_to:
@@ -200,7 +199,6 @@ class IgnoreManager:
return ret
async def set_ignored_guild(self, guild: discord.Guild, set_to: bool):
gid: int = guild.id
self._cached_guilds[gid] = set_to
if set_to:
@@ -221,9 +219,7 @@ class WhitelistBlacklistManager:
self._access_lock = asyncio.Lock()
async def discord_deleted_user(self, user_id: int):
async with self._access_lock:
async for guild_id_or_none, ids in AsyncIter(
self._cached_whitelist.items(), steps=100
):