Closed 0nyr closed 1 year ago
Hi @0nyr, you could use Shape
to express this:
from nptyping import NDArray, Shape, UInt8
# A 1-dimensional array (i.e. 1 RGB color).
RGBArray1D = NDArray[Shape["[r, g, b]"], UInt8]
# A 2-dimensional array (i.e. an array of RGB colors).
RGBArrayND = NDArray[Shape["*, [r, g, b]"], UInt8]
Thanks for the answer. I edited mine. Have a look here | StackOverflow. However, this solution is not well handled by VSCode Pylance;
I get:
Expected class type but received "Literal"
"Literal" is not a class
"Literal" is not a classPylance[reportGeneralTypeIssues](https://github.com/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md#diagnostic-severity-rules)
Pylance(reportGeneralTypeIssues)
Thank you for reporting and answering on StackOverflow! Pyright/Pylance can be kinda tricky to get done to be honest. Especially while also maintaining MyPy acceptance.
However, for this particular error that you show, I managed to trick my way out and get Pyright/Pylance acceptance. There will be a 2.1.3
release in a minute that should fix this error. Yet, I dare not announce an official Pyright support for nptyping
at this moment.
EDIT: v2.1.3 is released
Ok very kind of you. I will try it ASAP and give a final response before closing the issue. Have a nice day.
No recent activity: closing
Associated StackOverflow question
There is no 'Tuple' inside nptyping/typing.py. Hence it is not possible to write something like that:
This gives an error: