Skip to content

add vtk stub files - #10446

Closed
Gryfenfer97 wants to merge 28 commits into
python:mainfrom
Gryfenfer97:main
Closed

add vtk stub files#10446
Gryfenfer97 wants to merge 28 commits into
python:mainfrom
Gryfenfer97:main

Conversation

@Gryfenfer97

@Gryfenfer97Gryfenfer97 commented Jul 12, 2023

Copy link
Copy Markdown

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
Copy Markdown
Member

pre-commit.ci autofix

@github-actions

This comment has been minimized.

@Gryfenfer97

Gryfenfer97 commented Jul 22, 2023

Copy link
Copy Markdown
Author

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

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

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

classvtkTransform(vtkLinearTransform):
defGetOrientation(self, orient=None):
pass@staticmethoddefGetOrientation(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):

classFoo:
defbar(self) ->int: return1@staticmethoddefbar(i: str) ->None:
passprint(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):

importvtk.vtkCommonTransformsimportvtk.vtkCommonMathtransform=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.

@github-actions

Copy link
Copy Markdown
Contributor

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

@JelleZijlstra

Copy link
Copy Markdown
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
Copy Markdown
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 freeto 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

@Gryfenfer97@AlexWaygood@JelleZijlstra