Consider the following Python code:
def foo(aqs : typing.List[int]) -> ??? :
array_type = ctypes.c_int64 * len(aqs)
ans = array_type(*aqs)
return ans
What's the correct annotation for the return value of this function? (In place of ???
)
This function doesn't have a consistent return type, since the length of the returned array is part of the array's type. However, the type is always a subclass of ctypes.Array
, which is the most specific annotation you can use:
def foo(aqs: List[int]) -> ctypes.Array:
...
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