Skip to content

Commit

Permalink
Bump to v0.2.8 #patch
Browse files Browse the repository at this point in the history
This release focuses to fix some typehinting issues, along with some others. For more info, please see the changelog ~ Noelle
  • Loading branch information
No767 authored Sep 22, 2023
2 parents 3fe1a6e + 9923747 commit ecf5a17
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 54 deletions.
2 changes: 1 addition & 1 deletion bot/cogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def __str__(self) -> str:


EXTENSIONS = [module.name for module in iter_modules(__path__, f"{__package__}.")]
VERSION: VersionInfo = VersionInfo(major=0, minor=2, micro=7, releaselevel="final")
VERSION: VersionInfo = VersionInfo(major=0, minor=2, micro=8, releaselevel="final")
2 changes: 1 addition & 1 deletion bot/cogs/blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, bot: Catherine) -> None:
@blacklist.command(name="view")
async def view(self, interaction: discord.Interaction):
"""View the global blacklist"""
blacklist = await get_or_fetch_full_blacklist(interaction.client, self.pool)
blacklist = await get_or_fetch_full_blacklist(self.bot, self.pool)
if blacklist is None:
await interaction.response.send_message("No blacklist entries found")
return
Expand Down
2 changes: 0 additions & 2 deletions bot/cogs/dev_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from discord.ext import commands
from discord.ext.commands import Context, Greedy

HANGOUT_GUILD_ID = discord.Object(id=1145897416160194590)


class DevTools(commands.Cog, command_attrs=dict(hidden=True)):
"""Tools for developing Catherine-Chan (pulled from Kumiko directly)"""
Expand Down
5 changes: 2 additions & 3 deletions bot/cogs/support.py → bot/cogs/pride_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from libs.utils import Embed


# Yep making it better Jade
class Support(commands.Cog):
class PrideSupport(commands.Cog):
"""Commands for getting support as a person (not for this bot)"""

