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

@@ -92,11 +92,10 @@ class Admin(commands.Cog):
await self._ready.wait()
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
"""Nothing to delete"""
return
async def handle_migrations(self):
lock = self.config.get_guilds_lock()
async with lock:
# This prevents the edge case of someone loading admin,
@@ -110,7 +109,6 @@ class Admin(commands.Cog):
self._ready.set()
async def migrate_config_from_0_to_1(self):
all_guilds = await self.config.all_guilds()
for guild_id, guild_data in all_guilds.items():

View File

@@ -94,12 +94,10 @@ class Alias(commands.Cog):
all_guild_aliases = await self.config.all_guilds()
for guild_id, guild_data in all_guild_aliases.items():
to_set = []
modified = False
for a in guild_data.get("entries", []):
for keyname in ("creator", "guild"):
if isinstance((val := a.get(keyname)), str):
try:
@@ -134,7 +132,7 @@ class Alias(commands.Cog):
t.add_done_callback(done_callback)
async def _initialize(self):
""" Should only ever be a task """
"""Should only ever be a task"""
await self._maybe_handle_string_keys()
@@ -482,7 +480,6 @@ class Alias(commands.Cog):
@commands.Cog.listener()
async def on_message_without_command(self, message: discord.Message):
await self._ready_event.wait()
if message.guild is not None:

View File

@@ -67,7 +67,6 @@ class AliasEntry:
return extra
def to_json(self) -> dict:
return {
"name": self.name,
"command": self.command,
@@ -91,7 +90,6 @@ class AliasCache:
self._aliases: Dict[Optional[int], Dict[str, AliasEntry]] = {None: {}}
async def anonymize_aliases(self, user_id: int):
async with self.config.entries() as global_aliases:
for a in global_aliases:
if a.get("creator", 0) == user_id:

View File

@@ -182,7 +182,6 @@ class PlaylistCompat23:
tracks: Optional[List[MutableMapping]] = None,
guild: Union[discord.Guild, int, None] = None,
):
self.bot = bot
self.guild = guild
self.scope = standardize_scope(scope)

View File

@@ -192,7 +192,6 @@ class ScopeParser(commands.Converter):
async def convert(
self, ctx: commands.Context, argument: str
) -> Tuple[Optional[str], discord.User, Optional[discord.Guild], bool]:
target_scope: Optional[str] = None
target_user: Optional[Union[discord.Member, discord.User]] = None
target_guild: Optional[discord.Guild] = None
@@ -302,7 +301,6 @@ class ComplexScopeParser(commands.Converter):
Optional[discord.Guild],
bool,
]:
target_scope: Optional[str] = None
target_user: Optional[Union[discord.Member, discord.User]] = None
target_guild: Optional[discord.Guild] = None

View File

@@ -244,7 +244,7 @@ class EqualizerCommands(MixinMeta, metaclass=CompositeMetaClass):
eq_name_msg = await self.bot.wait_for(
"message",
timeout=15.0,
check=MessagePredicate.regex(fr"^(?!{re.escape(ctx.prefix)})", ctx),
check=MessagePredicate.regex(rf"^(?!{re.escape(ctx.prefix)})", ctx),
)
eq_preset = eq_name_msg.content.split(" ")[0].strip('"').lower()
except asyncio.TimeoutError:

View File

