Skip to content

Commit

Permalink
Make pyright strict (mostly) pass
Browse files Browse the repository at this point in the history
  • Loading branch information
hypergonial committed Jun 4, 2024
1 parent 3d7ec79 commit 6dcc780
Show file tree
Hide file tree
Showing 35 changed files with 264 additions and 1,025 deletions.
115 changes: 71 additions & 44 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ignore_errors = true # I use pyright only because mypy dumb

[tool.pyright]
pythonVersion = "3.12"
typeCheckingMode = "basic"
typeCheckingMode = "strict"
reportPrivateUsage = "none"

[tool.poetry]
Expand All @@ -45,7 +45,9 @@ python = ">=3.12,<3.13"
dateparser = "^1.1.8"
psutil = "^5.9.6"
Pillow = "^10.2.0"
asyncpg = "^0.28.0"
types-Pillow = "^10.2.0"
asyncpg = "^0.29.0"
asyncpg-stubs = "^0.29.0"
Levenshtein = "^0.23.0"
uvloop = { version = "==0.18.0", platform = "linux" }
aiodns = "~=3.1.1"
Expand Down
9 changes: 5 additions & 4 deletions src/__main__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/python3

import asyncio
import logging
import os
import pathlib
import platform
import re

from src.models import SnedBot
from src.models.client import SnedClient

DOTENV_REGEX = re.compile(r"^(?P<identifier>[A-Za-z_]+[A-Za-z0-9_]*)=(?P<value>[^#]+)(#.*)?$")
BASE_DIR = str(pathlib.Path(os.path.abspath(__file__)).parents[1])
Expand Down Expand Up @@ -38,16 +39,16 @@
try:
import uvloop

uvloop.install()
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
except ImportError:
logging.warn(
"Failed to import uvloop! Make sure to install it via 'pip install uvloop' for enhanced performance!"
)

bot = SnedBot(Config())
client = SnedClient(Config())

if __name__ == "__main__":
bot.run()
client.app.run()

# Copyright (C) 2022-present hypergonial

Expand Down
12 changes: 7 additions & 5 deletions src/etc/settings_static.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import typing as t

import hikari
import miru

Expand All @@ -10,7 +12,7 @@
ModerationFlags.IS_EPHEMERAL: "Send mod commands ephemerally",
}

default_automod_policies = {
default_automod_policies: dict[str, t.Any] = {
"invites": {
"state": "disabled",
"temp_dur": 15,
Expand Down Expand Up @@ -99,7 +101,7 @@
}

# Policy state configuration
policy_states = {
policy_states: dict[str, t.Any] = {
"disabled": {"name": "Disabled", "excludes": [], "description": "Disable this policy.", "emoji": "🚫"},
"flag": {"name": "Flag", "excludes": ["spam"], "description": "Log message to 'Auto-Mod Flagging'.", "emoji": "🚩"},
"notice": {
Expand Down Expand Up @@ -223,8 +225,8 @@
},
"escalate": {
"name": "Escalation",
"description": """This event is triggered when any other policy's punishment is set to escalation, and escalates measures, culminating in the punishment specified below.
"description": """This event is triggered when any other policy's punishment is set to escalation, and escalates measures, culminating in the punishment specified below.
**The flow is the following:**
**1.** The user is given a notice
**2.** If ignored, the user is warned
Expand All @@ -235,7 +237,7 @@
"perspective": {
"name": "Perspective",
"description": """Uses advanced machine learning algorithms to detect and filter out potentially toxic messages. Learn more about Perspective [here](https://www.perspectiveapi.com/).
Below you can set the percentages after which action will be taken based on the Perspective action-types. It is recommended to set at least a `0.85` (85%) confidence rate or higher for all values.
Staff members are encouraged to play around with the percentages with only the `Flag` state selected, to test the sensitiveness of the system. Perspective is not a replacement for human moderators, and should not be treated as such.
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/command_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ async def on_command_invoke(ctx: SnedContext) -> None:


@plugin.listen()
async def event_error_handler(event: hikari.ExceptionEvent) -> None:
async def event_error_handler(event: hikari.ExceptionEvent[t.Any]) -> None:
logging.error("Ignoring exception in listener {}:".format(event.failed_event.__class__.__name__))
exception_msg = "\n".join(traceback.format_exception(*event.exc_info))
logging.error(exception_msg)
Expand Down
Loading

0 comments on commit 6dcc780

Please sign in to comment.