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')
Answer from Andrew Eckart on Stack OverflowVideos
How do I create an array in Python?
How to declare an array in Python?
What's the difference between a list and an array in Python?
The arrays in python cannot contain multiple types of data values because consecutive memory locations are initialized to hold data of the same type in the array's backend. The arrays in python cannot contain multiple types of data values because consecutive memory locations are initialized to hold data of the same type in the array's backend.
Say I have a class Book: somewhere and I have a function that takes in an array of Book objects as an argument. How do I Static Type check this?
I've tried
def find_max_author(book_objects: object[ ]):