ci: add flake8 lint workflow; fix unused imports and f-string issues
Lint / Python (flake8) (push) Successful in 19s

Removes unused datetime/re imports (F401). Removes f prefix from
2 f-strings with no placeholders (F541). Fixes trailing whitespace
and missing newline (W291/W292). Config ignores style-only rules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-14 00:08:11 -04:00
parent 2ffcb79f19
commit 775d0ffce6
3 changed files with 39 additions and 9 deletions
+7 -9
View File
@@ -17,9 +17,6 @@ import subprocess
import sys
import argparse
from collections import defaultdict
from datetime import datetime
import re
DEBUG = False
class Colors:
@@ -396,8 +393,8 @@ def calculate_resilience_score(osd_data, host_name, all_hosts_data, osd_tree):
host_class_counts = {}
for host_node in [n for n in osd_tree['nodes'] if n['type'] == 'host']:
h_name = host_node['name']
host_osds = [osd_tree['nodes'][i] for i in range(len(osd_tree['nodes']))
if osd_tree['nodes'][i].get('id') in host_node.get('children', [])
host_osds = [osd_tree['nodes'][i] for i in range(len(osd_tree['nodes']))
if osd_tree['nodes'][i].get('id') in host_node.get('children', [])
and osd_tree['nodes'][i].get('type') == 'osd']
host_class_counts[h_name] = {
@@ -586,12 +583,12 @@ def analyze_cluster():
print(f" - {issue}")
if candidate['capacity_factors']:
print(f" Capacity Optimization:")
print(" Capacity Optimization:")
for factor in candidate['capacity_factors'][:2]:
print(f"{factor}")
if candidate['resilience_factors']:
print(f" Host Distribution:")
print(" Host Distribution:")
for factor in candidate['resilience_factors'][:2]:
print(f"{factor}")
@@ -622,9 +619,10 @@ def analyze_cluster():
print(f" Issues: {candidate['health_issues'][0]}")
print()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Analyze Ceph OSDs for replacement candidates across entire cluster')
parser.add_argument('--class', dest='device_class', choices=['hdd', 'nvme'],
parser.add_argument('--class', dest='device_class', choices=['hdd', 'nvme'],
help='Filter by device class')
parser.add_argument('--min-size', type=float, default=0,
help='Minimum OSD size in TB to consider')
@@ -645,4 +643,4 @@ if __name__ == "__main__":
print(f"{Colors.RED}Error: {e}{Colors.END}")
import traceback
traceback.print_exc()
sys.exit(1)
sys.exit(1)