Skip to content

Commit

Permalink
Fix type checking issues
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-psi committed Jul 26, 2024
1 parent d556ad1 commit cbc4b9d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions cogs/chunithm/records.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 5 additions & 6 deletions cogs/chunithm/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions utils/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit cbc4b9d

Please sign in to comment.