From 644843b8926eb0f6c5652b464da7c00fcb1f4012 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Sun, 9 Aug 2026 14:12:50 +0200 Subject: [PATCH] Remove unused imports and pointless f-string prefixes (F401, F541, E713) Entirely mechanical, produced by `ruff check --fix --select F401,F541,E713` and reviewed rather than taken on faith: deleting an import is only safe if nothing imports it for its side effects or re-exports it. None of the 19 removed names is referenced anywhere in its file, none appears in any string literal, and none of the touched files uses eval, exec, globals() or __import__, so there is no dynamic lookup that could reach them. --- confluent_client/bin/confetty | 1 - confluent_client/bin/confluent2hosts | 1 - confluent_client/bin/nodebmcpassword | 2 +- confluent_client/bin/nodeconsole | 2 +- confluent_client/bin/nodediscover | 1 - confluent_client/bin/nodelicense | 1 - confluent_client/bin/nodersync | 1 - .../common/initramfs/opt/confluent/bin/apiclient | 2 -- confluent_osdeploy/common/profile/scripts/syncfileclient | 1 - .../el7-diskless/profiles/default/scripts/syncfileclient | 1 - .../el7/profiles/default/scripts/add_local_repositories | 1 - .../el7/profiles/default/scripts/syncfileclient | 1 - .../el8/profiles/default/scripts/add_local_repositories | 1 - .../esxi7/profiles/hypervisor/scripts/getinstalldisk | 4 ++-- .../ubuntu22.04/profiles/default/scripts/mergetime | 1 - confluent_server/bin/confluent | 1 - confluent_server/bin/confluent_selfcheck | 2 -- confluent_server/confluent/plugins/console/tsmsol.py | 1 - confluent_server/setup.py.tmpl | 1 - misc/getipsfromswitchport | 4 ++-- misc/getusbnicaddr | 1 - 21 files changed, 6 insertions(+), 25 deletions(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index 4fe8ebb8..11272271 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -41,7 +41,6 @@ # esc-( would interfere with normal esc use too much # ~ I will not use for now... -import math import getpass import optparse import os diff --git a/confluent_client/bin/confluent2hosts b/confluent_client/bin/confluent2hosts index 66af0f48..5a212a33 100644 --- a/confluent_client/bin/confluent2hosts +++ b/confluent_client/bin/confluent2hosts @@ -14,7 +14,6 @@ path = os.path.realpath(os.path.join(path, '..', 'lib', 'python')) if path.startswith('/opt'): sys.path.append(path) import confluent.client as client -import confluent.sortutil as sortutil def partitionhostsline(line): comment = '' diff --git a/confluent_client/bin/nodebmcpassword b/confluent_client/bin/nodebmcpassword index 0b8883bd..c2f0343c 100755 --- a/confluent_client/bin/nodebmcpassword +++ b/confluent_client/bin/nodebmcpassword @@ -92,7 +92,7 @@ for rsp in session.read('/noderange/{0}/configuration/management_controller/user continue for user in rsp['databynode'][node]['users']: if user['username'] == username: - if not user['uid'] in uid_dict: + if user['uid'] not in uid_dict: uid_dict[user['uid']] = node continue uid_dict[user['uid']] = uid_dict[user['uid']] + ',{}'.format(node) diff --git a/confluent_client/bin/nodeconsole b/confluent_client/bin/nodeconsole index 800da71c..da274319 100755 --- a/confluent_client/bin/nodeconsole +++ b/confluent_client/bin/nodeconsole @@ -894,7 +894,7 @@ async def do_screenshot(): imgdata = res['databynode'][node].get('image', {}).get('imgdata', None) if imgdata: if len(imgdata) < 32: # We were subjected to error - errorstr = f'Unable to get screenshot' + errorstr = 'Unable to get screenshot' if errorstr or imgdata: imgdata = base64.b64decode(imgdata) draw_node(node, imgdata, errorstr, firstnodename, cwidth, cheight) diff --git a/confluent_client/bin/nodediscover b/confluent_client/bin/nodediscover index 4c45a933..cc2ffee6 100755 --- a/confluent_client/bin/nodediscover +++ b/confluent_client/bin/nodediscover @@ -27,7 +27,6 @@ if path.startswith('/opt'): sys.path.append(path) import confluent.asynclient as client -import confluent.sortutil as sortutil defcolumns = ['Node', 'Model', 'Serial', 'UUID', 'Mac Address', 'Type', 'Current IP Addresses'] diff --git a/confluent_client/bin/nodelicense b/confluent_client/bin/nodelicense index b13140da..cb5fb136 100755 --- a/confluent_client/bin/nodelicense +++ b/confluent_client/bin/nodelicense @@ -19,7 +19,6 @@ import optparse import os import signal import sys -import time try: signal.signal(signal.SIGPIPE, signal.SIG_DFL) diff --git a/confluent_client/bin/nodersync b/confluent_client/bin/nodersync index 8d316bab..0c427e86 100755 --- a/confluent_client/bin/nodersync +++ b/confluent_client/bin/nodersync @@ -35,7 +35,6 @@ if path.startswith('/opt'): import confluent.client as client import confluent.screensqueeze as sq -import confluent.sortutil as sortutil def run(): diff --git a/confluent_osdeploy/common/initramfs/opt/confluent/bin/apiclient b/confluent_osdeploy/common/initramfs/opt/confluent/bin/apiclient index 1ae22689..e08097a9 100644 --- a/confluent_osdeploy/common/initramfs/opt/confluent/bin/apiclient +++ b/confluent_osdeploy/common/initramfs/opt/confluent/bin/apiclient @@ -6,14 +6,12 @@ except ImportError: import base64 import ctypes import ctypes.util -import glob import os import select import socket import subprocess import ssl import sys -import struct import time import re import hashlib diff --git a/confluent_osdeploy/common/profile/scripts/syncfileclient b/confluent_osdeploy/common/profile/scripts/syncfileclient index 99687df2..7688bd13 100644 --- a/confluent_osdeploy/common/profile/scripts/syncfileclient +++ b/confluent_osdeploy/common/profile/scripts/syncfileclient @@ -2,7 +2,6 @@ import random import time import subprocess -import importlib import tempfile import json import os diff --git a/confluent_osdeploy/el7-diskless/profiles/default/scripts/syncfileclient b/confluent_osdeploy/el7-diskless/profiles/default/scripts/syncfileclient index 69283a13..ca5a47a6 100644 --- a/confluent_osdeploy/el7-diskless/profiles/default/scripts/syncfileclient +++ b/confluent_osdeploy/el7-diskless/profiles/default/scripts/syncfileclient @@ -1,6 +1,5 @@ #!/usr/bin/python import time -import importlib import tempfile import json import os diff --git a/confluent_osdeploy/el7/profiles/default/scripts/add_local_repositories b/confluent_osdeploy/el7/profiles/default/scripts/add_local_repositories index 12cecbc1..efe677d8 100644 --- a/confluent_osdeploy/el7/profiles/default/scripts/add_local_repositories +++ b/confluent_osdeploy/el7/profiles/default/scripts/add_local_repositories @@ -4,7 +4,6 @@ except ImportError: import ConfigParser as configparser import cStringIO import imp -import sys apiclient = imp.load_source('apiclient', '/etc/confluent/apiclient') repo = None server = None diff --git a/confluent_osdeploy/el7/profiles/default/scripts/syncfileclient b/confluent_osdeploy/el7/profiles/default/scripts/syncfileclient index c17cf52e..e79c77ed 100644 --- a/confluent_osdeploy/el7/profiles/default/scripts/syncfileclient +++ b/confluent_osdeploy/el7/profiles/default/scripts/syncfileclient @@ -1,5 +1,4 @@ #!/usr/bin/python -import importlib import tempfile import json import os diff --git a/confluent_osdeploy/el8/profiles/default/scripts/add_local_repositories b/confluent_osdeploy/el8/profiles/default/scripts/add_local_repositories index c3bc7e68..64b88aba 100644 --- a/confluent_osdeploy/el8/profiles/default/scripts/add_local_repositories +++ b/confluent_osdeploy/el8/profiles/default/scripts/add_local_repositories @@ -5,7 +5,6 @@ except ImportError: import cStringIO import importlib.util import importlib.machinery -import sys import glob modloader = importlib.machinery.SourceFileLoader('apiclient', '/opt/confluent/bin/apiclient') modspec = importlib.util.spec_from_file_location('apiclient', '/opt/confluent/bin/apiclient', loader=modloader) diff --git a/confluent_osdeploy/esxi7/profiles/hypervisor/scripts/getinstalldisk b/confluent_osdeploy/esxi7/profiles/hypervisor/scripts/getinstalldisk index 419f5224..8e725b08 100644 --- a/confluent_osdeploy/esxi7/profiles/hypervisor/scripts/getinstalldisk +++ b/confluent_osdeploy/esxi7/profiles/hypervisor/scripts/getinstalldisk @@ -229,8 +229,8 @@ def main(): sc.write(f'install --drive={nd[0]} --overwritevmfs\n') else: with open('/tmp/storagecfg', 'w') as sc: - sc.write(f'clearpart --firstdisk --overwritevmfs\n') - sc.write(f'install --firstdisk --overwritevmfs\n') + sc.write('clearpart --firstdisk --overwritevmfs\n') + sc.write('install --firstdisk --overwritevmfs\n') if __name__ == '__main__': diff --git a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/mergetime b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/mergetime index 7edb2632..261b1f88 100644 --- a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/mergetime +++ b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/mergetime @@ -1,6 +1,5 @@ #!/usr/bin/python3 import yaml -import os ainst = {} with open('/autoinstall.yaml', 'r') as allin: diff --git a/confluent_server/bin/confluent b/confluent_server/bin/confluent index 5eebfd75..6f8d2d1f 100755 --- a/confluent_server/bin/confluent +++ b/confluent_server/bin/confluent @@ -32,7 +32,6 @@ import confluent.main #p = cProfile.Profile(time.clock) #p.enable() #try: -import multiprocessing def main(): confluent.main.run(sys.argv) diff --git a/confluent_server/bin/confluent_selfcheck b/confluent_server/bin/confluent_selfcheck index e787f211..3afd3e36 100755 --- a/confluent_server/bin/confluent_selfcheck +++ b/confluent_server/bin/confluent_selfcheck @@ -17,8 +17,6 @@ import confluent.certutil as certutil import confluent.client as client import confluent.config.configmanager as configmanager import confluent.netutil as netutil -import tempfile -import shutil import pwd import signal import confluent.collective.manager as collective diff --git a/confluent_server/confluent/plugins/console/tsmsol.py b/confluent_server/confluent/plugins/console/tsmsol.py index cbafe533..e022a4a9 100644 --- a/confluent_server/confluent/plugins/console/tsmsol.py +++ b/confluent_server/confluent/plugins/console/tsmsol.py @@ -26,7 +26,6 @@ import confluent.tasks as tasks import confluent.util as util import aiohmi.exceptions as pygexc import aiohmi.redfish.command as rcmd -import aiohmi.util.webclient as webclient import aiohttp class CustomVerifier(aiohttp.Fingerprint): diff --git a/confluent_server/setup.py.tmpl b/confluent_server/setup.py.tmpl index fc481798..b9e36932 100644 --- a/confluent_server/setup.py.tmpl +++ b/confluent_server/setup.py.tmpl @@ -1,5 +1,4 @@ from setuptools import setup -import os setup( name='confluent_server', diff --git a/misc/getipsfromswitchport b/misc/getipsfromswitchport index aed45e26..216e2a17 100644 --- a/misc/getipsfromswitchport +++ b/misc/getipsfromswitchport @@ -171,11 +171,11 @@ async def main(switch, port): portname = portcandidate if not portname: await ping_everywhere() - async for rsp in client.update(f'/networking/macs/rescan', {'rescan': 'start'}): + async for rsp in client.update('/networking/macs/rescan', {'rescan': 'start'}): pass scanning = True while scanning: - async for rsp in client.read(f'/networking/macs/rescan'): + async for rsp in client.read('/networking/macs/rescan'): if 'scanning' in rsp: scanning = rsp['scanning'] if scanning: diff --git a/misc/getusbnicaddr b/misc/getusbnicaddr index 206d7e64..2e947b51 100644 --- a/misc/getusbnicaddr +++ b/misc/getusbnicaddr @@ -1,7 +1,6 @@ #!/usr/bin/python3 import glob import os -import select import socket