Skip to content

Commit

Permalink
Use proper type checking imports (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 authored Oct 13, 2024
1 parent fed3174 commit 4b86065
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
8 changes: 7 additions & 1 deletion bot/cogs/fun.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import discord
from catherinecore import Catherine
from discord import app_commands
from discord.ext import commands
from libs.utils import Embed
from yarl import URL

if TYPE_CHECKING:
from catherinecore import Catherine


class Fun(commands.Cog):
"""Fun commands!"""
Expand Down
18 changes: 12 additions & 6 deletions bot/cogs/meta.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
from __future__ import annotations

import datetime
import itertools
import platform
from typing import TYPE_CHECKING

import discord
import psutil
import pygit2
from catherinecore import Catherine
from discord import app_commands
from discord.ext import commands
from discord.utils import format_dt, oauth_url
from libs.utils import Embed, human_timedelta
from pygit2.enums import SortMode

if TYPE_CHECKING:
from catherinecore import Catherine


class Meta(commands.Cog):
"""Commands for getting info about the bot"""
Expand All @@ -36,12 +40,14 @@ def format_commit(self, commit: pygit2.Commit) -> str:
)

# [`hash`](url) message (offset)
offset = format_dt(commit_time.astimezone(datetime.timezone.utc), "R")
offset = discord.utils.format_dt(
commit_time.astimezone(datetime.timezone.utc), "R"
)
commit_id = str(commit.id)
return f"[`{short_sha2}`](https://github.com/No767/Catherine-Chan/commit/{commit_id}) {short} ({offset})"

def get_last_commits(self, count: int = 5):
repo = pygit2.Repository(".git")
repo = pygit2.Repository(".git") # type: ignore # Pyright is incorrect
commits = list(
itertools.islice(repo.walk(repo.head.target, SortMode.TOPOLOGICAL), count)
)
Expand Down Expand Up @@ -112,15 +118,15 @@ async def invite(self, interaction: discord.Interaction) -> None:
# This should be filled in by the time the bot is fully ready
if self.bot.application is None:
return
invite_url = oauth_url(client_id=self.bot.application.id)
invite_url = discord.utils.oauth_url(client_id=self.bot.application.id)
await interaction.response.send_message(
f"Invite Catherine-Chan using this link: {invite_url}"
)

@app_commands.command(name="support")
async def support(self, interaction: discord.Interaction):
"""Ways you can support Catherine-Chan!"""
invite_url = oauth_url(client_id=self.bot.application.id) # type: ignore # By the time the bot is ready, the app id is already there
invite_url = discord.utils.oauth_url(client_id=self.bot.application.id) # type: ignore # By the time the bot is ready, the app id is already there
desc = f"""
**Upvoting on Top.gg**: https://top.gg/bot/1142620675517984808
**Joining the support server**: https://discord.gg/ns3e74frqn
Expand Down
8 changes: 6 additions & 2 deletions bot/cogs/pride_support.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from typing import Literal
from __future__ import annotations

from typing import TYPE_CHECKING, Literal

import discord
from catherinecore import Catherine
from discord import app_commands
from discord.ext import commands
from libs.utils import Embed

if TYPE_CHECKING:
from catherinecore import Catherine


class PrideSupport(commands.Cog):
"""Commands for getting support as a person (not for this bot)"""
Expand Down

0 comments on commit 4b86065

Please sign in to comment.