Skip to content

Commit

Permalink
fix: ignore or fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sid-maddy committed Oct 19, 2024
1 parent 194ae46 commit 77b92d2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ async def main() -> None:
)

bot = Bot(
guild_id=constants.Guild.id,
http_session=session,
allowed_roles=list({discord.Object(id_) for id_ in constants.MODERATION_ROLES}),
command_prefix=get_prefix,
intents=intents,
guild_id=constants.Guild.id, # type: ignore[arg-type]
http_session=session, # type: ignore[arg-type]
allowed_roles=list({discord.Object(id_) for id_ in constants.MODERATION_ROLES}), # type: ignore[arg-type]
command_prefix=get_prefix, # type: ignore[arg-type]
intents=intents, # type: ignore[arg-type]
dragonfly_services=dragonfly_services,
)

Expand Down
2 changes: 1 addition & 1 deletion src/bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(
super().__init__(
*args,
tree_cls=CommandTree,
**kwargs,
**kwargs, # type: ignore[arg-type]
)

self.dragonfly_services = dragonfly_services
Expand Down
2 changes: 1 addition & 1 deletion src/bot/exts/core/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def on_command_error( # noqa: C901,PLR0911 -- Probably refactor this?
self.revert_cooldown_counter(ctx.command, ctx.message) # type: ignore[arg-type]
embed = self.error_embed(
"The argument you provided was invalid: " # type: ignore[union-attr]
f"{error}\n\nUsage:\n```\n{ctx.prefix}{parent_command}{ctx.command} {ctx.command.signature}\n```",
f"{error}\n\nUsage:\n```\n{ctx.prefix}{parent_command}{ctx.command} {ctx.command.signature}\n```", # type: ignore[arg-type]
)
await ctx.send(embed=embed)
return
Expand Down
11 changes: 8 additions & 3 deletions src/bot/exts/core/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ async def send_log_message( # noqa: PLR0913 -- Maybe refactor this?
content = content[: 2000 - 3] + "..."

channel = self.bot.get_channel(channel_id)
log_message = await channel.send(content=content, embed=embed, files=files)
log_message = await channel.send( # type: ignore[attr-defined]
content=content,
embed=embed,
files=files, # type: ignore[arg-type]
)

if additional_embeds:
for additional_embed in additional_embeds:
await channel.send(embed=additional_embed)
await channel.send(embed=additional_embed) # type: ignore[attr-defined]

return await self.bot.get_context(log_message) # type: ignore[no-any-return] # Optionally return for use with antispam
# Optionally return for use with antispam
return await self.bot.get_context(log_message) # type: ignore[no-any-return]


async def setup(bot: Bot) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/bot/exts/dragonfly/dragonfly.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ async def run(
"""Script entrypoint."""
scan_results = await bot.dragonfly_services.get_scanned_packages(since=since)
for result in scan_results:
if result.score >= score:
if result.score is not None and result.score >= score:
embed = _build_package_scan_result_embed(result)
await alerts_channel.send(
f"<@&{DragonflyConfig.alerts_role_id}>",
Expand Down
2 changes: 1 addition & 1 deletion src/bot/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def trace(self: Self, msg: str, *args: tuple, **kwargs: dict) -> None: # type:
logger.trace("Houston, we have an %s", "interesting problem", exc_info=1)
"""
if self.isEnabledFor(TRACE_LEVEL):
self.log(TRACE_LEVEL, msg, *args, **kwargs)
self.log(TRACE_LEVEL, msg, *args, **kwargs) # type: ignore[arg-type]


def get_logger(name: str | None = None) -> CustomLogger:
Expand Down
2 changes: 1 addition & 1 deletion src/bot/utils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def command_wraps(
"""Update the decorated function to look like `wrapped` and update globals for discordpy forwardref evaluation."""

def decorator(wrapper: types.FunctionType) -> types.FunctionType:
return functools.update_wrapper(
return functools.update_wrapper( # type: ignore[return-value]
update_wrapper_globals(wrapper, wrapped, ignored_conflict_names=ignored_conflict_names),
wrapped,
assigned,
Expand Down

0 comments on commit 77b92d2

Please sign in to comment.