def __init__(self, bot: Catherine):
Expand Down Expand Up @@ -92,4 +91,4 @@ async def pride_support(


async def setup(bot: Catherine) -> None:
await bot.add_cog(Support(bot))
await bot.add_cog(PrideSupport(bot))
2 changes: 1 addition & 1 deletion bot/libs/cog_utils/pride_profiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def parse_values(value: Any) -> str:
return value.capitalize()


def present_info(record: Dict[str, Any]):
def present_info(record: Dict[str, Any]) -> str:
separated_values = [
f"**{snake_case_to_title(k)}**: {parse_values(v)}"
for k, v in record.items()
Expand Down
2 changes: 1 addition & 1 deletion bot/libs/cog_utils/tonetags/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def edit_tonetag(

async def create_tonetag(
indicator: str, definition: str, author_id: int, pool: asyncpg.Pool
):
) -> str:
query = """
WITH tonetag_insert AS (
INSERT INTO tonetags (indicator, definition, author_id)
Expand Down
17 changes: 13 additions & 4 deletions bot/libs/ui/pronouns/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import asyncpg
import discord
from libs.cog_utils.commons import register_user
Expand All @@ -6,10 +10,13 @@
APPROVAL_CHANNEL_ID = 1150575176006782976
NO_CONTROL_MSG = "This menu cannot be controlled by you, sorry!"

if TYPE_CHECKING:
from bot.catherinecore import Catherine


# This modal is in here to avoid circular imports
class SuggestPronounsExamplesModal(discord.ui.Modal, title="Suggest an example"):
def __init__(self, bot, pool: asyncpg.Pool) -> None:
def __init__(self, bot: Catherine, pool: asyncpg.Pool) -> None:
super().__init__(custom_id="suggest_pronouns_example:modal")
self.sentence = discord.ui.TextInput(
label="Sentence",
Expand Down Expand Up @@ -44,8 +51,8 @@ async def on_submit(self, interaction: discord.Interaction) -> None:
query, interaction.user.id, self.sentence.value
)
if status is not None:
channel: discord.TextChannel = self.bot.get_channel(APPROVAL_CHANNEL_ID)
if isinstance(channel, discord.TextChannel):
channel = self.bot.get_channel(APPROVAL_CHANNEL_ID)
if channel is not None and isinstance(channel, discord.TextChannel):
await channel.send(
embed=build_approve_embed(
self.sentence.value,
Expand Down Expand Up @@ -136,7 +143,9 @@ async def deny(


class SuggestionView(discord.ui.View):
def __init__(self, bot, interaction: discord.Interaction, pool: asyncpg.Pool):
def __init__(
self, bot: Catherine, interaction: discord.Interaction, pool: asyncpg.Pool
):
self.bot = bot
self.interaction = interaction
self.pool = pool
Expand Down
12 changes: 8 additions & 4 deletions bot/libs/utils/blacklist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from typing import Dict, Optional
from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Optional

import asyncpg

if TYPE_CHECKING:
from bot.catherinecore import Catherine


async def load_blacklist(pool: asyncpg.Pool) -> Dict[int, bool]:
"""Loads the global blacklist into cache from the database
Expand All @@ -20,8 +25,7 @@ async def load_blacklist(pool: asyncpg.Pool) -> Dict[int, bool]:
return {record["id"]: record["blacklist_status"] for record in records}


# Circular import so bot is untyped
async def get_or_fetch_blacklist(bot, id: int, pool: asyncpg.Pool) -> bool:
async def get_or_fetch_blacklist(bot: Catherine, id: int, pool: asyncpg.Pool) -> bool:
"""Gets or fetches a user's blacklist status
Args:
Expand All @@ -48,7 +52,7 @@ async def get_or_fetch_blacklist(bot, id: int, pool: asyncpg.Pool) -> bool:


async def get_or_fetch_full_blacklist(
bot, pool: asyncpg.Pool
bot: Catherine, pool: asyncpg.Pool
) -> Optional[Dict[int, bool]]:
cache = bot.blacklist_cache

Expand Down
18 changes: 9 additions & 9 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# 🛠️ Catherine-Chan 0.2.7 🛠️
# 🛠️ Catherine-Chan 0.2.8 🛠️

Finally the blacklist and dev tool commands are not synced globally. This release aims to fix that and adds some QoL improvements.
Fix one small tiny bug that thanks to Sarth on the Python Discord server, has been resolved.

## ✨ TD;LR

- Fixed blacklist commands showing up in public commands **for real this time**
- Fixed bot args not having proper typehints

## 🛠️ Changes

- Fixed blacklist and sync commands showing up in public commands **for real this time**
- Migrate the sync and reload commands to be exclusively prefixed commands. This is done at the recommendation of Umbra and Nanika
- Switched the `/about` title URL to the support server invite link
- Renamed `/support` to be `/pride-support`
- Fixed bot args not having proper typehints
- Renamed `support.py` to `pride_support.py` (to reflect the support command now the one used by Catherine-Chan)
- Renamed `Support` cog to `PrideSupport` (to reflect the filename changes)
- Updated some typehints

## ✨ Additions

- A small little `/support` command to show ways you can better support Catherine-Chan
- None

## ➖ Removals

- None
- Any dead code
4 changes: 1 addition & 3 deletions docs/source/guides/dev/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ Static Typing (aka Type Hinting)

For the most part, Catherine-Chan's codebase is fully typed. Pyright in this case is used to check whether the code is typed and meets standards or not. If you are using VS Code, then you can enable this on VSC by clicking on the ``{}`` icon in your status bar.

The only exception to this is where circular imports can occur. And this most commonly happens with the ``Catherine`` class (due to how the project is structured). If you find that you have circular imports with that class, please make sure to leave a comment above the line that it happens.

Formatting
^^^^^^^^^^^

Expand Down Expand Up @@ -113,4 +111,4 @@ In order to automate the release system, you have to make sure that in order to
Major Release (For updates that are not backwards compatible) ``v2.0.0 #major``
Minor Release (For updates that are backwards compatible) ``v2.5.0 #minor``
Patch Release (For critical security patches and bug fixes) ``v2.5.1 #patch``
=============================================================== =====================
=============================================================== =====================
24 changes: 0 additions & 24 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ecf5a17

Please sign in to comment.