mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-05-15 18:03:32 +00:00
fix: remove unused local variable assignments (pyflakes F841)
Dead assignments removed across src/ and web_interface/: - background_data_service: drop future= on fire-and-forget executor.submit - base_classes/baseball: drop font= (all rendering uses self.fonts['time']) - base_classes/hockey: drop status_short= (never referenced after assignment) - common/cli: drop game_helper=/config_helper= bindings in import-test block; constructors called for instantiation-only validation - common/display_helper: drop text_width= (x_position uses display_width directly); drop draw= in create_error_image (uses _draw_centered_text) - config_manager: remove dead secrets_content loading block in migration path (comment already noted save_config_atomic handles secrets internally) - display_manager: drop setup_start= (timing was never completed or read) - font_manager: drop target_path= (catalog uses font_file_path directly); drop face=/font= bindings in validate_font (validation by construction — TypeError on failure is the signal, not the return value) - font_test_manager: drop width=/height= (draw_text uses display_manager directly) - plugin_system/state_reconciliation: drop manager= (only config/disk/state_mgr used) - plugin_system/store_manager: drop result= on pip install subprocess.run (check=True raises on failure; stdout unused) - web_interface/blueprints/pages_v3: drop main_config_path=""/secrets_config_path="" (render_template uses config_manager.get_*_path() inline) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -223,7 +223,7 @@ class BackgroundDataService:
|
|||||||
self.stats['cache_misses'] += 1
|
self.stats['cache_misses'] += 1
|
||||||
|
|
||||||
# Submit to executor
|
# Submit to executor
|
||||||
future = self.executor.submit(self._fetch_data_worker, request)
|
self.executor.submit(self._fetch_data_worker, request)
|
||||||
|
|
||||||
logger.info(f"Submitted background fetch request {request_id} for {sport} {year}")
|
logger.info(f"Submitted background fetch request {request_id} for {sport} {year}")
|
||||||
return request_id
|
return request_id
|
||||||
|
|||||||
@@ -329,7 +329,6 @@ class Baseball(SportsCore):
|
|||||||
return
|
return
|
||||||
|
|
||||||
series_summary = game.get("series_summary", "")
|
series_summary = game.get("series_summary", "")
|
||||||
font = self.fonts.get('detail', ImageFont.load_default())
|
|
||||||
bbox = draw_overlay.textbbox((0, 0), series_summary, font=self.fonts['time'])
|
bbox = draw_overlay.textbbox((0, 0), series_summary, font=self.fonts['time'])
|
||||||
height = bbox[3] - bbox[1]
|
height = bbox[3] - bbox[1]
|
||||||
shots_y = (self.display_height - height) // 2
|
shots_y = (self.display_height - height) // 2
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ class Hockey(SportsCore):
|
|||||||
away_shots = round(home_team_saves / home_team_saves_per)
|
away_shots = round(home_team_saves / home_team_saves_per)
|
||||||
if away_team_saves_per > 0:
|
if away_team_saves_per > 0:
|
||||||
home_shots = round(away_team_saves / away_team_saves_per)
|
home_shots = round(away_team_saves / away_team_saves_per)
|
||||||
status_short = status["type"].get("shortDetail", "")
|
|
||||||
|
|
||||||
if situation and status["type"]["state"] == "in":
|
if situation and status["type"]["state"] == "in":
|
||||||
# Detect scoring events from status detail
|
# Detect scoring events from status detail
|
||||||
# status_detail = status["type"].get("detail", "")
|
# status_detail = status["type"].get("detail", "")
|
||||||
|
|||||||
@@ -63,12 +63,12 @@ def test_utilities(display_width: int, display_height: int):
|
|||||||
|
|
||||||
# Test GameHelper
|
# Test GameHelper
|
||||||
print("Testing GameHelper...")
|
print("Testing GameHelper...")
|
||||||
game_helper = GameHelper()
|
GameHelper()
|
||||||
print("GameHelper initialized")
|
print("GameHelper initialized")
|
||||||
|
|
||||||
# Test ConfigHelper
|
# Test ConfigHelper
|
||||||
print("Testing ConfigHelper...")
|
print("Testing ConfigHelper...")
|
||||||
config_helper = ConfigHelper()
|
ConfigHelper()
|
||||||
print("ConfigHelper initialized")
|
print("ConfigHelper initialized")
|
||||||
|
|
||||||
print("All tests passed!")
|
print("All tests passed!")
|
||||||
|
|||||||
@@ -166,8 +166,7 @@ class DisplayHelper:
|
|||||||
img = self.create_base_image(background_color)
|
img = self.create_base_image(background_color)
|
||||||
draw = ImageDraw.Draw(img)
|
draw = ImageDraw.Draw(img)
|
||||||
|
|
||||||
# Calculate text position (start off-screen to the right)
|
# Start text off-screen to the right
|
||||||
text_width = draw.textlength(text, font=font)
|
|
||||||
x_position = self.display_width
|
x_position = self.display_width
|
||||||
|
|
||||||
# Draw text
|
# Draw text
|
||||||
@@ -216,8 +215,7 @@ class DisplayHelper:
|
|||||||
PIL Image with error message
|
PIL Image with error message
|
||||||
"""
|
"""
|
||||||
img = self.create_base_image((50, 0, 0)) # Dark red background
|
img = self.create_base_image((50, 0, 0)) # Dark red background
|
||||||
draw = ImageDraw.Draw(img)
|
|
||||||
|
|
||||||
# Use default font
|
# Use default font
|
||||||
font = ImageFont.load_default()
|
font = ImageFont.load_default()
|
||||||
|
|
||||||
|
|||||||
@@ -313,17 +313,8 @@ class ConfigManager:
|
|||||||
self._merge_template_defaults(self.config, template_config)
|
self._merge_template_defaults(self.config, template_config)
|
||||||
|
|
||||||
# Save migrated config using atomic save to preserve permissions
|
# Save migrated config using atomic save to preserve permissions
|
||||||
# Load secrets if they exist to pass to atomic save
|
|
||||||
secrets_content = {}
|
|
||||||
if os.path.exists(self.secrets_path):
|
|
||||||
try:
|
|
||||||
with open(self.secrets_path, 'r') as f_secrets:
|
|
||||||
secrets_content = json.load(f_secrets)
|
|
||||||
except Exception:
|
|
||||||
pass # Continue without secrets if can't load
|
|
||||||
|
|
||||||
# Use atomic save to preserve file permissions
|
# Use atomic save to preserve file permissions
|
||||||
# Note: save_config_atomic handles secrets internally, no need to pass new_secrets
|
# Note: save_config_atomic handles secrets internally
|
||||||
result = self.save_config_atomic(
|
result = self.save_config_atomic(
|
||||||
new_config_data=self.config,
|
new_config_data=self.config,
|
||||||
create_backup=False, # Already created backup above
|
create_backup=False, # Already created backup above
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ class DisplayManager:
|
|||||||
|
|
||||||
def _setup_matrix(self):
|
def _setup_matrix(self):
|
||||||
"""Initialize the RGB matrix with configuration settings."""
|
"""Initialize the RGB matrix with configuration settings."""
|
||||||
setup_start = time.time()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Allow callers (e.g., web UI) to force non-hardware fallback mode
|
# Allow callers (e.g., web UI) to force non-hardware fallback mode
|
||||||
if getattr(self, '_force_fallback', False):
|
if getattr(self, '_force_fallback', False):
|
||||||
|
|||||||
@@ -697,8 +697,6 @@ class FontManager:
|
|||||||
fonts_dir = Path("assets/fonts")
|
fonts_dir = Path("assets/fonts")
|
||||||
ensure_directory_permissions(fonts_dir, get_assets_dir_mode())
|
ensure_directory_permissions(fonts_dir, get_assets_dir_mode())
|
||||||
|
|
||||||
target_path = os.path.join(fonts_dir, f"{family_name}.{font_file_path.rsplit('.', 1)[-1]}")
|
|
||||||
|
|
||||||
# Add to catalog
|
# Add to catalog
|
||||||
self.font_catalog[family_name] = font_file_path
|
self.font_catalog[family_name] = font_file_path
|
||||||
self.clear_cache()
|
self.clear_cache()
|
||||||
@@ -744,11 +742,11 @@ class FontManager:
|
|||||||
|
|
||||||
if font_path.endswith('.bdf'):
|
if font_path.endswith('.bdf'):
|
||||||
# Try to load BDF font
|
# Try to load BDF font
|
||||||
face = freetype.Face(font_path)
|
freetype.Face(font_path)
|
||||||
return {"valid": True, "type": "bdf", "family": "unknown"}
|
return {"valid": True, "type": "bdf", "family": "unknown"}
|
||||||
elif font_path.endswith('.ttf'):
|
elif font_path.endswith('.ttf'):
|
||||||
# Try to load TTF font
|
# Try to load TTF font
|
||||||
font = ImageFont.truetype(font_path, 12)
|
ImageFont.truetype(font_path, 12)
|
||||||
return {"valid": True, "type": "ttf", "family": "unknown"}
|
return {"valid": True, "type": "ttf", "family": "unknown"}
|
||||||
else:
|
else:
|
||||||
return {"valid": False, "error": "Unsupported font format"}
|
return {"valid": False, "error": "Unsupported font format"}
|
||||||
|
|||||||
@@ -79,10 +79,6 @@ class FontTestManager:
|
|||||||
# Clear the display
|
# Clear the display
|
||||||
self.display_manager.clear()
|
self.display_manager.clear()
|
||||||
|
|
||||||
# Get display dimensions
|
|
||||||
width = self.display_manager.matrix.width
|
|
||||||
height = self.display_manager.matrix.height
|
|
||||||
|
|
||||||
# Draw font name at the top
|
# Draw font name at the top
|
||||||
self.display_manager.draw_text(self.current_config['display_name'], y=2, color=(255, 255, 255))
|
self.display_manager.draw_text(self.current_config['display_name'], y=2, color=(255, 255, 255))
|
||||||
|
|
||||||
|
|||||||
@@ -285,7 +285,6 @@ class StateReconciliation:
|
|||||||
|
|
||||||
config = config_state.get(plugin_id, {})
|
config = config_state.get(plugin_id, {})
|
||||||
disk = disk_state.get(plugin_id, {})
|
disk = disk_state.get(plugin_id, {})
|
||||||
manager = manager_state.get(plugin_id, {})
|
|
||||||
state_mgr = state_manager_state.get(plugin_id, {})
|
state_mgr = state_manager_state.get(plugin_id, {})
|
||||||
|
|
||||||
# Check: Plugin exists on disk but not in config
|
# Check: Plugin exists on disk but not in config
|
||||||
|
|||||||
@@ -1728,7 +1728,7 @@ class PluginStoreManager:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.logger.info(f"Installing dependencies for {plugin_path.name}")
|
self.logger.info(f"Installing dependencies for {plugin_path.name}")
|
||||||
result = subprocess.run(
|
subprocess.run(
|
||||||
['pip3', 'install', '--break-system-packages', '-r', str(requirements_file)],
|
['pip3', 'install', '--break-system-packages', '-r', str(requirements_file)],
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ def index():
|
|||||||
secrets_config_json = "{}"
|
secrets_config_json = "{}"
|
||||||
main_config_data = {}
|
main_config_data = {}
|
||||||
secrets_config_data = {}
|
secrets_config_data = {}
|
||||||
main_config_path = ""
|
|
||||||
secrets_config_path = ""
|
|
||||||
|
|
||||||
return render_template('v3/index.html',
|
return render_template('v3/index.html',
|
||||||
schedule_config=schedule_config,
|
schedule_config=schedule_config,
|
||||||
|
|||||||
Reference in New Issue
Block a user