From cbc4b9da3fbcc771b26731d41488c556653eb5ae Mon Sep 17 00:00:00 2001 From: beerpiss Date: Fri, 26 Jul 2024 14:50:32 +0700 Subject: [PATCH] Fix type checking issues --- bot.py | 2 +- cogs/chunithm/records.py | 8 +++----- cogs/chunithm/search.py | 11 +++++------ utils/views/profile.py | 12 ++++++++++-- web.py | 8 ++++++++ 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/bot.py b/bot.py index ee25c78..232cb5b 100644 --- a/bot.py +++ b/bot.py @@ -70,7 +70,7 @@ def setup_database(conn, _): conn.create_function( "fuzz_qratio", 2, - functools.partial(fuzz.QRatio, processor=str.lower), + functools.partial(fuzz.QRatio, processor=str.lower), # type: ignore[reportCallIssue] ) sqlalchemy.event.listen(self.engine.sync_engine, "connect", setup_database) diff --git a/cogs/chunithm/records.py b/cogs/chunithm/records.py index 4cce5de..5b3faee 100644 --- a/cogs/chunithm/records.py +++ b/cogs/chunithm/records.py @@ -1,7 +1,7 @@ import contextlib import itertools from argparse import ArgumentError -from typing import TYPE_CHECKING, Literal, Literal, Optional, cast +from typing import TYPE_CHECKING, Literal, Optional, cast import discord from discord import app_commands @@ -474,8 +474,7 @@ async def top_slash( records.sort( reverse=True, key=lambda x: ( - x.extras.get(KEY_OVERPOWER_BASE) - / x.extras.get(KEY_OVERPOWER_MAX), + x.extras[KEY_OVERPOWER_BASE] / x.extras[KEY_OVERPOWER_MAX], x.extras.get(KEY_OVERPOWER_BASE), x.extras.get(KEY_PLAY_RATING), x.score, @@ -675,8 +674,7 @@ def sort_type(arg: str) -> str: records.sort( reverse=True, key=lambda x: ( - x.extras.get(KEY_OVERPOWER_BASE) - / x.extras.get(KEY_OVERPOWER_MAX), + x.extras[KEY_OVERPOWER_BASE] / x.extras[KEY_OVERPOWER_MAX], x.extras.get(KEY_OVERPOWER_BASE), x.extras.get(KEY_PLAY_RATING), x.score, diff --git a/cogs/chunithm/search.py b/cogs/chunithm/search.py index c8d6ebc..14286f1 100644 --- a/cogs/chunithm/search.py +++ b/cogs/chunithm/search.py @@ -431,7 +431,6 @@ async def info_inner(self, ctx: Context, *, query: str, detailed: bool = False): embed = discord.Embed( title=song.title, - description=song_description, color=discord.Color.yellow(), ).set_thumbnail(url=get_jacket_url(song)) @@ -477,16 +476,16 @@ async def info_inner(self, ctx: Context, *, query: str, detailed: bool = False): chart_level_desc.append(desc) if len(chart_level_desc) > 0: - # embed.description is already set above - embed.description += "\n**Level**:\n" # type: ignore[reportGeneralTypeIssues] + song_description += "\n**Level**:\n" if detailed: - embed.description += ( + song_description += ( "**CHAIN** / TAP / HOLD / SLIDE / AIR / FLICK\n\n" ) - embed.description += "\n".join(chart_level_desc) + song_description += "\n".join(chart_level_desc) else: - embed.description += " / ".join(chart_level_desc) + song_description += " / ".join(chart_level_desc) + embed.description = song_description song_embeds.append(embed) view = EmbedPaginationView(ctx, song_embeds) diff --git a/utils/views/profile.py b/utils/views/profile.py index 9d90a74..61d2cef 100644 --- a/utils/views/profile.py +++ b/utils/views/profile.py @@ -89,13 +89,21 @@ async def send_friend_request( await interaction.followup.send(embed=embed, ephemeral=True) return - utils: "UtilsCog" = cast("ChuniBot", interaction.client).get_cog("Utils") + if (friend_code := self.profile.friend_code) is None: + embed.description = "There is no friend code data?!" + + await interaction.followup.send(embed=embed, ephemeral=True) + return + + utils: "UtilsCog" = cast( + "UtilsCog", cast("ChuniBot", interaction.client).get_cog("Utils") + ) try: ctx = utils.chuninet(interaction.user.id) client = await ctx.__aenter__() - await client.send_friend_request(self.profile.friend_code) + await client.send_friend_request(friend_code) await ctx.__aexit__(None, None, None) embed.title = "Success" diff --git a/web.py b/web.py index 2c3c8dd..a73db18 100644 --- a/web.py +++ b/web.py @@ -25,6 +25,14 @@ router = web.RouteTableDef() +@router.get("/") +async def index(request: web.Request) -> web.Response: + return web.Response( + body="https://github.com/beer-psi/chuninewbot", + content_type="text/plain", + ) + + @router.get("/kamaitachi/oauth") async def kamaitachi_oauth(request: web.Request) -> web.Response: if (