From da0eb45df7206f9fe508378414bf0c5a1d28d09a Mon Sep 17 00:00:00 2001 From: Robert de Vries Date: Sat, 11 Apr 2026 18:38:09 +0200 Subject: [PATCH] Fix various minor issues caught by `ruff check` in default mode. Fixing these minor issues helps in adding more checks to fix-up the code without being bothered by these issues. Two minor issues are fixed: - Mark unused variables with a leading underscore - Use idiomatic boolean expressions --- scripts/build_ffi.py | 2 +- tests/test_ciphers.py | 2 +- wolfcrypt/ciphers.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build_ffi.py b/scripts/build_ffi.py index d9519ae..33f1a30 100644 --- a/scripts/build_ffi.py +++ b/scripts/build_ffi.py @@ -81,7 +81,7 @@ def wolfssl_lib_dir(local_wolfssl=None, fips=False): lib_names.append("libwolfssl.so") found = False - for root, dirs, files in os.walk(local_wolfssl): + for root, _dirs, files in os.walk(local_wolfssl): for name in lib_names: if name in files: lib_dir = root diff --git a/tests/test_ciphers.py b/tests/test_ciphers.py index 2cbd483..16d8364 100644 --- a/tests/test_ciphers.py +++ b/tests/test_ciphers.py @@ -605,7 +605,7 @@ def test_ecc_sign_verify_raw(ecc_private, ecc_public): # invalid signature ret = ecc_public.verify_raw(r, s[:-1], plaintext) - assert ret == False + assert not ret # private object holds both private and public info, so it can also verify # using the known public key. diff --git a/wolfcrypt/ciphers.py b/wolfcrypt/ciphers.py index 8fa304b..08d5062 100644 --- a/wolfcrypt/ciphers.py +++ b/wolfcrypt/ciphers.py @@ -183,7 +183,7 @@ def encrypt(self, string): raise ValueError( "empty string not allowed") - if len(string) % self.block_size and not self.mode == MODE_CTR and not "ChaCha" in self._native_type: + if len(string) % self.block_size and not self.mode == MODE_CTR and "ChaCha" not in self._native_type: raise ValueError( "string must be a multiple of %d in length" % self.block_size)