pycryptodome
pycryptodome copied to clipboard
Mypy errors when mixing PyCryptodome integer type and Python int
On https://github.com/Legrandin/pycryptodome/blob/5dace638b70ac35bb5d9b565f3e75f7869c9d851/lib/Crypto/PublicKey/RSA.pyi#L41-L45 the RSA.construct()
is defined to have tuple of Python ints only instead of also accepting PyCryptodome integer types (like IntegerGMP
or just simply Integer
). Mixing both int types throws Mypy off and it gives an incompatible variable type error.
Seems like it's fixable by defining a new integer type that is a union of Python int and IntegerBase (something like IntegerLike = Union[int, IntegerBase]
) and use this new definition for crypto-related methods that accept both Python int and PyCryptodome integers.