aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar S. Co1 <[email protected]>2019-09-11 11:33:16 -0400
committerGravatar S. Co1 <[email protected]>2019-09-11 11:33:16 -0400
commitda20c52802cbb4c68cfbb058e9ffc986b591240f (patch)
treebf38f7863925b393326edf4dc04453508e545a2b
parentMerge branch 'master' into flake8-annotations (diff)
Fix incorrect merge conflict resolutions, lint remaining items
-rw-r--r--bot/seasons/easter/avatar_easterifier.py2
-rw-r--r--bot/seasons/easter/bunny_name_generator.py6
-rw-r--r--bot/seasons/easter/easter_riddle.py2
-rw-r--r--bot/seasons/easter/egghead_quiz.py4
-rw-r--r--bot/seasons/easter/traditions.py2
-rw-r--r--bot/seasons/evergreen/minesweeper.py8
-rw-r--r--bot/seasons/evergreen/showprojects.py4
-rw-r--r--bot/seasons/evergreen/snakes/utils.py26
-rw-r--r--bot/seasons/evergreen/speedrun.py2
-rw-r--r--bot/seasons/halloween/hacktoberstats.py2
-rw-r--r--bot/utils/__init__.py2
-rw-r--r--tox.ini2
12 files changed, 34 insertions, 28 deletions
diff --git a/bot/seasons/easter/avatar_easterifier.py b/bot/seasons/easter/avatar_easterifier.py
index f056068e..85c32909 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: Tuple[int, int, int]) -> Tuple[int, int, int]:
- """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 22957b7f..97c467e1 100644
--- a/bot/seasons/easter/bunny_name_generator.py
+++ b/bot/seasons/easter/bunny_name_generator.py
@@ -47,7 +47,7 @@ class BunnyNameGenerator(commands.Cog):
return new_name
def append_name(self, displayname: str) -> str:
- """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
@@ -56,12 +56,12 @@ class BunnyNameGenerator(commands.Cog):
@commands.command()
async def bunnyname(self, ctx: commands.Context) -> None:
- """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: commands.Context) -> None:
- """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 c3f19055..4b98b204 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: discord.Messaged) -> None:
- """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 0b175bf1..bd179fe2 100644
--- a/bot/seasons/easter/egghead_quiz.py
+++ b/bot/seasons/easter/egghead_quiz.py
@@ -97,13 +97,13 @@ class EggheadQuiz(commands.Cog):
@staticmethod
async def already_reacted(message: discord.Message, user: Union[discord.Member, discord.User]) -> bool:
- """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: discord.Reaction, user: Union[discord.Member, discord.User]) -> None:
- """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 4fb4694f..9529823f 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: commands.Context) -> None:
- """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/minesweeper.py b/bot/seasons/evergreen/minesweeper.py
index 015b09df..b0ba8145 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: commands.Context, 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) -> None:
- """Commands for Playing Minesweeper"""
+ """Commands for Playing Minesweeper."""
await ctx.send_help(ctx.command)
@staticmethod
@@ -216,7 +216,7 @@ class Minesweeper(commands.Cog):
self.reveal_zeros(revealed, board, x_, y_)
async def check_if_won(self, ctx: commands.Context, 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)
@@ -268,7 +268,7 @@ class Minesweeper(commands.Cog):
@minesweeper_group.command(name="end")
async def end_command(self, ctx: commands.Context) -> None:
- """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 d41132aa..a943e548 100644
--- a/bot/seasons/evergreen/showprojects.py
+++ b/bot/seasons/evergreen/showprojects.py
@@ -17,7 +17,7 @@ class ShowProjects(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message: Message) -> None:
- """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
@@ -29,6 +29,6 @@ class ShowProjects(commands.Cog):
def setup(bot: commands.Bot) -> None:
- """Show Projects Reaction Cog"""
+ """Show Projects Reaction Cog."""
bot.add_cog(ShowProjects(bot))
log.info("ShowProjects cog loaded")
diff --git a/bot/seasons/evergreen/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py
index 76809bd4..7d6caf04 100644
--- a/bot/seasons/evergreen/snakes/utils.py
+++ b/bot/seasons/evergreen/snakes/utils.py
@@ -388,8 +388,7 @@ class SnakeAndLaddersGame:
"""
Create a new Snakes and Ladders game.
- Listen for reactions until players have joined,
- and the game has been started.
+ Listen for reactions until players have joined, and the game has been started.
"""
def startup_event_check(reaction_: Reaction, user_: Member) -> bool:
"""Make sure that this reaction is what we want to operate on."""
@@ -457,6 +456,7 @@ class SnakeAndLaddersGame:
return # We're done, no reactions for the last 5 minutes
async def _add_player(self, user: Member) -> None:
+ """Add player to game."""
self.players.append(user)
self.player_tiles[user.id] = 1
@@ -490,7 +490,7 @@ class SnakeAndLaddersGame:
delete_after=10
)
- async def player_leave(self, user: Member) -> None:
+ async def player_leave(self, user: Member) -> bool:
"""
Handle players leaving the game.
@@ -515,11 +515,13 @@ class SnakeAndLaddersGame:
is_surrendered = True
self._destruct()
- async def cancel_game(self, user: Member) -> None:
- """Allow the game author to cancel the running game."""
- if not user == self.author:
- await self.channel.send(user.mention + " Only the author of the game can cancel it.", delete_after=10)
- return
+ return is_surrendered
+ else:
+ await self.channel.send(user.mention + " You are not in the match.", delete_after=10)
+ return is_surrendered
+
+ async def cancel_game(self) -> None:
+ """Cancel the running game."""
await self.channel.send("**Snakes and Ladders**: Game has been canceled.")
self._destruct()
@@ -670,6 +672,7 @@ class SnakeAndLaddersGame:
self.round_has_rolled[user.id] = True
async def _complete_round(self) -> None:
+ """At the conclusion of a round check to see if there's been a winner."""
self.state = 'post_round'
# check for winner
@@ -684,19 +687,22 @@ class SnakeAndLaddersGame:
self._destruct()
def _check_winner(self) -> Member:
+ """Return a winning member if we're in the post-round state and there's a winner."""
if self.state != 'post_round':
return None
return next((player for player in self.players if self.player_tiles[player.id] == 100),
None)
def _check_all_rolled(self) -> bool:
+ """Check if all members have made their roll."""
return all(rolled for rolled in self.round_has_rolled.values())
def _destruct(self) -> None:
+ """Clean up the finished game object."""
del self.snakes.active_sal[self.channel]
- def _board_coordinate_from_index(self, index: int) -> Tuple[float, float]:
- # converts the tile number to the x/y coordinates for graphical purposes
+ def _board_coordinate_from_index(self, index: int) -> Tuple[int, int]:
+ """Convert the tile number to the x/y coordinates for graphical purposes."""
y_level = 9 - math.floor((index - 1) / 10)
is_reversed = math.floor((index - 1) / 10) % 2 != 0
x_level = (index - 1) % 10
diff --git a/bot/seasons/evergreen/speedrun.py b/bot/seasons/evergreen/speedrun.py
index 2f59c886..76c5e8d3 100644
--- a/bot/seasons/evergreen/speedrun.py
+++ b/bot/seasons/evergreen/speedrun.py
@@ -23,6 +23,6 @@ class Speedrun(commands.Cog):
def setup(bot: commands.Bot) -> None:
- """Load the Speedrun cog"""
+ """Load the Speedrun cog."""
bot.add_cog(Speedrun(bot))
log.info("Speedrun cog loaded")
diff --git a/bot/seasons/halloween/hacktoberstats.py b/bot/seasons/halloween/hacktoberstats.py
index 5687a5c7..0f513953 100644
--- a/bot/seasons/halloween/hacktoberstats.py
+++ b/bot/seasons/halloween/hacktoberstats.py
@@ -19,7 +19,7 @@ PRS_FOR_SHIRT = 4 # Minimum number of PRs before a shirt is awarded
class HacktoberStats(commands.Cog):
"""Hacktoberfest statistics Cog."""
- def __init__(self, bot):
+ def __init__(self, bot: commands.Bot):
self.bot = bot
self.link_json = Path("bot/resources/github_links.json")
self.linked_accounts = self.load_linked_users()
diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py
index 8732eb22..0aa50af6 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: re.Match) -> str:
- """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 dec88854..ee898b0d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,7 +11,7 @@ ignore=
# 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
# Type Annotations
TYP002,TYP003,TYP101,TYP102,TYP204,TYP206
exclude=