-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Open3D type checking bug/issue #3052
Comments
Hi @BojanMatovski which static analyser does PyCharm use? Can you reproduce this with |
I am not sure which static analyzer PyCharm uses. I tried looking out and finding it, but couldn't really do it. I tried using flake8, but had some issues with it. When I try using it, it prints: I also tried catching it with pylint and it doesn't catch it, but I might need to configure it or something, because I also added these two lines as a check:
and pylint still doesn't complain about the variable "being" an integer and having a string assigned. Finally, I tried mypy, but for some reason it says that open3d has no type hinting: |
@BojanMatovski Open3D doesn't use type hints, since the code is a compiled C++ module. I don't believe type hints are useful here since C++ already has strong type safety. |
Hello @ssheorey! I am trying to apply type checking to my project in order to have a robust CI. I type my functions which usually have Open3D objects. Using mypy I get the following error: In order to improve the compatibility with these kind of tools Open3D should be PEP 561, the following links give a starting point: |
Hi @ManuCorrea here are two options for generating stubs: https://github.com/sizmailov/pybind11-stubgen with a discussion here: If any of these tools work for you, please let us know. Also happy to accept a PR to package these stubs in the Open3D wheel based on your results. |
@ssheorey OpenCV also added type hints with .pyi files opencv/opencv#14590 The stub generation with https://github.com/sizmailov/pybind11-stubgen works, although in vscode you have to copy generated file in root of your workspace or some pylance folder #5802 Is the reason why Open3D doesn't have type hints that the functions are generated with pybind11? |
Describe the bug
Since the Open3D update I get this kind of a warning (see screenshots) in PyCharm when I try to add a point cloud as a geometry in a visualizer.
I've also seen issues like "Expected type 'PointCloud.py', got 'PointCloud' instead", where the only difference is that the expected type is the type of the object I am already giving but followed by a ".py"
To Reproduce
some_pointcloud: open3d.geometry.PointCloud = open3d.geometry.PointCloud() (added another screenshot for this example)
Expected behavior
The method should accept the input object and PyCharm shouldn't complain about it.
Screenshots
Environment (please complete the following information):
Additional context
I opened this discussion on Discord, but there were no responses, so I assume that it is a bug. Also, in the geometry issue, I've tried casting it to a geometry object type, but there were some issues with the geometry object constructor. I searched the documentation to try and see if I'm doing something wrong, but I couldn't find anything specific to this.
By the way, nothing crashes, everything works as intended, it's just these silly warnings that the static code analyzer complains about.
The text was updated successfully, but these errors were encountered: