Add pyright for static type checking#17744
Conversation
|
Can you clean up the other trailing spaces in requirements.txt by the way? |
|
@hwf1324 - this is probably better done as its own PR, it's relatively trivial |
|
Note: there's no inbuilt way of automatically generating |
SaschaCowley
left a comment
There was a problem hiding this comment.
Mostly looks good, however I'm a little concerned about the inclusion of a bunch of internal classes in various modules' __all__.
Co-authored-by: Sean Budd <sean@nvaccess.org>
See test results for failed build of commit f2649a8e74 |
See test results for failed build of commit 445074b0b8 |
See test results for failed build of commit defc94e191 |
Closes #17749 Summary of the issue: #17744 introduced pyright using it's default server nodeenv. The pyright python package recommends installing pyright[nodejs] for a faster and more reliable server. Hwever we couldn't use it while NVDA was 32bit. This is because the node wheel binaries required a 64bit environment. Now that NVDA has migrated to 64bit, we should update the pyright package version to using nodejs.
Link to issue number:
Related to #17301
Summary of the issue:
NVDA has no type checking for python.
Python is a dynamically typed language meaning typing issues can occur at runtime.
Static analysers like
mypyorpyrightcan be used to avoid typing errors.Description of user facing changes
None
Description of development approach
pyrightwas chosen overmypyfor performance reasons.Additionally, pyright has better pre-commit integration, and is built-in to VS Code, which is used by most NVDA developers.
We are far from compliant with static type checking, so most rules are currently disabled.
The intention is to fix compliance and turn on rules over time.
Various trivial typing fixes have occurred, particularly:
gettextbuiltins and_buildVersiongenerated build vars__all__to mark export for private classesmatchcasesTesting strategy:
Known issues with pull request:
We are far from compliant with static type checking, so most rules are currently disabled.
The intention is to fix compliance and turn on rules over time.
Code Review Checklist:
@coderabbitai summary