Made Pylint happy

This commit is contained in:
Vegard Berg 2022-10-15 03:35:42 +02:00
parent 8aec106671
commit 2c93e81be0
Signed by: myrkvi
GPG Key ID: BFE35EA1A44D5E40
7 changed files with 53 additions and 66 deletions

View File

@ -4,12 +4,9 @@ from os import getenv
from naff import (
Client,
Intents,
OptionTypes,
Permissions,
listen,
slash_command,
InteractionContext,
slash_option,
)
from naff.api import events
from naff.models.discord.embed import (
@ -19,10 +16,8 @@ from naff.models.discord.embed import (
EmbedFooter,
)
from database import GuildSettings as GuildSettingsModel, JoinLeave
from dotenv import load_dotenv
from database import GuildSettings as GuildSettingsModel, JoinLeave
bot = Client(intents=Intents.ALL, debug_scope=387153131378835456)
@ -86,7 +81,6 @@ async def on_member_leave(event: events.MemberRemove):
@slash_command(name="ping", description="Ping the bot")
async def ping_command(ctx: InteractionContext):
ctx.ephemeral = True

View File

@ -1,3 +1,4 @@
# pylint: disable=consider-using-f-string
import logging
from typing import Optional
from naff import (

View File

@ -6,7 +6,6 @@ from naff import (
Client,
Extension,
slash_command,
slash_option,
InteractionContext,
Modal,
ParagraphText,
@ -22,7 +21,7 @@ from database import BotMessages as BotMessagesModel
# Template modal for creating/editing bot messages.
message_creation_modal = Modal(
custom_id="bot-message-create",
title=f"Create a message as the bot",
title="Create a message as the bot",
components=[
ParagraphText(
custom_id="embeds",
@ -52,7 +51,6 @@ class BotMessages(Extension):
default_member_permissions=Permissions.MANAGE_GUILD,
)
async def bot_message_create_command(self, ctx: InteractionContext):
# Respond with the template modal. No values have been set in the modal, as it is
# a new message.
await ctx.send_modal(message_creation_modal)

View File

@ -1,5 +1,6 @@
import logging
import random, string
import random
import string
from io import BytesIO
from naff import (
Extension,
@ -17,7 +18,6 @@ from naff import (
SlashCommandChoice,
Button,
ButtonStyles,
Embed,
)
from naff.api import events
from naff.models.discord.enums import Permissions
@ -60,12 +60,12 @@ class Gatekeep(Extension):
),
],
)
async def set_type_command(self, ctx: InteractionContext, type: str):
async def set_type_command(self, ctx: InteractionContext, type_: str):
gk: GatekeepModel
gk, _ = GatekeepModel.get_or_create(guild_id=ctx.guild.id)
gk.gatekeep_method = type
gk.gatekeep_method = type_
gk.save()
await ctx.send(f"Gatekeep type set to {type}", ephemeral=True)
await ctx.send(f"Gatekeep type set to {type_}", ephemeral=True)
@slash_command(
name="gatekeep",
@ -193,7 +193,8 @@ class Gatekeep(Extension):
if not welcome_channel:
await ctx.send(
f"{user.mention} has been approved.\nNB: No welcome channel has been set attempting to DM {user.mention}",
(f"{user.mention} has been approved.\n"
f"NB: No welcome channel has been set attempting to DM {user.mention}"),
ephemeral=True,
)
await user.send(
@ -204,7 +205,8 @@ class Gatekeep(Extension):
channel = await ctx.guild.fetch_channel(jl.message_channel)
if not channel:
await ctx.send(
f"{user.mention} has been approved.\nNB: No welcome channel has been set attempting to DM {user.mention}",
(f"{user.mention} has been approved.\n"
f"NB: No welcome channel has been set attempting to DM {user.mention}"),
ephemeral=True,
)
await user.send(
@ -406,10 +408,6 @@ class Gatekeep(Extension):
await ctx.message.delete()
def setup(client: Client):
GatekeepModel.create_table()
GatekeepCaptchasModel.create_table()

View File

@ -1,3 +1,4 @@
# pylint: disable=unsubscriptable-object
import logging
from typing import List, Optional
from naff import (
@ -63,7 +64,6 @@ class Infractions(Extension):
# await ctx.send(embed=embeds, ephemeral=True)
paginator = Paginator.create_from_embeds(self.client, *embeds)
await paginator.send(ctx)
paginator.send
@slash_command(
name="user-infractions",
@ -226,16 +226,16 @@ class Infractions(Extension):
guild_settings: Optional[GuildSettings] = GuildSettings.get_or_none(GuildSettings.guild_id == int(ctx.guild_id))
if guild_settings is not None:
if guild_settings.admin_channel is not None:
admin_channel = await self.client.fetch_channel(int(guild_settings.admin_channel))
if admin_channel is not None:
await admin_channel.send(embed=Embed(
title=f"Warned {user.display_name} ({user.username}#{user.discriminator}, {user.id})",
description=f"{reason}",
color=infraction_colour(0x0000FF),
fields=[
],
))
if guild_settings.admin_channel is not None:
admin_channel = await self.client.fetch_channel(int(guild_settings.admin_channel))
if admin_channel is not None:
await admin_channel.send(embed=Embed(
title=f"Warned {user.display_name} ({user.username}#{user.discriminator}, {user.id})",
description=f"{reason}",
color=infraction_colour(0x0000FF),
fields=[
],
))
if not silent and warning_msg is None:
await ctx.send(

View File

@ -1,8 +1,10 @@
# pylint: disable=not-an-iterable
# pylint: disable=unsubscriptable-object
# pylint: disable=logging-fstring-interpolation
from datetime import datetime, timedelta
import logging
import json
from time import sleep
from typing import Dict, List, Tuple
from typing import List, Tuple
from naff import (
Client,
Extension,
@ -29,8 +31,8 @@ from naff import (
from naff.api import events
from naff.client.errors import HTTPException
from database import Polls as PollsModel, PollVotes as PollVotesModel
from peewee import fn
from database import Polls as PollsModel, PollVotes as PollVotesModel
PollOptions = List[Tuple[str | None, str]]
@ -114,7 +116,7 @@ def generate_poll_embed(
return embed
def num_to_emoji(num: int) -> str:
def num_to_emoji(num: int) -> str: # pylint: disable=too-many-return-statements
match num:
case 0:
return "0"
@ -140,7 +142,7 @@ def num_to_emoji(num: int) -> str:
return "🔟"
case _:
raise ValueError(f"Invalid number: `num` must be 0 <= num <= 10.")
raise ValueError("Invalid number: `num` must be 0 <= num <= 10.")
class Polls(Extension):
@ -150,7 +152,7 @@ class Polls(Extension):
@listen(events.Ready)
async def on_ready(self):
await self.poll_expiry_check()
self.poll_expiry_check.start()
self.poll_expiry_check.start() # pylint: disable=no-member
@slash_command(
name="polls",
@ -178,7 +180,7 @@ class Polls(Extension):
required=False,
opt_type=OptionTypes.BOOLEAN,
)
async def create_poll(
async def create_poll( # pylint: disable=too-many-locals
self,
ctx: InteractionContext,
*,
@ -307,7 +309,7 @@ class Polls(Extension):
poll_entry.save()
@listen(events.Button)
async def on_button(self, button: events.Button):
async def on_button(self, button: events.Button): #pylint: disable=too-many-branches,too-many-statements
ctx = button.context
# Ensure that the pressed button is a vote button.
@ -404,7 +406,7 @@ class Polls(Extension):
options: PollOptions = json.loads(poll_entry.options)
votes = len(options) * [0]
for i, vote in enumerate(votes_q):
for vote in votes_q:
votes[int(vote.option)] = vote.count
embed = generate_poll_embed(

View File

@ -1,4 +1,4 @@
from re import S
# pylint: disable=not-an-iterable
from typing import Dict, List, Optional, Tuple
import logging
from naff import (
@ -11,7 +11,6 @@ from naff import (
InteractionContext,
Role,
Embed,
EmbedField,
AutocompleteContext,
Select,
SelectOption,
@ -21,7 +20,6 @@ from naff import (
Message,
)
from naff.api import events
from naff import components
from database import (
SelfRoles as SelfRolesModel,
SelfRoleGroups as SelfRoleGroupsModel,
@ -621,10 +619,6 @@ class SelfRoles(Extension):
await ctx.send("Role group message regenerated!", ephemeral=True)
@slash_command(
name="role",
description="Manage your roles",
@ -648,7 +642,7 @@ class SelfRoles(Extension):
)
if role_q is None:
await ctx.send(f"Failed to retrieve self-role.", ephemeral=True)
await ctx.send("Failed to retrieve self-role.", ephemeral=True)
return
role = await ctx.guild.fetch_role(role)
@ -732,7 +726,7 @@ class SelfRoles(Extension):
await ctx.defer(ephemeral=True)
role = await ctx.guild.fetch_role(role)
if role is None:
await ctx.send(f"Failed to retrieve role.", ephemeral=True)
await ctx.send("Failed to retrieve role.", ephemeral=True)
return
if role not in ctx.author.roles: