For most collections we can do:
from typing import List, Tuple, etc
Is there a hint for array? As in:
arr = array.array('i')
As Carcigenicate pointed out, you can use array.array directly as a type annotation. However, you can't use array.array[int] or array.array[float] to specify the type of the elements.
If you need to do this, my suggestion is to use MutableSequence from collections.abc, since arrays implement all of the necessary operations: __len__, __getitem__, __setitem__, __contains__, __iter__, etc.
from collections.abc import MutableSequence
arr: MutableSequence[float] = array.array('f')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With