From c6c2d3112ea5c9b96964bada9e8321639616a522 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Sun, 9 Aug 2026 14:14:18 +0200 Subject: [PATCH] Tidy comparisons, statement layout and a redundant alias (E711, E712, E701, PLC0414) Hand written rather than autofixed, since three of the four need the surrounding code read to be sure they are equivalent: - confetty: `powerstate == None` -> `is None`. - nodeconfig: `setmode != True` / `!= False` -> `not setmode` / `setmode`. Safe because setmode only ever holds None, True or False, and the two lines above each test normalise None away first. - pam: split two `if cond: stmt` one-liners. - imgutil: `from shutil import copytree as copytree`, an alias that renames nothing. Not a re-export marker, this is a script. --- confluent_client/bin/confetty | 2 +- confluent_client/bin/nodeconfig | 4 ++-- confluent_server/confluent/pam.py | 6 ++++-- imgutil/imgutil | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index 11272271..d32ad5d2 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -1042,7 +1042,7 @@ def main(): except IOError: pass if powerstate is None or powertime < time.time() - 10: # Check powerstate every 10 seconds - if powerstate == None: + if powerstate is None: powerstate = True powertime = time.time() check_power_state() diff --git a/confluent_client/bin/nodeconfig b/confluent_client/bin/nodeconfig index ba1b861e..4746c4b6 100755 --- a/confluent_client/bin/nodeconfig +++ b/confluent_client/bin/nodeconfig @@ -170,7 +170,7 @@ def parse_config_line(arguments, single=False): if '=' in param or param[-1] == ':' or forceset: if setmode is None: setmode = True - if setmode != True: + if not setmode: bailout('Cannot do set and query in same command: Query detected but "{0}" appears to be set'.format(param)) if '=' in param: key, _, value = param.partition('=') @@ -182,7 +182,7 @@ def parse_config_line(arguments, single=False): else: if setmode is None: setmode = False - if setmode != False: + if setmode: bailout('Cannot do set and query in same command: Set mode detected but "{0}" appears to be a query'.format(param)) if '.' not in param: if param == 'bmc': diff --git a/confluent_server/confluent/pam.py b/confluent_server/confluent/pam.py index 4d613dc1..4823358d 100644 --- a/confluent_server/confluent/pam.py +++ b/confluent_server/confluent/pam.py @@ -178,8 +178,10 @@ class pam(): return 0 # python3 ctypes prefers bytes - if isinstance(username, str): username = username.encode(encoding) - if isinstance(service, str): service = service.encode(encoding) + if isinstance(username, str): + username = username.encode(encoding) + if isinstance(service, str): + service = service.encode(encoding) if b'\x00' in username or b'\x00' in service: self.code = 4 # PAM_SYSTEM_ERR in Linux-PAM diff --git a/imgutil/imgutil b/imgutil/imgutil index 58f022ab..118e9b29 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -5,7 +5,7 @@ import ctypes import ctypes.util import datetime import inspect -from shutil import copytree as copytree +from shutil import copytree if hasattr(inspect, 'getfullargspec') and 'dirs_exist_ok' in inspect.getfullargspec(copytree).args: def copy_tree(src, dst): copytree(src, dst, dirs_exist_ok=True)