We can create custom dtypes with record-like properties:
dt = np.dtype([('R','u1'), ('G','u1'), ('B','u1'), ('A','u1')])
We can annotate the data type of an ndarray for type hinting:
numpy.typing.NDArray = numpy.ndarray[typing.Any, numpy.dtype[+ScalarType]]
However, I can't work out how to hint that an array is supposed to have a custom dtype, for instance a: NDArray[dt] results in Pylance complaining:
Declared return type, "ndarray[Any, dtype[Unknown]]", is partially unknown Pylance(reportUnknownVariableType)
Illegal type annotation: variable not allowed unless it is a type alias Pylance(reportGeneralTypeIssues)
I guess what I'm asking is if is possible to create a type from a dtype object, or what the +ScalarType means in numpy.ndarray[typing.Any, numpy.dtype[+ScalarType]].