Skip to content

add vtk stub files #10446

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

Closed
wants to merge 28 commits into from
Closed

add vtk stub files #10446

wants to merge 28 commits into from

Conversation

Gryfenfer97
Copy link

@Gryfenfer97 Gryfenfer97 commented Jul 12, 2023

These are the stub files generated by the vtk script generate_pyi.py
Should fix #10442

I am cleaning them and test them to be sure that it works
TODO:

Cleaning:

  • vtkmodules

Generating

  • gtk/
  • numpy_interface/
  • qt/
  • tk/
  • util/
  • web/
  • wx/
  • tests

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member

pre-commit.ci autofix

@github-actions

This comment has been minimized.

@Gryfenfer97
Copy link
Author

Gryfenfer97 commented Jul 22, 2023

I may need some help for this because the stub file generated doesn't seem to match valid python code and this generate an error
I have this piece of code in the generated stub file (the comment is the error generated by mypy):

class vtkTransform(vtkLinearTransform):
    @overload  # Overload does not consistently use the "@staticmethod" decorator on all function signatures.
    def GetOrientation(self, orient: MutableSequence[float]) -> None: ...
    @overload
    def GetOrientation(self) -> tuple[float, float, float]: ...
    @overload
    @staticmethod
    def GetOrientation(orient: MutableSequence[float], matrix: vtkmodules.vtkCommonMath.vtkMatrix4x4) -> None: ...

Which, I guess, should correspond to the following python code

class vtkTransform(vtkLinearTransform):
    def GetOrientation(self, orient = None):
        pass

    @staticmethod
    def GetOrientation(orient, matrix) -> None:
        pass

But this isn't valid python code, I have made this piece of code to test the behavior of the python interpreter (the comment is the error generated by my python interpreter):

class Foo:
    def bar(self) -> int: 
        return 1

    @staticmethod
    def bar(i: str) -> None:
        pass


print(type(Foo.bar("abc")))
print(type(Foo().bar()))  # TypeError: Foo.bar() missing 1 required positional argument: 'i'

So I don't understand how they manage to do this since both methods works as expected in the case of vtk (comment correspond to the output of the script):

import vtk.vtkCommonTransforms
import vtk.vtkCommonMath

transform = vtk.vtkCommonTransforms.vtkTransform()
print(transform.GetOrientation())  # (0.0, -0.0, 0.0)
print(vtk.vtkCommonTransforms.vtkTransform.GetOrientation([0, 0, 0], vtk.vtkCommonMath.vtkMatrix4x4()))  # None

Can the behavior of python be different between .py scripts and generated c++ libraries ? Or did I wrongly assume the python code behind this ? and if so what could I do to fix the mypy error ?

@github-actions

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Oct 2, 2024

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra
Copy link
Member

I started looking at this with an eye towards getting CI to pass, since this is one of the oldest open PRs. Unfortunately, there is a really huge amount of stubtest errors, more than I can deal with. This probably needs someone with deeper familiarity with the library.

@JelleZijlstra
Copy link
Member

Thanks for contributing! I'm closing this PR for now, because it still fails some tests
after more than a year of inactivity. If you are still interested, please feel free to open
a new PR (or ping us to reopen this one).

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

Successfully merging this pull request may close these issues.

Can we add vtk stub file ?
3 participants