Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/grace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install pytest
pip install .[dev]

- name: Lint with ruff
- name: Check formatting with black
run: |
ruff check --preview
black --check .

- name: Generate config file
run: |
Expand Down
1 change: 0 additions & 1 deletion bot/extensions/bookmark_cog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from discord import Embed, File, Interaction, Message
from discord.app_commands import ContextMenu
from discord.ext.commands import Cog
Expand Down
1 change: 0 additions & 1 deletion bot/extensions/extension_cog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from discord import Embed
from discord.app_commands import Choice, autocomplete
from discord.ext.commands import (
Expand Down
3 changes: 2 additions & 1 deletion bot/extensions/fun_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ async def quote_command(self, ctx: Context) -> None:
:type ctx: Context
"""
response = await asyncio.to_thread(
get, "https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en"
get,
"https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en",
)

if response.ok:
Expand Down
9 changes: 2 additions & 7 deletions bot/extensions/thank_cog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from discord import Embed, Member
from discord.ext.commands import BucketType, Cog, Context, cooldown, hybrid_group

Expand Down Expand Up @@ -89,16 +88,12 @@ async def thank_leaderboard(self, ctx: Context, *, top: int = 10) -> None:

for position, helper in enumerate(helpers):
member = await self.bot.fetch_user(helper.member_id)
leaderboard_embed.description += (
f"{position + 1}. **{member.display_name}**: **{helper.rank}** with {helper.count} thank(s).\n"
)
leaderboard_embed.description += f"{position + 1}. **{member.display_name}**: **{helper.rank}** with {helper.count} thank(s).\n"

await ctx.reply(embed=leaderboard_embed, ephemeral=True)

@thank_group.command(name="rank", description="Shows your current thank rank.")
async def thank_rank(
self, ctx: Context, *, member: Member | None = None
) -> None:
async def thank_rank(self, ctx: Context, *, member: Member | None = None) -> None:
"""Show the current rank of the member who issue this command.

:param ctx: The context of the command invocation.
Expand Down
6 changes: 2 additions & 4 deletions bot/extensions/threads_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,14 @@ async def post_thread(self, thread: Thread):
color=self.bot.default_color,
title=thread.title,
description=thread.content,
timestamp=datetime.now(tz=UTC)
timestamp=datetime.now(tz=UTC),
)

if channel:
message = await channel.send(content=content, embed=embed)
new_discord_thread = await message.create_thread(name=thread.title)

if old_discord_thread := self.bot.get_channel(
thread.latest_thread_id
):
if old_discord_thread := self.bot.get_channel(thread.latest_thread_id):
await old_discord_thread.send(new_discord_thread.jump_url)
await old_discord_thread.edit(archived=True, locked=True)

Expand Down
2 changes: 1 addition & 1 deletion bot/extensions/welcome_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def matrix_section(self) -> str:
return self.__build_section(
[],
"### Join our Matrix Server!\n"
"You can also join our [matrix server](<https://matrix.to/#/%23codesociety:matrix.org>)\n"
"You can also join our [matrix server](<https://matrix.to/#/%23codesociety:matrix.org>)\n",
)

def get_welcome_message(self, member: Member) -> str:
Expand Down
4 changes: 3 additions & 1 deletion bot/extensions/wikipedia_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def search_results(search: str) -> list[Any]:
:rtype: list
"""
url_encode: str = quote_plus(search)
base_url: str = f"https://en.wikipedia.org/w/api.php?action=opensearch&format=json&limit=3&namespace=0&search={url_encode}"
base_url: str = (
f"https://en.wikipedia.org/w/api.php?action=opensearch&format=json&limit=3&namespace=0&search={url_encode}"
)

request = Request(base_url, headers={"User-Agent": USER_AGENT})
with urlopen(request) as url:
Expand Down
4 changes: 3 additions & 1 deletion bot/grace.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ async def load_extensions(self):
extension = Extension.where(module_name=module).first()

if not extension:
logger.warning(f"{module} is not registered. Registering the extension.")
logger.warning(
f"{module} is not registered. Registering the extension."
)
extension = Extension.create(module_name=module)

if not extension.should_be_loaded():
Expand Down
1 change: 0 additions & 1 deletion bot/models/extensions/fun/answer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from grace.model import Field, Model


Expand Down
1 change: 0 additions & 1 deletion bot/models/extensions/language/trigger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from emoji import emojize
from grace.model import Field, Model, Relationship

Expand Down
1 change: 0 additions & 1 deletion bot/models/extensions/thank.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from grace.model import Field, Model


Expand Down
1 change: 0 additions & 1 deletion bot/services/github_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from github import Github, Organization
from github.Repository import Repository

Expand Down
1 change: 1 addition & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ You should always review your own PR first.
#### How to self review my code?
- Confirm that the changes meet the user experience and goals of the bot.
- Ensure that your code is **clean** and follows Python's [PEP-0008](https://www.python.org/dev/peps/pep-0008/).
- Format your code with [black](https://black.readthedocs.io/en/stable/) by running `black .` (this is checked in CI with `black --check .`).
- Verify your code for grammar and spelling mistakes (The code and the text must be in **English**).
- Test your changes to ensure there's no bugs.

Expand Down
1 change: 0 additions & 1 deletion lib/config_required.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class ConfigRequiredError(DisabledCommand):
"""



class MissingRequiredConfigError(ConfigRequiredError):
"""Exception raised when a required configuration is missing.

Expand Down
1 change: 0 additions & 1 deletion lib/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from sqlalchemy import Column
from sqlalchemy.types import Integer, TypeDecorator
from sqlmodel import Field
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ dependencies = [
dev = [
"pytest",
"pytest-asyncio",
"flake8",
"mypy",
"ruff==0.15.12",
"black==26.5.1",
"freezegun",
]

Expand All @@ -47,3 +46,6 @@ Documentation = "https://github.com/Code-Society-Lab/grace/wiki"

[tool.setuptools.packages.find]
include = ["*"]

[tool.black]
target-version = ["py312"]
Loading