Skip to content

Commit 1e7ddcf

Browse files
committed
Reorganize imports
1 parent 5969a4b commit 1e7ddcf

File tree

7 files changed

+31
-17
lines changed

7 files changed

+31
-17
lines changed

cogs/modmail.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from typing import Optional, Union
44

55
import discord
6-
from dateutil import parser
76
from discord.ext import commands
7+
8+
from dateutil import parser
89
from natural.date import duration
910

1011
from core import checks
@@ -615,7 +616,7 @@ async def contact(self, ctx,
615616
embed = discord.Embed(
616617
color=discord.Color.red(),
617618
description='A thread for this user already '
618-
f'exists in {exists.channel.mention}.'
619+
f'exists in {exists.channel.mention}.'
619620
)
620621

621622
else:

cogs/plugins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import subprocess
77
import sys
88

9-
from colorama import Fore, Style
109
from discord.ext import commands
1110

11+
from colorama import Fore, Style
12+
1213
from core.models import Bot
1314

1415

cogs/utility.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
from textwrap import indent
99

1010
import discord
11-
from aiohttp import ClientResponseError
1211
from discord import Embed, Color, Activity
1312
from discord.enums import ActivityType
1413
from discord.ext import commands
1514

15+
from aiohttp import ClientResponseError
16+
1617
from core import checks
1718
from core.changelog import Changelog
1819
from core.decorators import github_access_token_required, trigger_typing
@@ -27,13 +28,15 @@ class Utility:
2728
def __init__(self, bot: Bot):
2829
self.bot = bot
2930

30-
async def check_checks(self, ctx, cmd):
31+
@staticmethod
32+
async def verify_checks(ctx, cmd):
3133
predicates = cmd.checks
3234
if not predicates:
3335
return True
3436

3537
try:
36-
return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
38+
return await discord.utils.async_all(predicate(ctx)
39+
for predicate in predicates)
3740
except commands.CheckFailure:
3841
return False
3942

@@ -45,7 +48,8 @@ async def format_cog_help(self, ctx, cog):
4548
fmts = ['']
4649
for cmd in sorted(self.bot.commands,
4750
key=lambda cmd: cmd.qualified_name):
48-
if cmd.instance is cog and not cmd.hidden and await self.check_checks(ctx, cmd):
51+
if cmd.instance is cog and not cmd.hidden and \
52+
await self.verify_checks(ctx, cmd):
4953
new_fmt = f'`{prefix + cmd.qualified_name}` - '
5054
new_fmt += f'{cmd.short_doc}\n'
5155
if len(new_fmt) + len(fmts[-1]) >= 1024:
@@ -58,7 +62,8 @@ async def format_cog_help(self, ctx, cog):
5862
if fmt == '':
5963
continue
6064
embed = Embed(
61-
description='*' + (inspect.getdoc(cog) or 'No description') + '*',
65+
description='*' + (inspect.getdoc(cog) or
66+
'No description') + '*',
6267
color=self.bot.main_color
6368
)
6469

@@ -73,7 +78,7 @@ async def format_cog_help(self, ctx, cog):
7378

7479
async def format_command_help(self, ctx, cmd):
7580
"""Formats command help."""
76-
if cmd.hidden or not await self.check_checks(ctx, cmd):
81+
if cmd.hidden or not await self.verify_checks(ctx, cmd):
7782
return None
7883

7984
prefix = self.bot.prefix
@@ -117,13 +122,14 @@ async def format_not_found(self, ctx, command):
117122
# filter out hidden commands & blank cogs
118123
for i in self.bot.cogs:
119124
for cmd in self.bot.commands:
120-
if cmd.cog_name == i and not cmd.hidden and await self.check_checks(ctx, cmd):
125+
if cmd.cog_name == i and not cmd.hidden and \
126+
await self.verify_checks(ctx, cmd):
121127
# as long as there's one valid cmd, add cog
122128
choices.add(i)
123129
break
124130

125131
for i in self.bot.commands:
126-
if not i.hidden and await self.check_checks(ctx, i):
132+
if not i.hidden and await self.verify_checks(ctx, i):
127133
choices.add(i.name)
128134

129135
closest = get_close_matches(command, choices, n=1, cutoff=0.45)

core/clients.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from json import JSONDecodeError
44
from typing import Union, Optional
55

6-
from aiohttp import ClientResponseError, ClientResponse
76
from discord import Member, DMChannel
87
from discord.ext import commands
98

9+
from aiohttp import ClientResponseError, ClientResponse
10+
1011
from core.models import Bot, UserClient
1112

1213

core/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import typing
44
from datetime import datetime
55

6-
from aiohttp import ClientSession
76
from discord import Color, Member, User, CategoryChannel, DMChannel, Embed
87
from discord import Message, TextChannel, Guild
98
from discord.ext import commands
9+
10+
from aiohttp import ClientSession
1011
from motor.motor_asyncio import AsyncIOMotorClient
1112

1213

core/time.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import re
77
from datetime import datetime
88

9+
from discord.ext.commands import BadArgument, Converter
10+
911
import parsedatetime as pdt
1012
from dateutil.relativedelta import relativedelta
11-
from discord.ext.commands import BadArgument, Converter
1213

1314

1415
class ShortTime:

core/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
from discord import Object
66
from discord.ext import commands
77

8+
89
class SafeDict(dict):
910
def __missing__(self, key):
1011
return '{' + key + '}'
11-
12-
def safeformat(str, **kwargs):
12+
13+
14+
def safeformat(s, **kwargs):
1315
replacements = SafeDict(**kwargs)
14-
return str.format_map(replacements)
16+
return s.format_map(replacements)
17+
1518

1619
class User(commands.IDConverter):
1720
"""

0 commit comments

Comments
 (0)