-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
CI: run pyright #43672
CI: run pyright #43672
Conversation
Some points to consider:
While this PR enables very few rules for all files (except for the tests), it would make sense in subsequent PRs to prioritize fixing |
You can ignore type errors on a specific line using a |
Thank you for the correction! I remembered one issue on pyright that mentioned that there wasn't this possibility. |
I noticed that you added "pandas/tests" to the "ignore" section of the configuration. This tells pyright to analyze these files but suppress reporting any diagnostics in them. I recommend moving it to "exclude" instead, which tells pyright to avoid analyzing them unless they are explicitly imported by other modules that are included in the analysis set. Making this change drops the total analysis time from 67 seconds to 19 seconds on my machine.
I'll also point out that as more type annotations are added to the code base, the overall analysis time will decrease. Currently, pyright needs to perform a lot of expensive computations to infer function return types based on the function implementation and call-site argument types. I would anticipate that the total analysis time would drop by 50% or more as you add more type annotations. |
That's amazing, thank you for noticing that! 19s should be more than fast enough to run pyright with all pre-commit hooks. |
mypy used to be in the pre-commit but was removed in #35066 (because of running in a different environment and bugs(?) in mypy pre-commit/pre-commit#1580 (comment)). We probably need to add all the type-stub packages as dependencies to the pyright hook (pyright comes with its copy of typeshed, so we might not need to install various type-stub packages(?)). At a minimum, we probably need to add edit: It seems that pre-commit doesn't isolate pyright from the current python environment because it is a node.js application(?)! That's very convenient, especially because it seems that pre-commit doesn't support installing node dependencies and python dependencies for the same check. |
thanks @twoertwein very nice. |
pls open issues as appropriate (or a single with check boxes) to enable features on pyright checking. |
Run pyright in strict mode with a very long list of rules that need to be ignored. The idea is to enable more rules over time.
pre-commit seamlessly installs pyright (depends on node.js) but running pyright as part of the pre-commit slows the pre-commit down by ~85s.