aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar S. Co1 <[email protected]>2019-09-05 18:35:04 -0400
committerGravatar S. Co1 <[email protected]>2019-09-05 18:35:04 -0400
commitd982254a79ca3e34c9f50e072a925fe6b8a12ed1 (patch)
tree689691b7ede87b0b5202e4a5844c4a06b179a471
parentUpdate Snakes and Ladders (diff)
Fix misconfigured flake8 so docstrings are properly linted
Relint
-rw-r--r--bot/seasons/christmas/adventofcode.py2
-rw-r--r--bot/seasons/easter/avatar_easterifier.py2
-rw-r--r--bot/seasons/easter/bunny_name_generator.py10
-rw-r--r--bot/seasons/easter/easter_riddle.py2
-rw-r--r--bot/seasons/easter/egghead_quiz.py6
-rw-r--r--bot/seasons/easter/traditions.py2
-rw-r--r--bot/seasons/evergreen/8bitify.py6
-rw-r--r--bot/seasons/evergreen/minesweeper.py18
-rw-r--r--bot/seasons/evergreen/showprojects.py6
-rw-r--r--bot/seasons/evergreen/speedrun.py2
-rw-r--r--bot/seasons/halloween/spookyrating.py2
-rw-r--r--bot/utils/__init__.py2
-rw-r--r--tox.ini5
13 files changed, 33 insertions, 32 deletions
diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py
index a9e72805..d2894ec4 100644
--- a/bot/seasons/christmas/adventofcode.py
+++ b/bot/seasons/christmas/adventofcode.py
@@ -359,7 +359,7 @@ class AdventOfCode(commands.Cog):
)
async def _check_n_entries(self, ctx: commands.Context, number_of_people_to_display: int) -> int:
- """Check for n > max_entries and n <= 0"""
+ """Check for n > max_entries and n <= 0."""
max_entries = AocConfig.leaderboard_max_displayed_members
author = ctx.message.author
if not 0 <= number_of_people_to_display <= max_entries:
diff --git a/bot/seasons/easter/avatar_easterifier.py b/bot/seasons/easter/avatar_easterifier.py
index ad8b5473..98e15982 100644
--- a/bot/seasons/easter/avatar_easterifier.py
+++ b/bot/seasons/easter/avatar_easterifier.py
@@ -34,7 +34,7 @@ class AvatarEasterifier(commands.Cog):
r1, g1, b1 = x
def distance(point):
- """Finds the difference between a pastel colour and the original pixel colour"""
+ """Finds the difference between a pastel colour and the original pixel colour."""
r2, g2, b2 = point
return ((r1 - r2)**2 + (g1 - g2)**2 + (b1 - b2)**2)
diff --git a/bot/seasons/easter/bunny_name_generator.py b/bot/seasons/easter/bunny_name_generator.py
index 76d5c478..3ceaeb9e 100644
--- a/bot/seasons/easter/bunny_name_generator.py
+++ b/bot/seasons/easter/bunny_name_generator.py
@@ -28,8 +28,8 @@ class BunnyNameGenerator(commands.Cog):
"""
Finds vowels in the user's display name.
- If the Discord name contains a vowel and the letter y,
- it will match one or more of these patterns.
+ If the Discord name contains a vowel and the letter y, it will match one or more of these patterns.
+
Only the most recently matched pattern will apply the changes.
"""
expressions = [
@@ -46,7 +46,7 @@ class BunnyNameGenerator(commands.Cog):
return new_name
def append_name(self, displayname):
- """Adds a suffix to the end of the Discord name"""
+ """Adds a suffix to the end of the Discord name."""
extensions = ['foot', 'ear', 'nose', 'tail']
suffix = random.choice(extensions)
appended_name = displayname + suffix
@@ -55,12 +55,12 @@ class BunnyNameGenerator(commands.Cog):
@commands.command()
async def bunnyname(self, ctx):
- """Picks a random bunny name from a JSON file"""
+ """Picks a random bunny name from a JSON file."""
await ctx.send(random.choice(BUNNY_NAMES["names"]))
@commands.command()
async def bunnifyme(self, ctx):
- """Gets your Discord username and bunnifies it"""
+ """Gets your Discord username and bunnifies it."""
username = ctx.message.author.display_name
# If name contains spaces or other separators, get the individual words to randomly bunnify
diff --git a/bot/seasons/easter/easter_riddle.py b/bot/seasons/easter/easter_riddle.py
index 56555586..b612f8b9 100644
--- a/bot/seasons/easter/easter_riddle.py
+++ b/bot/seasons/easter/easter_riddle.py
@@ -84,7 +84,7 @@ class EasterRiddle(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message):
- """If a non-bot user enters a correct answer, their username gets added to self.winners"""
+ """If a non-bot user enters a correct answer, their username gets added to self.winners."""
if self.current_channel != message.channel:
return
diff --git a/bot/seasons/easter/egghead_quiz.py b/bot/seasons/easter/egghead_quiz.py
index 3e0cc598..b3841993 100644
--- a/bot/seasons/easter/egghead_quiz.py
+++ b/bot/seasons/easter/egghead_quiz.py
@@ -37,7 +37,7 @@ class EggheadQuiz(commands.Cog):
@commands.command(aliases=["eggheadquiz", "easterquiz"])
async def eggquiz(self, ctx):
"""
- Gives a random quiz question, waits 30 seconds and then outputs the answer
+ Gives a random quiz question, waits 30 seconds and then outputs the answer.
Also informs of the percentages and votes of each option
"""
@@ -96,13 +96,13 @@ class EggheadQuiz(commands.Cog):
@staticmethod
async def already_reacted(message, user):
- """Returns whether a given user has reacted more than once to a given message"""
+ """Returns whether a given user has reacted more than once to a given message."""
users = [u.id for reaction in [await r.users().flatten() for r in message.reactions] for u in reaction]
return users.count(user.id) > 1 # Old reaction plus new reaction
@commands.Cog.listener()
async def on_reaction_add(self, reaction, user):
- """Listener to listen specifically for reactions of quiz messages"""
+ """Listener to listen specifically for reactions of quiz messages."""
if user.bot:
return
if reaction.message.id not in self.quiz_messages:
diff --git a/bot/seasons/easter/traditions.py b/bot/seasons/easter/traditions.py
index f04b8828..b0bf04d7 100644
--- a/bot/seasons/easter/traditions.py
+++ b/bot/seasons/easter/traditions.py
@@ -19,7 +19,7 @@ class Traditions(commands.Cog):
@commands.command(aliases=('eastercustoms',))
async def easter_tradition(self, ctx):
- """Responds with a random tradition or custom"""
+ """Responds with a random tradition or custom."""
random_country = random.choice(list(traditions))
await ctx.send(f"{random_country}:\n{traditions[random_country]}")
diff --git a/bot/seasons/evergreen/8bitify.py b/bot/seasons/evergreen/8bitify.py
index 54db71db..60062fc1 100644
--- a/bot/seasons/evergreen/8bitify.py
+++ b/bot/seasons/evergreen/8bitify.py
@@ -13,17 +13,17 @@ class EightBitify(commands.Cog):
@staticmethod
def pixelate(image: Image) -> Image:
- """Takes an image and pixelates it"""
+ """Takes an image and pixelates it."""
return image.resize((32, 32)).resize((1024, 1024))
@staticmethod
def quantize(image: Image) -> Image:
- """Reduces colour palette to 256 colours"""
+ """Reduces colour palette to 256 colours."""
return image.quantize(colors=32)
@commands.command(name="8bitify")
async def eightbit_command(self, ctx: commands.Context) -> None:
- """Pixelates your avatar and changes the palette to an 8bit one"""
+ """Pixelates your avatar and changes the palette to an 8bit one."""
async with ctx.typing():
image_bytes = await ctx.author.avatar_url.read()
avatar = Image.open(BytesIO(image_bytes))
diff --git a/bot/seasons/evergreen/minesweeper.py b/bot/seasons/evergreen/minesweeper.py
index cb859ea9..3eee92ca 100644
--- a/bot/seasons/evergreen/minesweeper.py
+++ b/bot/seasons/evergreen/minesweeper.py
@@ -33,7 +33,7 @@ class CoordinateConverter(commands.Converter):
"""Converter for Coordinates."""
async def convert(self, ctx, coordinate: str) -> typing.Tuple[int, int]:
- """Take in a coordinate string and turn it into x, y"""
+ """Take in a coordinate string and turn it into an (x, y) tuple."""
if not 2 <= len(coordinate) <= 3:
raise commands.BadArgument('Invalid co-ordinate provided')
@@ -81,7 +81,7 @@ class Minesweeper(commands.Cog):
@commands.group(name='minesweeper', aliases=('ms',), invoke_without_command=True)
async def minesweeper_group(self, ctx: commands.Context):
- """Commands for Playing Minesweeper"""
+ """Commands for Playing Minesweeper."""
await ctx.send_help(ctx.command)
@staticmethod
@@ -175,7 +175,7 @@ class Minesweeper(commands.Cog):
@commands.dm_only()
@minesweeper_group.command(name="flag")
async def flag_command(self, ctx: commands.Context, *coordinates: CoordinateConverter) -> None:
- """Place multiple flags on the board"""
+ """Place multiple flags on the board."""
board: GameBoard = self.games[ctx.author.id].revealed
for x, y in coordinates:
if board[y][x] == "hidden":
@@ -185,14 +185,14 @@ class Minesweeper(commands.Cog):
@staticmethod
def reveal_bombs(revealed: GameBoard, board: GameBoard) -> None:
- """Reveals all the bombs"""
+ """Reveals all the bombs."""
for y, row in enumerate(board):
for x, cell in enumerate(row):
if cell == "bomb":
revealed[y][x] = cell
async def lost(self, ctx: commands.Context) -> None:
- """The player lost the game"""
+ """The player lost the game."""
game = self.games[ctx.author.id]
self.reveal_bombs(game.revealed, game.board)
await ctx.author.send(":fire: You lost! :fire:")
@@ -200,7 +200,7 @@ class Minesweeper(commands.Cog):
await game.chat_msg.channel.send(f":fire: {ctx.author.mention} just lost Minesweeper! :fire:")
async def won(self, ctx: commands.Context) -> None:
- """The player won the game"""
+ """The player won the game."""
game = self.games[ctx.author.id]
await ctx.author.send(":tada: You won! :tada:")
if game.activated_on_server:
@@ -216,7 +216,7 @@ class Minesweeper(commands.Cog):
self.reveal_zeros(revealed, board, x_, y_)
async def check_if_won(self, ctx, revealed: GameBoard, board: GameBoard) -> bool:
- """Checks if a player has won"""
+ """Checks if a player has won."""
if any(
revealed[y][x] in ["hidden", "flag"] and board[y][x] != "bomb"
for x in range(10)
@@ -252,7 +252,7 @@ class Minesweeper(commands.Cog):
@commands.dm_only()
@minesweeper_group.command(name="reveal")
async def reveal_command(self, ctx: commands.Context, *coordinates: CoordinateConverter) -> None:
- """Reveal multiple cells"""
+ """Reveal multiple cells."""
game = self.games[ctx.author.id]
revealed: GameBoard = game.revealed
board: GameBoard = game.board
@@ -268,7 +268,7 @@ class Minesweeper(commands.Cog):
@minesweeper_group.command(name="end")
async def end_command(self, ctx: commands.Context):
- """End your current game"""
+ """End your current game."""
game = self.games[ctx.author.id]
game.revealed = game.board
await self.update_boards(ctx)
diff --git a/bot/seasons/evergreen/showprojects.py b/bot/seasons/evergreen/showprojects.py
index 37809b33..5dea78a5 100644
--- a/bot/seasons/evergreen/showprojects.py
+++ b/bot/seasons/evergreen/showprojects.py
@@ -8,7 +8,7 @@ log = logging.getLogger(__name__)
class ShowProjects(commands.Cog):
- """Cog that reacts to posts in the #show-your-projects"""
+ """Cog that reacts to posts in the #show-your-projects."""
def __init__(self, bot):
self.bot = bot
@@ -16,7 +16,7 @@ class ShowProjects(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message):
- """Adds reactions to posts in #show-your-projects"""
+ """Adds reactions to posts in #show-your-projects."""
reactions = ["\U0001f44d", "\U00002764", "\U0001f440", "\U0001f389", "\U0001f680", "\U00002b50", "\U0001f6a9"]
if (message.channel.id == Channels.show_your_projects
and message.author.bot is False
@@ -28,6 +28,6 @@ class ShowProjects(commands.Cog):
def setup(bot):
- """Show Projects Reaction Cog"""
+ """Show Projects Reaction Cog."""
bot.add_cog(ShowProjects(bot))
log.info("ShowProjects cog loaded")
diff --git a/bot/seasons/evergreen/speedrun.py b/bot/seasons/evergreen/speedrun.py
index f6a43a63..5e3d38a0 100644
--- a/bot/seasons/evergreen/speedrun.py
+++ b/bot/seasons/evergreen/speedrun.py
@@ -23,6 +23,6 @@ class Speedrun(commands.Cog):
def setup(bot):
- """Load the Speedrun cog"""
+ """Load the Speedrun cog."""
bot.add_cog(Speedrun(bot))
log.info("Speedrun cog loaded")
diff --git a/bot/seasons/halloween/spookyrating.py b/bot/seasons/halloween/spookyrating.py
index 08c17a27..a436e39d 100644
--- a/bot/seasons/halloween/spookyrating.py
+++ b/bot/seasons/halloween/spookyrating.py
@@ -17,7 +17,7 @@ with Path("bot/resources/halloween/spooky_rating.json").open() as file:
class SpookyRating(commands.Cog):
- """A cog for calculating one's spooky rating"""
+ """A cog for calculating one's spooky rating."""
def __init__(self, bot):
self.bot = bot
diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py
index 3249a9cf..72a681a3 100644
--- a/bot/utils/__init__.py
+++ b/bot/utils/__init__.py
@@ -110,7 +110,7 @@ def replace_many(
regex = re.compile(pattern, re.I if ignore_case else 0)
def _repl(match):
- """Returns replacement depending on `ignore_case` and `match_case`"""
+ """Returns replacement depending on `ignore_case` and `match_case`."""
word = match.group(0)
replacement = replacements[word.lower() if ignore_case else word]
diff --git a/tox.ini b/tox.ini
index 3e5db0a5..34a4d498 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,16 +1,17 @@
[flake8]
max-line-length=120
application_import_names=bot
+docstring-convention=all
ignore=
P102,B311,W503,E226,S311,
# Missing Docstrings
- D100,D104,D107,
+ D100,D104,D105,D107,
# Docstring Whitespace
D203,D212,D214,D215,
# Docstring Quotes
D301,D302,
# Docstring Content
- D400,D401,D402,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414
+ D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417
exclude=
__pycache__,.cache,
venv,.venv,