mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-05-15 10:03:31 +00:00
fix: remove unused imports and bare exception aliases (pyflakes F401/F841)
Remove unused imports across 86 files in src/, web_interface/, test/, and scripts/ using autoflake. No logic changes — only dead import statements and unused names in from-imports are removed. Also remove bare exception aliases where the variable is never referenced in the handler body: - src/cache/disk_cache.py: except (IOError, OSError, PermissionError) as e - src/cache_manager.py: except (OSError, IOError, PermissionError) as perm_error - src/plugin_system/resource_monitor.py: except Exception as e - web_interface/app.py: except Exception as read_err 86 files changed, 205 lines removed, 18 pre-existing test failures unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,6 @@ Provides common fixtures for mocking core components and test setup.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, MagicMock
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
Diagnostic script to examine NBA API data structure and identify the missing 'id' field issue.
|
||||
"""
|
||||
import requests
|
||||
import json
|
||||
import logging
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, Mock
|
||||
from typing import Any, Dict, Generator, Optional
|
||||
from typing import Any, Dict
|
||||
|
||||
# Add project root to path
|
||||
project_root = Path(__file__).parent.parent.parent
|
||||
|
||||
@@ -6,9 +6,7 @@ Provides common test functionality for all plugins.
|
||||
|
||||
import pytest
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from src.plugin_system.plugin_loader import PluginLoader
|
||||
from src.plugin_system.base_plugin import BasePlugin
|
||||
|
||||
@@ -5,7 +5,6 @@ Verifies that the visual display manager actually renders pixels,
|
||||
loads fonts, and can save snapshots.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
from src.plugin_system.testing import VisualTestDisplayManager
|
||||
|
||||
@@ -6,10 +6,7 @@ Tests cache functionality including memory cache, disk cache, strategy, and metr
|
||||
|
||||
import pytest
|
||||
import time
|
||||
import json
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
from src.cache_manager import CacheManager
|
||||
from src.cache.memory_cache import MemoryCache
|
||||
from src.cache.disk_cache import DiskCache
|
||||
|
||||
@@ -7,9 +7,6 @@ Tests configuration loading, migration, secrets handling, and validation.
|
||||
import pytest
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch, mock_open
|
||||
from src.config_manager import ConfigManager
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import time
|
||||
import pytest
|
||||
import threading
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, MagicMock, patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
from src.config_service import ConfigService
|
||||
from src.config_manager import ConfigManager
|
||||
|
||||
|
||||
@@ -10,11 +10,7 @@ Tests scenarios that commonly cause user configuration errors:
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
# Add project root to path
|
||||
import sys
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import pytest
|
||||
import time
|
||||
from unittest.mock import MagicMock, patch, ANY
|
||||
from src.display_controller import DisplayController
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
class TestDisplayControllerInitialization:
|
||||
"""Test DisplayController initialization and setup."""
|
||||
@@ -25,7 +23,6 @@ class TestDisplayControllerInitialization:
|
||||
# Manually trigger the plugin loading logic that happens in __init__
|
||||
# Since we're using a fixture that mocks __init__ partially, we need to verify
|
||||
# the interactions or simulate the loading if we want to test that specific logic
|
||||
pass
|
||||
# Note: Testing __init__ logic is tricky with the fixture.
|
||||
# We rely on the fixture to give us a usable controller.
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import pytest
|
||||
import time
|
||||
from unittest.mock import MagicMock, patch, ANY
|
||||
from PIL import Image, ImageDraw
|
||||
from unittest.mock import MagicMock, patch
|
||||
from PIL import ImageDraw
|
||||
from src.display_manager import DisplayManager
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -9,11 +9,8 @@ Tests:
|
||||
- Thread safety
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch
|
||||
import threading
|
||||
import sys
|
||||
|
||||
@@ -29,7 +26,7 @@ from src.error_aggregator import (
|
||||
get_error_aggregator,
|
||||
record_error
|
||||
)
|
||||
from src.exceptions import PluginError, ConfigError
|
||||
from src.exceptions import PluginError
|
||||
|
||||
|
||||
class TestErrorRecording:
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import pytest
|
||||
import logging
|
||||
import json
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from src.exceptions import CacheError, ConfigError, PluginError, DisplayError, LEDMatrixError
|
||||
from src.exceptions import CacheError, ConfigError, PluginError, DisplayError
|
||||
from src.common.error_handler import (
|
||||
handle_file_operation,
|
||||
handle_json_operation,
|
||||
safe_execute,
|
||||
retry_on_failure,
|
||||
log_and_continue,
|
||||
log_and_raise
|
||||
safe_execute
|
||||
)
|
||||
|
||||
class TestCustomExceptions:
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import pytest
|
||||
import os
|
||||
from unittest.mock import MagicMock, patch, mock_open
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
from src.font_manager import FontManager
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -6,10 +6,7 @@ Tests layout creation, management, rendering, and element positioning.
|
||||
|
||||
import pytest
|
||||
import json
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch, Mock
|
||||
from datetime import datetime
|
||||
from unittest.mock import MagicMock
|
||||
from src.layout_manager import LayoutManager
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import sys
|
||||
import os
|
||||
import logging
|
||||
import json
|
||||
from typing import Dict, Any
|
||||
|
||||
# Set up logging
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
Simple test script to verify NBA data structure includes team ID fields.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import requests
|
||||
import logging
|
||||
import json
|
||||
from typing import Dict, Any
|
||||
|
||||
# Set up logging
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
@@ -6,7 +6,6 @@ import sys
|
||||
import os
|
||||
import logging
|
||||
import json
|
||||
from typing import Dict, Any
|
||||
|
||||
# Set up logging
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
@@ -6,7 +6,6 @@ This script simulates the leaderboard manager's data fetching process.
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
from typing import Dict, Any
|
||||
|
||||
# Add the src directory to Python path so we can import the leaderboard manager
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
||||
|
||||
@@ -5,9 +5,7 @@ Tests plugin directory discovery, module loading, and class instantiation.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch, Mock, mock_open
|
||||
from unittest.mock import MagicMock, patch
|
||||
from src.plugin_system.plugin_loader import PluginLoader
|
||||
from src.exceptions import PluginError
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@ Tests various failure modes that can occur during plugin loading:
|
||||
import pytest
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
import tempfile
|
||||
from unittest.mock import patch, MagicMock
|
||||
import sys
|
||||
|
||||
# Add project root to path
|
||||
@@ -25,9 +24,7 @@ if str(project_root) not in sys.path:
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
from src.plugin_system.plugin_manager import PluginManager
|
||||
from src.plugin_system.plugin_loader import PluginLoader
|
||||
from src.plugin_system.plugin_state import PluginState
|
||||
from src.exceptions import PluginError
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import pytest
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from unittest.mock import MagicMock, patch, ANY, call
|
||||
from unittest.mock import MagicMock, patch
|
||||
from pathlib import Path
|
||||
from src.plugin_system.plugin_manager import PluginManager
|
||||
from src.plugin_system.plugin_state import PluginState
|
||||
from src.exceptions import PluginError
|
||||
|
||||
class TestPluginManager:
|
||||
"""Test PluginManager functionality."""
|
||||
@@ -90,7 +86,6 @@ class TestPluginLoader:
|
||||
"""Test dependency checking logic."""
|
||||
# This would test _check_dependencies_installed and _install_plugin_dependencies
|
||||
# which requires mocking subprocess calls and file operations
|
||||
pass
|
||||
|
||||
|
||||
class TestPluginExecutor:
|
||||
|
||||
@@ -6,8 +6,6 @@ Tests schema loading, validation, default extraction, and caching.
|
||||
|
||||
import pytest
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch, mock_open
|
||||
from jsonschema import ValidationError
|
||||
from src.plugin_system.schema_manager import SchemaManager
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Tests text rendering, font loading, and text positioning utilities.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch, Mock
|
||||
from unittest.mock import MagicMock, patch
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from src.common.text_helper import TextHelper
|
||||
|
||||
|
||||
@@ -6,10 +6,9 @@ Tests Flask routes, request/response handling, and API functionality.
|
||||
|
||||
import pytest
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch, Mock
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
# Add project root to path
|
||||
project_root = Path(__file__).parent.parent
|
||||
@@ -288,7 +287,6 @@ class TestDisplayAPI:
|
||||
@patch('web_interface.blueprints.api_v3._ensure_cache_manager')
|
||||
def test_stop_on_demand_display(self, mock_ensure_cache, client):
|
||||
"""Test stopping on-demand display."""
|
||||
from web_interface.blueprints.api_v3 import api_v3
|
||||
|
||||
# Mock the cache manager returned by _ensure_cache_manager
|
||||
mock_cache_manager = MagicMock()
|
||||
@@ -440,7 +438,6 @@ class TestPluginsAPI:
|
||||
|
||||
def test_get_plugin_schema(self, client):
|
||||
"""Test getting plugin configuration schema."""
|
||||
from web_interface.blueprints.api_v3 import api_v3
|
||||
|
||||
response = client.get('/api/v3/plugins/schema?plugin_id=weather')
|
||||
|
||||
@@ -477,7 +474,6 @@ class TestPluginsAPI:
|
||||
|
||||
def test_get_operation_history(self, client):
|
||||
"""Test getting operation history."""
|
||||
from web_interface.blueprints.api_v3 import api_v3
|
||||
|
||||
response = client.get('/api/v3/plugins/operation/history')
|
||||
|
||||
@@ -487,7 +483,6 @@ class TestPluginsAPI:
|
||||
|
||||
def test_get_plugin_state(self, client):
|
||||
"""Test getting plugin state."""
|
||||
from web_interface.blueprints.api_v3 import api_v3
|
||||
|
||||
response = client.get('/api/v3/plugins/state')
|
||||
|
||||
|
||||
@@ -5,12 +5,10 @@ Integration tests for plugin operations (install, update, uninstall).
|
||||
import unittest
|
||||
import tempfile
|
||||
import shutil
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from src.plugin_system.operation_queue import PluginOperationQueue
|
||||
from src.plugin_system.operation_types import OperationType, OperationStatus
|
||||
from src.plugin_system.operation_types import OperationType
|
||||
from src.plugin_system.state_manager import PluginStateManager
|
||||
from src.plugin_system.operation_history import OperationHistory
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ Tests import the production function from src.web_interface.validators
|
||||
to ensure they exercise the real code path.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from src.web_interface.validators import dedup_unique_arrays as _dedup_unique_arrays
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import tempfile
|
||||
import shutil
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock, MagicMock, patch
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from src.plugin_system.state_reconciliation import (
|
||||
StateReconciliation,
|
||||
@@ -15,7 +15,7 @@ from src.plugin_system.state_reconciliation import (
|
||||
FixAction,
|
||||
ReconciliationResult
|
||||
)
|
||||
from src.plugin_system.state_manager import PluginStateManager, PluginState, PluginStateStatus
|
||||
from src.plugin_system.state_manager import PluginStateManager, PluginStateStatus
|
||||
|
||||
|
||||
class TestStateReconciliation(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user