typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

add vtk stub files

Open Gryfenfer97 opened this issue 2 years ago • 13 comments

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

Gryfenfer97 avatar Jul 12 '23 18:07 Gryfenfer97

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

github-actions[bot] avatar Jul 12 '23 18:07 github-actions[bot]

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

github-actions[bot] avatar Jul 12 '23 19:07 github-actions[bot]

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

github-actions[bot] avatar Jul 17 '23 19:07 github-actions[bot]

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

github-actions[bot] avatar Jul 17 '23 21:07 github-actions[bot]

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

github-actions[bot] avatar Jul 17 '23 21:07 github-actions[bot]

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

github-actions[bot] avatar Jul 17 '23 22:07 github-actions[bot]

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

github-actions[bot] avatar Jul 17 '23 22:07 github-actions[bot]

pre-commit.ci autofix

AlexWaygood avatar Jul 20 '23 12:07 AlexWaygood

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

github-actions[bot] avatar Jul 20 '23 13:07 github-actions[bot]

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 ?

Gryfenfer97 avatar Jul 22 '23 15:07 Gryfenfer97

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

github-actions[bot] avatar Jul 22 '23 18:07 github-actions[bot]

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

github-actions[bot] avatar Oct 02 '24 00:10 github-actions[bot]

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 avatar Oct 02 '24 00:10 JelleZijlstra

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).

JelleZijlstra avatar Dec 28 '24 04:12 JelleZijlstra