[V3] Update code standards (black code format pass) (#1650)

* ran black: code formatter against `redbot/` with `-l 99`

* badge
This commit is contained in:
Michael H
2018-05-14 15:33:24 -04:00
committed by Will
parent e7476edd68
commit b88b5a2601
90 changed files with 3629 additions and 3223 deletions

View File

@@ -3,8 +3,12 @@ from collections import namedtuple
import discord
import asyncio
from redbot.cogs.warnings.helpers import warning_points_add_check, get_command_for_exceeded_points, \
get_command_for_dropping_points, warning_points_remove_check
from redbot.cogs.warnings.helpers import (
warning_points_add_check,
get_command_for_exceeded_points,
get_command_for_dropping_points,
warning_points_remove_check,
)
from redbot.core import Config, modlog, checks, commands
from redbot.core.bot import Red
from redbot.core.i18n import Translator, cog_i18n
@@ -18,17 +22,9 @@ _ = Translator("Warnings", __file__)
class Warnings:
"""A warning system for Red"""
default_guild = {
"actions": [],
"reasons": {},
"allow_custom_reasons": False
}
default_guild = {"actions": [], "reasons": {}, "allow_custom_reasons": False}
default_member = {
"total_points": 0,
"status": "",
"warnings": {}
}
default_member = {"total_points": 0, "status": "", "warnings": {}}
def __init__(self, bot: Red):
self.config = Config.get_conf(self, identifier=5757575755)
@@ -41,9 +37,7 @@ class Warnings:
@staticmethod
async def register_warningtype():
try:
await modlog.register_casetype(
"warning", True, "\N{WARNING SIGN}", "Warning", None
)
await modlog.register_casetype("warning", True, "\N{WARNING SIGN}", "Warning", None)
except RuntimeError:
pass
@@ -105,7 +99,7 @@ class Warnings:
"action_name": name,
"points": points,
"exceed_command": exceed_command,
"drop_command": drop_command
"drop_command": drop_command,
}
# Have all details for the action, now save the action
@@ -138,9 +132,7 @@ class Warnings:
registered_actions.remove(to_remove)
await ctx.tick()
else:
await ctx.send(
_("No action named {} exists!").format(action_name)
)
await ctx.send(_("No action named {} exists!").format(action_name))
@commands.group()
@commands.guild_only()
@@ -159,13 +151,8 @@ class Warnings:
if name.lower() == "custom":
await ctx.send("That cannot be used as a reason name!")
return
to_add = {
"points": points,
"description": description
}
completed = {
name.lower(): to_add
}
to_add = {"points": points, "description": description}
completed = {name.lower(): to_add}
guild_settings = self.config.guild(guild)
@@ -219,8 +206,7 @@ class Warnings:
msg_list.append(
"Name: {}\nPoints: {}\nExceed command: {}\n"
"Drop command: {}".format(
r["action_name"], r["points"], r["exceed_command"],
r["drop_command"]
r["action_name"], r["points"], r["exceed_command"], r["drop_command"]
)
)
if msg_list:
@@ -262,7 +248,7 @@ class Warnings:
str(ctx.message.id): {
"points": reason_type["points"],
"description": reason_type["description"],
"mod": ctx.author.id
"mod": ctx.author.id,
}
}
async with member_settings.warnings() as user_warnings:
@@ -275,7 +261,7 @@ class Warnings:
@commands.command()
@commands.guild_only()
async def warnings(self, ctx: commands.Context, userid: int=None):
async def warnings(self, ctx: commands.Context, userid: int = None):
"""Show warnings for the specified user.
If userid is None, show warnings for the person running the command
Note that showing warnings for users other than yourself requires
@@ -285,10 +271,7 @@ class Warnings:
else:
if not await is_admin_or_superior(self.bot, ctx.author):
await ctx.send(
warning(
_("You are not allowed to check "
"warnings for other users!")
)
warning(_("You are not allowed to check " "warnings for other users!"))
)
return
else:
@@ -305,22 +288,14 @@ class Warnings:
mod = ctx.guild.get_member(user_warnings[key]["mod"])
if mod is None:
mod = discord.utils.get(
self.bot.get_all_members(),
id=user_warnings[key]["mod"]
self.bot.get_all_members(), id=user_warnings[key]["mod"]
)
if mod is None:
mod = await self.bot.get_user_info(
user_warnings[key]["mod"]
)
mod = await self.bot.get_user_info(user_warnings[key]["mod"])
msg += "{} point warning {} issued by {} for {}\n".format(
user_warnings[key]["points"],
key,
mod,
user_warnings[key]["description"]
user_warnings[key]["points"], key, mod, user_warnings[key]["description"]
)
await ctx.send_interactive(
pagify(msg), box_lang="Warnings for {}".format(user)
)
await ctx.send_interactive(pagify(msg), box_lang="Warnings for {}".format(user))
@commands.command()
@commands.guild_only()
@@ -348,10 +323,7 @@ class Warnings:
@staticmethod
async def custom_warning_reason(ctx: commands.Context):
"""Handles getting description and points for custom reasons"""
to_add = {
"points": 0,
"description": ""
}
to_add = {"points": 0, "description": ""}
def same_author_check(m):
return m.author == ctx.author