You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use Numpy methods on an image returned from pyexr.read() then Pylance gives me a warning.
E.g. VS Code gives me a red squiggle on .shape on the last line of this code:
import pyexr
impath = 'image.exr'
im = pyexr.read(impath)
im.shape
The full warning from Pylance is:
Cannot access member "shape" for type "Dict[str, ndarray[Unknown, Unknown]]"
Member "shape" is unknownPylance[reportAttributeAccessIssue](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportAttributeAccessIssue)
I saw that you recently added type hints, however the issue seems to be that read() can return either an image or a dict.
A work around is to add a cast() wrapper:
from typing import cast
import pyexr
from numpy import ndarray
impath = 'image.exr'
im = cast(ndarray, pyexr.read(impath))
im.shape
This code gives no warnings from Pylance.
Instead of casting, adding an assertion also works:
assert isinstance(im, ndarray)
The text was updated successfully, but these errors were encountered:
When I use Numpy methods on an image returned from
pyexr.read()
then Pylance gives me a warning.E.g. VS Code gives me a red squiggle on
.shape
on the last line of this code:The full warning from Pylance is:
I saw that you recently added type hints, however the issue seems to be that
read()
can return either an image or a dict.A work around is to add a
cast()
wrapper:This code gives no warnings from Pylance.
Instead of casting, adding an assertion also works:
The text was updated successfully, but these errors were encountered: