Fix ruff lint errors across matrixbot (F401, F841, E402)
Remove unused imports: logging from bot.py and config.py, RoomMessageText/ UnknownEvent from callbacks.py, functools.partial and MAX_INPUT_LENGTH from commands.py. Rename unused local variables to _ (resp in cmd_ping, symbols in render_keyboard_plain, guesses_left in two wordle functions). Move wordle import to top of commands.py to fix E402. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from nio import AsyncClient, RoomMessageText, UnknownEvent
|
from nio import AsyncClient
|
||||||
|
|
||||||
from config import BOT_PREFIX, MATRIX_USER_ID
|
from config import BOT_PREFIX, MATRIX_USER_ID
|
||||||
from commands import COMMANDS, metrics
|
from commands import COMMANDS, metrics
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import time
|
|||||||
import logging
|
import logging
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
from nio import AsyncClient
|
from nio import AsyncClient
|
||||||
|
|
||||||
from utils import send_text, send_html, send_reaction, sanitize_input
|
from utils import send_text, send_html, send_reaction, sanitize_input
|
||||||
|
from wordle import handle_wordle
|
||||||
from config import (
|
from config import (
|
||||||
MAX_DICE_SIDES, MAX_DICE_COUNT, BOT_PREFIX, ADMIN_USERS,
|
MAX_DICE_SIDES, MAX_DICE_COUNT, BOT_PREFIX, ADMIN_USERS,
|
||||||
OLLAMA_URL, OLLAMA_MODEL, MAX_INPUT_LENGTH, COOLDOWN_SECONDS,
|
OLLAMA_URL, OLLAMA_MODEL, COOLDOWN_SECONDS,
|
||||||
MINECRAFT_RCON_HOST, MINECRAFT_RCON_PORT, MINECRAFT_RCON_PASSWORD,
|
MINECRAFT_RCON_HOST, MINECRAFT_RCON_PORT, MINECRAFT_RCON_PASSWORD,
|
||||||
RCON_TIMEOUT, MIN_USERNAME_LENGTH, MAX_USERNAME_LENGTH,
|
RCON_TIMEOUT, MIN_USERNAME_LENGTH, MAX_USERNAME_LENGTH,
|
||||||
)
|
)
|
||||||
@@ -99,7 +99,7 @@ async def cmd_help(client: AsyncClient, room_id: str, sender: str, args: str):
|
|||||||
@command("ping", "Check bot latency")
|
@command("ping", "Check bot latency")
|
||||||
async def cmd_ping(client: AsyncClient, room_id: str, sender: str, args: str):
|
async def cmd_ping(client: AsyncClient, room_id: str, sender: str, args: str):
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
resp = await send_text(client, room_id, "Pong!")
|
_ = await send_text(client, room_id, "Pong!")
|
||||||
elapsed = (time.monotonic() - start) * 1000
|
elapsed = (time.monotonic() - start) * 1000
|
||||||
# Edit isn't straightforward in Matrix, so just send a follow-up if slow
|
# Edit isn't straightforward in Matrix, so just send a follow-up if slow
|
||||||
if elapsed > 500:
|
if elapsed > 500:
|
||||||
@@ -822,8 +822,6 @@ async def cmd_health(client: AsyncClient, room_id: str, sender: str, args: str):
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Wordle
|
# Wordle
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
from wordle import handle_wordle
|
|
||||||
|
|
||||||
|
|
||||||
@command("wordle", "Play Wordle! (!wordle help for details)")
|
@command("wordle", "Play Wordle! (!wordle help for details)")
|
||||||
async def cmd_wordle(client: AsyncClient, room_id: str, sender: str, args: str):
|
async def cmd_wordle(client: AsyncClient, room_id: str, sender: str, args: str):
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|||||||
+2
-3
@@ -317,7 +317,6 @@ def render_keyboard_plain(game: WordleGame) -> str:
|
|||||||
letter_states[letter] = max(letter_states.get(letter, -1), score)
|
letter_states[letter] = max(letter_states.get(letter, -1), score)
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
symbols = {-1: " ", 0: "\u2717", 1: "?", 2: "\u2713"}
|
|
||||||
for row in _KB_ROWS:
|
for row in _KB_ROWS:
|
||||||
chars = []
|
chars = []
|
||||||
for letter in row:
|
for letter in row:
|
||||||
@@ -465,7 +464,7 @@ async def wordle_start_or_status(client: AsyncClient, room_id: str, sender: str,
|
|||||||
if sender in _active_games:
|
if sender in _active_games:
|
||||||
game = _active_games[sender]
|
game = _active_games[sender]
|
||||||
if not game.finished:
|
if not game.finished:
|
||||||
guesses_left = 6 - len(game.guesses)
|
_ = 6 - len(game.guesses)
|
||||||
grid_plain = render_grid_plain(game)
|
grid_plain = render_grid_plain(game)
|
||||||
kb_plain = render_keyboard_plain(game)
|
kb_plain = render_keyboard_plain(game)
|
||||||
plain = (
|
plain = (
|
||||||
@@ -626,7 +625,7 @@ async def wordle_guess(
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Still playing — show grid + keyboard
|
# Still playing — show grid + keyboard
|
||||||
guesses_left = 6 - len(game.guesses)
|
_ = 6 - len(game.guesses)
|
||||||
grid_plain = render_grid_plain(game)
|
grid_plain = render_grid_plain(game)
|
||||||
kb_plain = render_keyboard_plain(game)
|
kb_plain = render_keyboard_plain(game)
|
||||||
plain = (
|
plain = (
|
||||||
|
|||||||
Reference in New Issue
Block a user