Not every NumPy type (e.g., the ml_dtypes.bfloat16 NumPy extension type) has a type in the Python buffer protocol, so exporting such a buffer with PyBUF_FORMAT may fail.
However, we don't care about the self-reported type of a buffer if the user provides an explicit type. In the case that an explicit type is provided, don't request the format from the buffer protocol, which allows arrays whose element types are unknown to the buffer protocol to be passed.
Hold off a second before merging, I realized there's a bug here.