Skip to content

Commit

Permalink
build/lint: switch to uv and ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
sn1f3rt committed Dec 15, 2024
1 parent fadc1fd commit 942eeaa
Show file tree
Hide file tree
Showing 28 changed files with 541 additions and 77 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
buy_me_a_coffee: sn1f3rt
github: [sn1f3rt]
patreon: sn1f3rt
28 changes: 28 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: ci/gh-actions/ruff

on:
push:
paths-ignore:
- "README.md"
pull_request:
paths-ignore:
- "README.md"
workflow_dispatch:

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint
run: ruff check --select I --no-fix .
- name: Format
run: ruff format --check .
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ cython_debug/
.idea/

# FumeGuard
config.py
logs/*.log
logs/errors/*.log

config.py
uv.lock
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
hooks:
- id: ruff
args: [--select=I]
- id: ruff-format
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
39 changes: 6 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,11 @@
`config.py`:
# FumeGuard

```python
TOKEN = "token"
[![ci/gh-actions/ruff](https://github.com/FumeStop/FumeGuard/actions/workflows/ruff.yml/badge.svg)](https://github.com/FumeStop/FumeGuard/actions/workflows/ruff.yml)

EMBED_COLOR = 0xE44C65
> Moderation, Roles, Logging, Welcome Messages, AFK status - YOU NAME IT - FumeGuard has got your community covered!
WEBHOOK_ID = 1234567890
WEBHOOK_TOKEN = "webhook_token"
## License

IPC_SECRET_KEY = "ipc_secret_key"
IPC_STANDARD_PORT = 10001
IPC_MULTICAST_PORT = 20001
[GNU Affero General Public License v3.0](LICENSE)

COMMUNITY_GUILD_ID = 1234567890

DB_NAME = "db_name"
DB_USER = "db_user"
DB_PASSWORD = "db_password"
DB_HOST = "localhost"
DB_PORT = 3306

TOPGG_TOKEN = "topgg_token"

INITIAL_EXTENSIONS = [
"cogs.__dev__",
"cogs.__error__",
"cogs.__eval__",
"cogs.__ipc__",
"cogs.__topgg__",
"cogs.afk",
"cogs.general",
"cogs.help",
"cogs.moderation",
"cogs.roles",
"cogs.settings",
]
```
Copyright © 2023-2024 [Sayan "Sn1F3rt" Bhattacharyya](https://sn1f3rt.dev)
15 changes: 8 additions & 7 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

from typing import Any

import logging
Expand All @@ -7,21 +8,21 @@

import topgg
import aiohttp
import aiomysql

import discord
from discord.app_commands import CommandTree
from discord.ext import commands, tasks
import aiomysql
from discord.ext import tasks, commands
from discord.ext.ipc import Server
from discord.app_commands import CommandTree

import config
from utils.logger import log_member, welcome_member
from utils.db import (
guild_exists,
add_guild,
guild_exists,
is_blacklisted_user,
is_blacklisted_guild,
)
from utils.logger import log_member, welcome_member

import config


class FumeTree(CommandTree):
Expand Down
1 change: 1 addition & 0 deletions cogs/__dev__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import discord
Expand Down
4 changes: 2 additions & 2 deletions cogs/__error__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import string
import random
import string
import traceback

import discord
from discord import app_commands
from discord.ext import commands


if TYPE_CHECKING:
from bot import FumeGuard

Expand Down
6 changes: 4 additions & 2 deletions cogs/__eval__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import io
import inspect
import asyncio
import inspect
import textwrap
import traceback
import subprocess
Expand All @@ -13,9 +14,10 @@
from discord import app_commands
from discord.ext import commands

from config import COMMUNITY_GUILD_ID
from utils.modals import EvalModal, ExecModal

from config import COMMUNITY_GUILD_ID

if TYPE_CHECKING:
from bot import FumeGuard

Expand Down
13 changes: 7 additions & 6 deletions cogs/__ipc__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import discord
Expand All @@ -7,16 +8,16 @@
from discord.ext.ipc.objects import ClientPayload

from utils.db import (
get_mod_log_channel,
update_mod_log_channel,
get_member_log_channel,
update_member_log_channel,
get_welcome_message,
update_welcome_message,
is_afk,
set_afk,
remove_afk,
get_afk_details,
get_mod_log_channel,
get_welcome_message,
get_member_log_channel,
update_mod_log_channel,
update_welcome_message,
update_member_log_channel,
)

if TYPE_CHECKING:
Expand Down
3 changes: 2 additions & 1 deletion cogs/__topgg__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from discord.ext import commands, tasks
from discord.ext import tasks, commands

if TYPE_CHECKING:
from bot import FumeGuard
Expand Down
4 changes: 3 additions & 1 deletion cogs/afk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Optional

from datetime import datetime
Expand All @@ -8,11 +9,12 @@
from discord.ext import commands

from utils.cd import cooldown_level_0
from utils.db import is_afk, set_afk, remove_afk, get_afk_details, get_afk_members
from utils.checks import afk_perms_check
from utils.db import is_afk, get_afk_details, get_afk_members, set_afk, remove_afk

if TYPE_CHECKING:
import aiomysql

from bot import FumeGuard


Expand Down
Loading

0 comments on commit 942eeaa

Please sign in to comment.