aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-11-06 17:36:03 -0800
committerGravatar MarkKoz <[email protected]>2019-11-06 17:36:03 -0800
commitad79540f058e5f04bde72dc9dba86533b1e296a2 (patch)
treef4fc0ecf9dbf987fc16c4f5dc11bc78f5f9199cc
parentModeration: use trailing _ instead of leading for variable names (diff)
Use trailing _ instead of leading for some variable names
PEP 8 states the convention is a trailing underscore when used to prevent name conflicts.
-rw-r--r--bot/cogs/eval.py4
-rw-r--r--bot/cogs/filtering.py8
-rw-r--r--bot/cogs/moderation/scheduler.py14
-rw-r--r--bot/interpreter.py4
4 files changed, 15 insertions, 15 deletions
diff --git a/bot/cogs/eval.py b/bot/cogs/eval.py
index 9ce854f2c..00b988dde 100644
--- a/bot/cogs/eval.py
+++ b/bot/cogs/eval.py
@@ -148,7 +148,7 @@ class CodeEval(Cog):
self.env.update(env)
# Ignore this code, it works
- _code = """
+ code_ = """
async def func(): # (None,) -> Any
try:
with contextlib.redirect_stdout(self.stdout):
@@ -162,7 +162,7 @@ async def func(): # (None,) -> Any
""".format(textwrap.indent(code, ' '))
try:
- exec(_code, self.env) # noqa: B102,S102
+ exec(code_, self.env) # noqa: B102,S102
func = self.env['func']
res = await func()
diff --git a/bot/cogs/filtering.py b/bot/cogs/filtering.py
index 4195783f1..1e7521054 100644
--- a/bot/cogs/filtering.py
+++ b/bot/cogs/filtering.py
@@ -43,7 +43,7 @@ class Filtering(Cog):
def __init__(self, bot: Bot):
self.bot = bot
- _staff_mistake_str = "If you believe this was a mistake, please let staff know!"
+ staff_mistake_str = "If you believe this was a mistake, please let staff know!"
self.filters = {
"filter_zalgo": {
"enabled": Filter.filter_zalgo,
@@ -53,7 +53,7 @@ class Filtering(Cog):
"user_notification": Filter.notify_user_zalgo,
"notification_msg": (
"Your post has been removed for abusing Unicode character rendering (aka Zalgo text). "
- f"{_staff_mistake_str}"
+ f"{staff_mistake_str}"
)
},
"filter_invites": {
@@ -63,7 +63,7 @@ class Filtering(Cog):
"content_only": True,
"user_notification": Filter.notify_user_invites,
"notification_msg": (
- f"Per Rule 6, your invite link has been removed. {_staff_mistake_str}\n\n"
+ f"Per Rule 6, your invite link has been removed. {staff_mistake_str}\n\n"
r"Our server rules can be found here: <https://pythondiscord.com/pages/rules>"
)
},
@@ -74,7 +74,7 @@ class Filtering(Cog):
"content_only": True,
"user_notification": Filter.notify_user_domains,
"notification_msg": (
- f"Your URL has been removed because it matched a blacklisted domain. {_staff_mistake_str}"
+ f"Your URL has been removed because it matched a blacklisted domain. {staff_mistake_str}"
)
},
"watch_rich_embeds": {
diff --git a/bot/cogs/moderation/scheduler.py b/bot/cogs/moderation/scheduler.py
index 462c7fc7f..49b61f35e 100644
--- a/bot/cogs/moderation/scheduler.py
+++ b/bot/cogs/moderation/scheduler.py
@@ -304,7 +304,7 @@ class InfractionScheduler(Scheduler):
guild = self.bot.get_guild(constants.Guild.id)
mod_role = guild.get_role(constants.Roles.moderator)
user_id = infraction["user"]
- _type = infraction["type"]
+ type_ = infraction["type"]
id_ = infraction["id"]
log.info(f"Marking infraction #{id_} as inactive (expired).")
@@ -324,14 +324,14 @@ class InfractionScheduler(Scheduler):
log_text = {**log_text, **returned_log} # Merge the logs together
else:
raise ValueError(
- f"Attempted to deactivate an unsupported infraction #{id_} ({_type})!"
+ f"Attempted to deactivate an unsupported infraction #{id_} ({type_})!"
)
except discord.Forbidden:
- log.warning(f"Failed to deactivate infraction #{id_} ({_type}): bot lacks permissions")
+ log.warning(f"Failed to deactivate infraction #{id_} ({type_}): bot lacks permissions")
log_text["Failure"] = f"The bot lacks permissions to do this (role hierarchy?)"
log_content = mod_role.mention
except discord.HTTPException as e:
- log.exception(f"Failed to deactivate infraction #{id_} ({_type})")
+ log.exception(f"Failed to deactivate infraction #{id_} ({type_})")
log_text["Failure"] = f"HTTPException with code {e.code}."
log_content = mod_role.mention
@@ -361,7 +361,7 @@ class InfractionScheduler(Scheduler):
json={"active": False}
)
except ResponseCodeError as e:
- log.exception(f"Failed to deactivate infraction #{id_} ({_type})")
+ log.exception(f"Failed to deactivate infraction #{id_} ({type_})")
log_line = f"API request failed with code {e.status}."
log_content = mod_role.mention
@@ -381,9 +381,9 @@ class InfractionScheduler(Scheduler):
log.trace(f"Sending deactivation mod log for infraction #{id_}.")
await self.mod_log.send_log_message(
- icon_url=utils.INFRACTION_ICONS[_type][1],
+ icon_url=utils.INFRACTION_ICONS[type_][1],
colour=Colours.soft_green,
- title=f"Infraction {log_title}: {_type}",
+ title=f"Infraction {log_title}: {type_}",
text="\n".join(f"{k}: {v}" for k, v in log_text.items()),
footer=f"ID: {id_}",
content=log_content,
diff --git a/bot/interpreter.py b/bot/interpreter.py
index a42b45a2d..76a3fc293 100644
--- a/bot/interpreter.py
+++ b/bot/interpreter.py
@@ -20,8 +20,8 @@ class Interpreter(InteractiveInterpreter):
write_callable = None
def __init__(self, bot: Bot):
- _locals = {"bot": bot}
- super().__init__(_locals)
+ locals_ = {"bot": bot}
+ super().__init__(locals_)
async def run(self, code: str, ctx: Context, io: StringIO, *args, **kwargs) -> Any:
"""Execute the provided source code as the bot & return the output."""