Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenEXR - Python IntelliSense #1607

Open
404Vector opened this issue Jan 3, 2024 · 6 comments
Open

OpenEXR - Python IntelliSense #1607

404Vector opened this issue Jan 3, 2024 · 6 comments

Comments

@404Vector
Copy link

OpenEXR - Python does not allow code autocompletion using intellisense.
is

intellisense is a simple convenience feature.

However, I hope that the openexr-python package will be supported to enable intellisense so that many developers can easily access it in the future.

@meshula
Copy link
Contributor

meshula commented Jan 4, 2024

Do you know why Intellisense can't autocomplete on OpenEXR? It sounds like a good thing to support if it doesn't require special maintenance. I don't know if anyone on the team has experience with Python and Intellisense.

@404Vector
Copy link
Author

My guess is that the file does not exist in *.py format.

For Imath it exists as Imath.py, but for OpenEXR it does not.
c

I created a simple python wrapper to solve this problem. I hope this project helps you in your decision making.
(https://github.com/404Vector/OpenEXR-Python?tab=readme-ov-file)

Although I haven't done much testing, I confirmed that it works well within the range I need (reading and writing files, extracting metadata, and intellisense support).
d

I don't know if this is the best way to support intellisense (there may be a way to expose it automatically).

However, I think OpenEXR is a very stable project.
And the number of interfaces exposed in the Python runtime environment is small.
Therefore, I think this method will also be easy to maintain.

@404Vector 404Vector reopened this Jan 5, 2024
@meshula
Copy link
Contributor

meshula commented Jan 6, 2024

Your solution does look easy to maintain, thanks for putting it together.

I'm not a Python expert, so please forgive my basic questions.

  • Is this something we could incorporate into our project to solve the problem, or is it an example?
  • will this benefit other systems, such as LSP, or environments like PyCharm?
  • Is the problem solvable at the cpython level (or should we be investigating the problem at the c level?)

@404Vector
Copy link
Author

  • Is this something we could incorporate into our project to solve the problem, or is it an example?

This is a project I created for my convenience, but since it's just a simple wrapper, I think it can be integrated into your project without any problems.

  • will this benefit other systems, such as LSP, or environments like PyCharm?

As a result of the experiment, PyCharm reads the cython file and creates an OpenEXR.py file. (It automatically generates python code, just like automatically generating a document with code and comments.)
Therefore, in PyCharm, intellisense works for the methods in OpenEXR and I was able to read them.
But PyCharm failed to read the file completely.
I knew the name of each method, but I couldn't tell what the parameters were.
ex: It is written as InputFile(*args, **kwargs), so it is impossible to guess what the parameters are.

  • Is the problem solvable at the cpython level (or should we be investigating the problem at the c level?)

In order for all IDEs to support this, it is assumed that the code must exist as *.py rather than solving it at the C or CPython level.

@meshula
Copy link
Contributor

meshula commented Jan 8, 2024

Thanks @404Vector !

@reinecke is there any guidance from the OpenTimelineIO project on this? I think OTIO went through a couple of iterations to get this working across the board.

@Parskatt
Copy link

Parskatt commented Jun 6, 2024

@meshula @404Vector One way to solve this is to use .pyi files which is basically declaring the python interface of your cpython methods. This will make intellisense be able to see expected inputs/outputs, but code will still be executed through the .so module and not via any wrapper.

Also thanks @404Vector for the wrapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants