From 61ee86168bdea7e133667f360e81e349f59b712b Mon Sep 17 00:00:00 2001 From: agessaman Date: Sat, 16 May 2026 12:11:51 -0700 Subject: [PATCH] chore(workflows): exclude dist directory from shellcheck Updated the GitHub Actions workflow to exclude the dist directory from shellcheck checks, ensuring cleaner linting results. fix(command_manager): reorder datetime import Moved the datetime import to the correct position in command_manager.py for better code organization. fix(reload_config): improve config value retrieval Refactored the _read_config_value function in reload_config.sh to ensure default values are returned correctly when the key is not found in the config file. fix(tests): adjust imports in test_scheduler_logic Updated import statements in test_scheduler_logic.py for consistency and clarity. --- .github/workflows/test.yml | 1 + modules/command_manager.py | 2 +- scripts/reload_config.sh | 11 ++++++++--- tests/test_scheduler_logic.py | 3 +-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 47bc8ac..4c8e327 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,6 +51,7 @@ jobs: -not -path "./node_modules/*" \ -not -path "./.venv/*" \ -not -path "./venv/*" \ + -not -path "./dist/*" \ -print0 | xargs -0 shellcheck --severity=warning lint: diff --git a/modules/command_manager.py b/modules/command_manager.py index 9ff369d..ba03f32 100644 --- a/modules/command_manager.py +++ b/modules/command_manager.py @@ -5,10 +5,10 @@ Handles all bot commands, keyword matching, and response generation """ import asyncio -from datetime import datetime import random import time from dataclasses import dataclass +from datetime import datetime from hashlib import sha256 from typing import Any diff --git a/scripts/reload_config.sh b/scripts/reload_config.sh index 55cb8b3..1f28a80 100755 --- a/scripts/reload_config.sh +++ b/scripts/reload_config.sh @@ -23,14 +23,19 @@ CONFIG="${1:-config.ini}" # --- read port and token from config.ini unless overridden by env ----- _read_config_value() { local key="$1" default="$2" + local value="" if [ -f "$CONFIG" ]; then - grep -A20 '^\[Admin\]' "$CONFIG" \ + value="$(grep -A20 '^\[Admin\]' "$CONFIG" \ | grep -m1 "^${key}[[:space:]]*=" \ | sed 's/^[^=]*=[[:space:]]*//' \ | tr -d '[:space:]' \ - || true + || true)" + fi + if [ -n "$value" ]; then + printf '%s\n' "$value" + else + printf '%s\n' "$default" fi - # fall through to default if nothing printed } ADMIN_PORT="${ADMIN_PORT:-$(_read_config_value port 5001)}" diff --git a/tests/test_scheduler_logic.py b/tests/test_scheduler_logic.py index 896ac93..7aaf565 100644 --- a/tests/test_scheduler_logic.py +++ b/tests/test_scheduler_logic.py @@ -2,10 +2,9 @@ import datetime import time -from zoneinfo import ZoneInfo - from configparser import ConfigParser from unittest.mock import AsyncMock, MagicMock, Mock, patch +from zoneinfo import ZoneInfo import pytest