@@ -224,7 +224,6 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass):
*,
scope_data: ComplexScopeParser = None,
):
"""Copy a playlist from one scope to another.
**Usage**:
@@ -962,7 +961,6 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass):
scope, author, guild, specified_user = scope_data
async with ctx.typing():
if scope is None:
global_matches = await get_all_playlist(
scope=PlaylistScope.GLOBAL.value,
bot=self.bot,

View File

@@ -31,7 +31,6 @@ class RedEvents(MixinMeta, metaclass=CompositeMetaClass):
requester: Literal["discord_deleted_user", "owner", "user", "user_strict"],
user_id: int,
):
await self.cog_ready_event.wait()
if requester in ("discord_deleted_user", "owner"):

View File

@@ -167,7 +167,6 @@ class FormattingUtilities(MixinMeta, metaclass=CompositeMetaClass):
ctx, title=_("This track is not allowed in this server.")
)
elif guild_data["maxlength"] > 0:
if self.is_track_length_allowed(search_choice, guild_data["maxlength"]):
search_choice.extras.update(
{

View File

@@ -258,7 +258,7 @@ class MiscellaneousUtilities(MixinMeta, metaclass=CompositeMetaClass):
return msg.format(d, h, m, s)
def format_time(self, time: int) -> str:
""" Formats the given time into DD:HH:MM:SS """
"""Formats the given time into DD:HH:MM:SS"""
seconds = time / 1000
days, seconds = divmod(seconds, 24 * 60 * 60)
hours, seconds = divmod(seconds, 60 * 60)

View File

@@ -11,7 +11,7 @@ from ..cog_utils import CompositeMetaClass
log = getLogger("red.cogs.Audio.cog.Utilities.Parsing")
STREAM_TITLE: Final[re.Pattern] = re.compile(br"StreamTitle='([^']*)';")
STREAM_TITLE: Final[re.Pattern] = re.compile(rb"StreamTitle='([^']*)';")
class ParsingUtilities(MixinMeta, metaclass=CompositeMetaClass):

View File

@@ -676,7 +676,6 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
def humanize_scope(
self, scope: str, ctx: Union[discord.Guild, discord.abc.User, str] = None, the: bool = None
) -> Optional[str]:
if scope == PlaylistScope.GLOBAL.value:
return _("the Global") if the else _("Global")
elif scope == PlaylistScope.GUILD.value:

View File

@@ -38,7 +38,7 @@ class Cleanup(commands.Cog):
self.config.register_guild(notify=True)
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
"""Nothing to delete"""
return
@staticmethod
@@ -155,7 +155,7 @@ class Cleanup(commands.Cog):
resolved = reference.resolved
if resolved and isinstance(resolved, discord.Message):
message = resolved
elif (message := reference.cached_message) :
elif message := reference.cached_message:
pass
else:
try:

View File

@@ -6,7 +6,7 @@ from redbot.core.utils.chat_formatting import inline
_ = Translator("Cleanup", __file__)
SNOWFLAKE_THRESHOLD = 2 ** 63
SNOWFLAKE_THRESHOLD = 2**63
class RawMessageIds(Converter):

View File

@@ -59,7 +59,6 @@ class CommandObj:
return {k: v for k, v in _commands.items() if _commands[k]}
async def redact_author_ids(self, user_id: int):
all_guilds = await self.config.all_guilds()
for guild_id in all_guilds.keys():

View File

@@ -349,7 +349,6 @@ class Economy(commands.Cog):
).format(author=author, time=dtime)
)
else:
# Gets the users latest successfully payday and adds the guilds payday time
next_payday = (
await self.config.member(author).next_payday()

View File

@@ -349,7 +349,7 @@ class Filter(commands.Cog):
def invalidate_cache(
self, guild: discord.Guild, channel: Optional[discord.TextChannel] = None
) -> None:
""" Invalidate a cached pattern"""
"""Invalidate a cached pattern"""
self.pattern_cache.pop((guild.id, channel and channel.id), None)
if channel is None:
for keyset in list(self.pattern_cache.keys()): # cast needed, no remove
@@ -399,7 +399,6 @@ class Filter(commands.Cog):
async def filter_hits(
self, text: str, server_or_channel: Union[discord.Guild, discord.TextChannel]
) -> Set[str]:
try:
guild = server_or_channel.guild
channel = server_or_channel
@@ -528,7 +527,6 @@ class Filter(commands.Cog):
await self.maybe_filter_name(member)
async def maybe_filter_name(self, member: discord.Member):
guild = member.guild
if (not guild) or await self.bot.cog_disabled_in_guild(self, guild):
return

View File

@@ -39,7 +39,7 @@ class RPSParser:
self.choice = None
MAX_ROLL: Final[int] = 2 ** 64 - 1
MAX_ROLL: Final[int] = 2**64 - 1
@cog_i18n(_)
@@ -77,7 +77,7 @@ class General(commands.Cog):
self.stopwatches = {}
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
"""Nothing to delete"""
return
@commands.command(usage="<first> <second> [others...]")

View File

@@ -28,7 +28,7 @@ class Image(commands.Cog):
self.session.detach()
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
"""Nothing to delete"""
return
async def initialize(self) -> None:

View File

@@ -226,7 +226,6 @@ class ModInfo(MixinMeta):
status_string = self.get_status_string(member)
if roles:
role_str = ", ".join([x.mention for x in roles])
# 400 BAD REQUEST (error code: 50035): Invalid Form Body
# In embed.fields.2.value: Must be 1024 or fewer in length.

View File

@@ -24,7 +24,7 @@ class ModLog(commands.Cog):
self.bot = bot
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
"""Nothing to delete"""
return
@commands.command()

View File

@@ -1065,7 +1065,6 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
if ctx.guild.id in self._server_mutes:
mutes_data = self._server_mutes[ctx.guild.id]
if mutes_data:
msg += _("__Server Mutes__\n")
for user_id, mutes in mutes_data.items():
if not mutes:
@@ -1528,7 +1527,6 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
mute_role = await self.config.guild(guild).mute_role()
if mute_role:
role = guild.get_role(mute_role)
if not role:
ret["reason"] = _(MUTE_UNMUTE_ISSUES["role_missing"])
@@ -1601,8 +1599,8 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
if not await self.is_allowed_by_hierarchy(guild, author, user):
ret["reason"] = _(MUTE_UNMUTE_ISSUES["hierarchy_problem"])
return ret
if mute_role:
if mute_role:
role = guild.get_role(mute_role)
if not role:
ret["reason"] = _(MUTE_UNMUTE_ISSUES["role_missing"])

View File

@@ -55,7 +55,6 @@ class VoiceMutes(MixinMeta):
ctx.permission_state is commands.PermState.NORMAL
and not voice_channel.permissions_for(ctx.author) >= required_perms
):
return (
False,
_(

View File

@@ -131,7 +131,6 @@ class Permissions(commands.Cog):
# there's a below recast to int where needed for guild ids
for typename, getter in ((COG, self.bot.get_cog), (COMMAND, self.bot.get_command)):
obj_type_rules = await self.config.custom(typename).all()
count += 1
@@ -139,7 +138,6 @@ class Permissions(commands.Cog):
await asyncio.sleep(0)
for obj_name, rules_dict in obj_type_rules.items():
count += 1
if not count % 100:
await asyncio.sleep(0)
@@ -147,7 +145,6 @@ class Permissions(commands.Cog):
obj = getter(obj_name)
for guild_id, guild_rules in rules_dict.items():
count += 1
if not count % 100:
await asyncio.sleep(0)

View File

@@ -356,11 +356,9 @@ class Reports(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message: discord.Message):
to_remove = []
for k, v in self.tunnel_store.items():
guild, ticket_number = k
if await self.bot.cog_disabled_in_guild(self, guild):
to_remove.append(k)

View File

@@ -83,7 +83,7 @@ class Streams(commands.Cog):
self._init_task: asyncio.Task = asyncio.create_task(self.initialize())
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
"""Nothing to delete"""
return
def check_name_or_id(self, data: str) -> bool:

View File

@@ -263,7 +263,6 @@ class YoutubeStream(Stream):
return snippet["title"]
async def _fetch_channel_resource(self, resource: str):
params = {"key": self._token["api_key"], "part": resource}
if resource == "id":
params["forUsername"] = self.name
@@ -334,8 +333,8 @@ class TwitchStream(Stream):
"""
current_time = int(time.time())
self._rate_limit_resets = {x for x in self._rate_limit_resets if x > current_time}
if self._rate_limit_remaining == 0:
if self._rate_limit_remaining == 0:
if self._rate_limit_resets:
reset_time = next(iter(self._rate_limit_resets))
# Calculate wait time and add 0.1s to the wait time to allow Twitch to reset