NumPy type hint that something is both an array and float32? [duplicate]
问题 This question already has answers here : Type hint for NumPy ndarray dtype? (4 answers) Closed 1 year ago . How can I type hint that a value being returned by a function is both an NumPy array and holds NumPy float32 data? I can specify that the returned value is an array using: def func() -> np.ndarray: ... However, this does not enforce the knowledge that it is a float32 array. I can specify that the returned value is of type float32 using: def func() -> np.float32: ... However, this does