From 085e4459b9405742047db2aecaa91fd0d3afa841 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 24 Sep 2021 21:36:53 +0200 Subject: [PATCH] Fix pylint issues --- .pylintrc | 22 ++++++++++++++++++++++ src/bot.py | 23 +++++++++++------------ 2 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..6df1145 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,22 @@ +[MASTER] +init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()) + '/src'); sys.path.append(os.path.dirname(find_pylintrc()) + '/test')" + +[MESSAGES CONTROL] +disable= + missing-module-docstring, + missing-class-docstring, + missing-function-docstring, + global-statement, + too-many-arguments, + too-few-public-methods, + wrong-import-position, + redefined-outer-name, + invalid-name, + no-self-use + +[FORMAT] +indent-string=' ' +max-line-length=160 + +[SIMILARITIES] +ignore-comments = no \ No newline at end of file diff --git a/src/bot.py b/src/bot.py index eddb57c..3108022 100644 --- a/src/bot.py +++ b/src/bot.py @@ -1,5 +1,5 @@ -import asyncio import os +import sys import discord from discord.ext import commands @@ -28,9 +28,9 @@ class Music(commands.Cog): """Plays a file from the local filesystem""" source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query)) - ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None) + ctx.voice_client.play(source, after=lambda e: print(f"Player error: {e}") if e else None) - await ctx.send('Now playing: {}'.format(query)) + await ctx.send(f"Now playing: {query}") @commands.command() async def yt(self, ctx, *, url): @@ -38,9 +38,9 @@ class Music(commands.Cog): async with ctx.typing(): player = await YTDLSource.from_url(url, loop=self.bot.loop) - ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None) + ctx.voice_client.play(player, after=lambda e: print(f"Player error: {e}") if e else None) - await ctx.send('Now playing: {}'.format(player.title)) + await ctx.send(f"Now playing: {player.title}") @commands.command() async def stream(self, ctx, *, url): @@ -48,9 +48,9 @@ class Music(commands.Cog): async with ctx.typing(): player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True) - ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None) + ctx.voice_client.play(player, after=lambda e: print(f"Player error: {e}") if e else None) - await ctx.send('Now playing: {}'.format(player.title)) + await ctx.send(f"Now playing: {player.title}") @commands.command() async def volume(self, ctx, volume: int): @@ -60,7 +60,7 @@ class Music(commands.Cog): return await ctx.send("Not connected to a voice channel.") ctx.voice_client.source.volume = volume / 100 - await ctx.send("Changed volume to {}%".format(volume)) + await ctx.send(f"Changed volume to {volume}%") @commands.command() async def stop(self, ctx): @@ -82,13 +82,12 @@ class Music(commands.Cog): ctx.voice_client.stop() -bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), - description='Relatively simple music bot example') +bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), description='Relatively simple music bot example') @bot.event async def on_ready(): - print('Logged in as {0} ({0.id})'.format(bot.user)) + print(f"Logged in as {bot.user} ({bot.user.id})") print('------') bot.add_cog(Music(bot)) @@ -96,6 +95,6 @@ bot.add_cog(Music(bot)) token = os.environ.get("BOT_TOKEN", None) if not token: print("No token fouund in BOT_TOKEN") - exit(1) + sys.exit(1) bot.run(token)