From 2d791406935c6d83eb674255e720997f71534909 Mon Sep 17 00:00:00 2001 From: greateggsgreg Date: Sun, 10 May 2026 12:13:17 -0400 Subject: [PATCH] fix mypy bytearray-vs-bytes error in test_aead The corrupt-ciphertext branches in test_variants_roundtrip_aad and test_variants_roundtrip_no_aad use bytearray purely so they can flip a byte; bytes is immutable. They then pass the bytearray to c.decrypt, which is typed Callable[[bytes, ...], bytes]. mypy flags this: tests/test_aead.py:162: error: Argument 1 has incompatible type "bytearray"; expected "bytes" [arg-type] tests/test_aead.py:196: error: Argument 1 has incompatible type "bytearray"; expected "bytes" [arg-type] The bytearray is just a building block, not the value under test. Convert it back at the call site so the type matches the alias and the roundtrip uses the same bytes type as the success path on lines 156/190. --- tests/test_aead.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_aead.py b/tests/test_aead.py index c1b1a902..98a9902b 100644 --- a/tests/test_aead.py +++ b/tests/test_aead.py @@ -159,7 +159,7 @@ def test_variants_roundtrip_aad( with pytest.raises(exc.CryptoError): ct1 = bytearray(ct) ct1[0] = ct1[0] ^ 0xFF - c.decrypt(ct1, aad, unonce, ukey) + c.decrypt(bytes(ct1), aad, unonce, ukey) @given( @@ -193,7 +193,7 @@ def test_variants_roundtrip_no_aad( with pytest.raises(exc.CryptoError): ct1 = bytearray(ct) ct1[0] = ct1[0] ^ 0xFF - c.decrypt(ct1, aad, unonce, ukey) + c.decrypt(bytes(ct1), aad, unonce, ukey) @pytest.mark.parametrize(