nuke-python-stubs icon indicating copy to clipboard operation
nuke-python-stubs copied to clipboard

Adding stubs to `PYTHONPATH`

Open sisoe24 opened this issue 1 year ago • 0 comments

Adding stubs to the PYTHONPATH can be tricky because the stubs are currently in .py files, which causes Nuke to break as it imports them instead of its own files. An alternative is to use .pyi files, but as they are currently structured, some imports are not being resolved properly. One solution I have found is to run stubgen from mypy on top of the generated stubs.

PYTHONWARNINGS="ignore:invalid escape sequence:SyntaxWarning" stubgen stubs --include-docstrings

But there are many problems that need to be solved, especially syntax errors. We can ignore the escape characters, which are mostly Qt Regex objects, but some have to be dealt with manually.

Example that stubgen work:

image

Of course, there may also be a situation where not every conversion worked correctly so we need to see.

sisoe24 avatar Aug 21 '24 17:08 sisoe24