Skip to content

Commit 138401d

Browse files
committed
Update ruff hook and fix pyright checks
1 parent e41ed0a commit 138401d

File tree

8 files changed

+16
-12
lines changed

8 files changed

+16
-12
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repos:
3434
- repo: https://github.com/astral-sh/ruff-pre-commit
3535
rev: v0.14.10
3636
hooks:
37-
- id: ruff
37+
- id: ruff-check
3838
args: [ --fix ]
3939
- id: ruff-format
4040

modmail/backends/mongodb/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, config: Config) -> None:
7171
"""
7272
super().__init__(config)
7373
self.db_name = self._mongodb_config.database
74-
self._client: AsyncMongoClient | None = None
74+
self._client: AsyncMongoClient[dict[str, Any]] | None = None
7575

7676
# the loaded settings model from the database
7777
self.__settings_document: MongoDBSettingsDocument | None = None
@@ -634,7 +634,7 @@ async def close_thread(
634634
# Update the thread status and set closer information
635635
thread_document.status = thread_status
636636
thread_document.closed_at = datetime.datetime.now(tz=datetime.UTC)
637-
thread_document.closed_by = closer_document
637+
thread_document.closed_by = closer_document # pyright: ignore [reportAttributeAccessIssue] # not sure why beanie expects a Link[] here
638638

639639
# Save the updated thread document
640640
# noinspection PyArgumentList

modmail/cogs/utility/commands/profile.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import logging
1313
import re
14-
from typing import TYPE_CHECKING, Any, Final, NamedTuple
14+
from typing import TYPE_CHECKING, Any, Final, NamedTuple, cast
1515

1616
import discord
1717
from discord.ext import commands
@@ -25,7 +25,7 @@
2525
from .. import Utility
2626

2727
# A "stub" for type hinting
28-
class ProfileCustomizeView(discord.ui.View):
28+
class _ProfileCustomizeView(discord.ui.View):
2929
_original_message: discord.Message | None
3030

3131
def set_original_message(self, message: discord.Message) -> None: ...
@@ -106,7 +106,7 @@ def _check_is_bot(user_or_role: discord.Member | discord.User | discord.Role) ->
106106

107107
async def make_profile_customize_view(
108108
cog: Utility, ctx: commands.Context[Bot], profile_detail: ProfileDetail, profile: ProfileModel
109-
) -> type[ProfileCustomizeView]:
109+
) -> type[_ProfileCustomizeView]:
110110
"""Create a UI view for customizing profiles.
111111
112112
Args:
@@ -308,6 +308,10 @@ async def customize_button(
308308
"""Open the modal for profile customization."""
309309
await interaction.response.send_modal(ProfileCustomizeModal())
310310

311+
if TYPE_CHECKING:
312+
# This is quite ugly, but until Protocol intersection is supported we have to do this
313+
ProfileCustomizeView = cast(type[_ProfileCustomizeView], ProfileCustomizeView) # noqa: N806
314+
311315
return ProfileCustomizeView
312316

313317

modmail/config/models/bot_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def check_jishaku_installed(cls, v: bool) -> bool:
133133
"""
134134
if v:
135135
try:
136-
import jishaku # pyright: ignore [reportUnusedImport, reportMissingImports] # noqa: F401
136+
import jishaku # pyright: ignore # noqa: F401
137137
except ImportError:
138138
logger.error("Jishaku is not installed, but is enabled in configs.")
139139
return False

modmail/config/models/logging_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class LoggingConfig(BaseModel):
4141
console_level: int = logging.INFO
4242
logfile_level: int = logging.DEBUG
4343
stdout_format: str = "%(message)s"
44-
logfile: str | None = Field("logs/modmail.log", validate_default=True)
44+
logfile: str | None = Field(default="logs/modmail.log", validate_default=True)
4545
logfile_format: str = "%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s"
4646
logfile_max_size: NonNegativeInt = 1024 * 1024 * 10 # 10 MB
4747
logfile_backup_count: NonNegativeInt = 3

modmail/core/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ async def clear_bot_presence(self) -> None:
471471
await self.database_client.update_settings(activity=None, status=None)
472472
await self.set_bot_presence()
473473

474-
async def on_command_error(self, context: commands.Context[Bot], exception: commands.CommandError, /) -> None:
474+
async def on_command_error(self, context: commands.Context[Any], exception: commands.CommandError, /) -> None:
475475
"""Handle command execution errors.
476476
477477
Ignores CommandNotFound and CheckFailure errors, passes others to parent handler.

modmail/core/internals/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, func: T, args: Any, kwargs: Any) -> None:
5858
args: Positional arguments for the command constructor.
5959
kwargs: Keyword arguments for the command constructor.
6060
"""
61-
self.base_func: Callable[..., Callable[[T], HcHg]] = staticmethod(commands.hybrid_command)
61+
self.base_func: Callable[..., Callable[[T], HcHg]] = commands.hybrid_command
6262
self.callback = func
6363
self.args = args
6464
self.kwargs = kwargs
@@ -140,7 +140,7 @@ def __init__(self, func: T, args: Any, kwargs: Any) -> None:
140140
kwargs: Keyword arguments for the group command constructor.
141141
"""
142142
super().__init__(func, args, kwargs)
143-
self.base_func: Callable[..., Callable[[T], HcHg]] = staticmethod(commands.hybrid_group)
143+
self.base_func: Callable[..., Callable[[T], HcHg]] = commands.hybrid_group
144144
self.children: list[LazyHybridCommand[Any]] = []
145145

146146
def get_commands(self, cog_name: str) -> dict[str, HcHg]:

modmail/core/internals/thread_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async def send_initial_staff_message(self) -> None:
185185

186186
embed_proxies.sort(key=lambda x: x[0]) # Sort by recipient name
187187
embeds = await asyncio.gather(*[
188-
embed.to_embed(self.bot.translator, CONFIG.default_locale) for x, embed in embed_proxies
188+
embed.to_embed(self.bot.translator, CONFIG.default_locale) for _x, embed in embed_proxies
189189
])
190190

191191
# Set the timestamp for the first embed

0 commit comments

Comments
 (0)