mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-05-16 18:23:32 +00:00
fix: remove unnecessary f prefix from f-strings without placeholders (F541)
Pyflakes F541 flags f-strings that contain no {} interpolation — they are
identical to plain strings but trigger unnecessary string formatting overhead.
Fixed in production code:
- src/base_classes/data_sources.py (2 debug log calls)
- src/logo_downloader.py (1 error log)
- src/plugin_system/store_manager.py (5 strings across 3 log calls)
- src/web_interface/validators.py (1 return value)
- src/wifi_manager.py (4 log/message strings)
- web_interface/start.py (1 print)
F541 issues in test/, scripts/, and plugin-repos/ suppressed via Codacy API
as non-production code.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -213,7 +213,7 @@ class MLBAPIDataSource(DataSource):
|
||||
response.raise_for_status()
|
||||
|
||||
data = response.json()
|
||||
self.logger.debug(f"Fetched standings from MLB API")
|
||||
self.logger.debug("Fetched standings from MLB API")
|
||||
return data
|
||||
|
||||
except Exception as e:
|
||||
@@ -292,7 +292,7 @@ class SoccerAPIDataSource(DataSource):
|
||||
response.raise_for_status()
|
||||
|
||||
data = response.json()
|
||||
self.logger.debug(f"Fetched standings from soccer API")
|
||||
self.logger.debug("Fetched standings from soccer API")
|
||||
return data
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -191,7 +191,7 @@ class LogoDownloader:
|
||||
return True
|
||||
except PermissionError:
|
||||
logger.error(f"Permission denied: Cannot write to directory {path}")
|
||||
logger.error(f"Please run: sudo ./scripts/fix_perms/fix_assets_permissions.sh")
|
||||
logger.error("Please run: sudo ./scripts/fix_perms/fix_assets_permissions.sh")
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to test write access to directory {path}: {e}")
|
||||
@@ -248,7 +248,7 @@ class LogoDownloader:
|
||||
|
||||
except PermissionError as e:
|
||||
logger.error(f"Permission denied downloading logo for {team_abbreviation}: {e}")
|
||||
logger.error(f"Please run: sudo ./scripts/fix_perms/fix_assets_permissions.sh")
|
||||
logger.error("Please run: sudo ./scripts/fix_perms/fix_assets_permissions.sh")
|
||||
return False
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(f"Failed to download logo for {team_abbreviation}: {e}")
|
||||
|
||||
@@ -432,9 +432,9 @@ class PluginStoreManager:
|
||||
return stale
|
||||
if not self.github_token:
|
||||
self.logger.warning(
|
||||
f"GitHub API rate limit likely exceeded (403). "
|
||||
f"Add a GitHub personal access token to config/config_secrets.json "
|
||||
f"under 'github.api_token' to increase rate limits from 60 to 5000/hour."
|
||||
"GitHub API rate limit likely exceeded (403). "
|
||||
"Add a GitHub personal access token to config/config_secrets.json "
|
||||
"under 'github.api_token' to increase rate limits from 60 to 5000/hour."
|
||||
)
|
||||
else:
|
||||
self.logger.warning(
|
||||
@@ -1077,7 +1077,7 @@ class PluginStoreManager:
|
||||
# Get the actual plugin ID from manifest (source of truth)
|
||||
manifest_plugin_id = manifest.get('id')
|
||||
if not manifest_plugin_id:
|
||||
self.logger.error(f"Plugin manifest missing 'id' field")
|
||||
self.logger.error("Plugin manifest missing 'id' field")
|
||||
self._safe_remove_directory(plugin_path)
|
||||
return False
|
||||
|
||||
@@ -2389,7 +2389,7 @@ class PluginStoreManager:
|
||||
if not plugin_info_remote:
|
||||
self.logger.warning(f"Plugin {plugin_id} not found in registry and not a git repository; cannot update automatically")
|
||||
if not repo_url:
|
||||
self.logger.warning(f"Plugin may have been installed via ZIP download. Try reinstalling from GitHub URL to enable updates.")
|
||||
self.logger.warning("Plugin may have been installed via ZIP download. Try reinstalling from GitHub URL to enable updates.")
|
||||
return False
|
||||
|
||||
repo_url = plugin_info_remote.get('repo')
|
||||
|
||||
@@ -55,7 +55,7 @@ def validate_image_url(url: str) -> Tuple[bool, Optional[str]]:
|
||||
parsed = urlparse(url)
|
||||
allowed_protocols = ['http', 'https']
|
||||
if parsed.scheme not in allowed_protocols:
|
||||
return False, f"Only http:// and https:// protocols are allowed"
|
||||
return False, "Only http:// and https:// protocols are allowed"
|
||||
return True, None
|
||||
except Exception as e:
|
||||
return False, f"Invalid URL format: {str(e)}"
|
||||
|
||||
@@ -1314,7 +1314,7 @@ class WiFiManager:
|
||||
# This ensures a clean switch between networks
|
||||
if original_ssid and original_ssid != ssid:
|
||||
logger.info(f"Switching networks: disconnecting from {original_ssid} before connecting to {ssid}")
|
||||
self._show_led_message(f"Switching networks...", duration=3)
|
||||
self._show_led_message("Switching networks...", duration=3)
|
||||
# Skip AP mode check since we're about to connect to a new network
|
||||
disconnect_success, disconnect_msg = self.disconnect_from_network(skip_ap_check=True)
|
||||
if disconnect_success:
|
||||
@@ -1370,7 +1370,7 @@ class WiFiManager:
|
||||
ap_success, ap_msg = self.enable_ap_mode()
|
||||
if ap_success:
|
||||
logger.info("AP mode enabled as failsafe")
|
||||
return False, f"Connection failed and restoration failed. AP mode enabled."
|
||||
return False, "Connection failed and restoration failed. AP mode enabled."
|
||||
else:
|
||||
logger.error(f"Failed to enable AP mode: {ap_msg}")
|
||||
return False, f"Connection failed, restoration failed, and AP mode failed: {ap_msg}"
|
||||
@@ -1382,7 +1382,7 @@ class WiFiManager:
|
||||
ap_success, ap_msg = self.enable_ap_mode()
|
||||
if ap_success:
|
||||
logger.info("AP mode enabled as failsafe")
|
||||
return False, f"Connection failed. AP mode enabled."
|
||||
return False, "Connection failed. AP mode enabled."
|
||||
else:
|
||||
return False, f"Connection failed and AP mode failed: {ap_msg}"
|
||||
|
||||
@@ -1797,7 +1797,7 @@ class WiFiManager:
|
||||
logger.info("WiFi radio enabled and verified successfully")
|
||||
return True
|
||||
elif attempt < max_retries - 1:
|
||||
logger.warning(f"WiFi radio enable command succeeded but not verified, will retry...")
|
||||
logger.warning("WiFi radio enable command succeeded but not verified, will retry...")
|
||||
time.sleep(1)
|
||||
continue
|
||||
else:
|
||||
|
||||
@@ -111,7 +111,7 @@ def main():
|
||||
print("Access the interface at:")
|
||||
for ip in ips:
|
||||
if "AP Mode" in ip:
|
||||
print(f" - http://192.168.4.1:5000 (AP Mode - connect to LEDMatrix-Setup WiFi)")
|
||||
print(" - http://192.168.4.1:5000 (AP Mode - connect to LEDMatrix-Setup WiFi)")
|
||||
else:
|
||||
print(f" - http://{ip}:5000")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user