Add stubs for OpenEXR and OpenImageIO #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The signatures provided by pyblind11 are not as accurate as we'd like them to be. For example:
The wrapper for this function looks like this:
The type
py::object
is used because the result type varies. From looking at the wrapper code above, we know that true return type of this function, in python terms, is actuallytyping.Optional[ImageSpec]
(which in more recent versions of python can be written asImageSpec | None
).The manual fixes that I've had to make fall into a few categories:
Buffer
should benumpy.ndaarray
: This refers to the newtyping.Buffer
protocol, and I just read that this is officially supported through pybind11 usingpy::buffer
. Since we know thatBuffer
is the name emitted by pybind11, I can make a PR against mypy to support this. However, in the short term I think we need to keep annotating this asnumpy.ndarray
because IIUC the buffer protocol is only supported in python 3.12 and later.list[X]
should beIterable[X]
. Honestly, this is an issue with pybind11’s docstring generation, because it seems to permit any kind of iterable instead of just a list.TypeDesc
should beUnion[TypeDesc, BASETYPE, str]
: Is this handled using implicit conversion? If so, it seems reasonable that pybind11 should produce a better annotation for this type, as it should know the alternatives.X or None
?