-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
gui(nviz): Type hinting to the nviz library wrapper and various related improvements #4899
Open
echoix
wants to merge
22
commits into
OSGeo:main
Choose a base branch
from
echoix:pylint-3-remaining-4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+674
−234
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…orts There is no reason (dependency of imports) apparent here that would prevent it from working. Works locally in a Ubuntu 22.04 WSL on Windows
grass.script was already below gui imports in 2023
This allows static analysis of self.render dict, that contains 4 keys and all boolean values
Includes using different aliases for different type of ids, to be able to check for usage mismatches
gui.wxpython.nviz.wxnviz: Add some type hints for Texture and ImageTexture
…ectors, considered tuples
When results of GetPointOnSurface() is None, ensure that we return None, and the other branch is assured to contain floats
… None or other variables are missing
echoix
force-pushed
the
pylint-3-remaining-4
branch
from
December 31, 2024 16:42
304ed41
to
8b576c7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the PR that includes the remaining typing changes I made for almost* fully typing the wrapped native library around nviz.
Mostly, it consisted of matching the c library functions called with their implementation, either directly in source code or through the notes/signatures in the doxygen docs. The most useful improvement here, is the knowledge injected by not only specifying ids as ints, but what kind of id is expected (a point id? a vector set id? an isosurface id? etc,), in order to have type checking tools help out find cases where a wrong kind of Id is used. This mismatch analysis is not made yet, however some function docs were adjusted as they were "wrong" with respect to the actual library called. To be stricter, instead of simple int aliases, these new Id types could be defined as "NewType" (https://docs.python.org/3/library/typing.html#typing.NewType), but I don't think it is appropriate for now, there's a tiny impact from what I've read.
Non-typed functions or arguments are most probably because it wasn't possible to be sure at that time.
The "various related improvements" part comes from related typing annotations that were able to be set when analyzing the function calls when investigating the wxnviz functions. It also includes a commit that fixes #4878, that was too small to be worth a PR, considering it is almost the same as the other typing fixes of the same file.
I rebased and worked around to exclude the commits from #4880 that I thought were easier and faster to merge, but didn't get through yet after addressing the review.
The next step, that this PR enables us to do, is to see what logic errors or any type errors are left in gui/wxpython/nviz/mapwindow.py, regarding to the usages of functions in wxnviz. There are already multiple ones that I identified regarding to handling of None in some attributes, that are possible, but the ones fixed were the easiest ones that didn't involve much changes.