Found during a review of BIP327's reference implementation and its shipped test gate.
bip-0327/tests.sh (the BIP's own set -e quality gate: mypy --no-error-summary reference.py && python3 reference.py && python3 gen_vectors_helper.py) currently fails at its first step under the current mypy (2.3.1), before the vector suite ever runs:
reference.py:354: error: Argument 1 to "int_from_bytes" has incompatible type "bytearray"; expected "bytes" [arg-type]
reference.py:355: error: Argument 1 to "int_from_bytes" has incompatible type "bytearray"; expected "bytes" [arg-type]
reference.py:672: error: Argument 1 to "int_from_bytes" has incompatible type "bytearray"; expected "bytes" [arg-type]
reference.py:673: error: Argument 1 to "int_from_bytes" has incompatible type "bytearray"; expected "bytes" [arg-type]
Cause: sign() and the tweak-test driver slice secnonce, which is a bytearray by design (mutable, for in-place zeroization); recent mypy/typeshed no longer accepts bytearray for a bytes parameter.
Fix: convert to immutable bytes at the four call sites (int_from_bytes(bytes(secnonce[...]))). This keeps the int_from_bytes helper byte-identical to the BIP-340 reference implementation it was copied from, and is behavior-identical at runtime (int.from_bytes already accepts both types).
Verification: full tests.sh gate now passes end-to-end in a clean container with mypy 2.3.1 (mypy clean + python3 reference.py — all vector suites and the randomized self-test — + gen_vectors_helper.py).
History: this was accepted in older versions of mypy because it was more relaxed then. But from mypy 2.0, it is stricter per PEP 688, mypy no longer treats bytearray and memoryview values as assignable to the bytes type. https://github.com/python/mypy/pull/18371