Skip to content

CI: use github action for pyright #47067

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

Closed
wants to merge 1 commit into from
Closed

CI: use github action for pyright #47067

wants to merge 1 commit into from

Conversation

twoertwein
Copy link
Member

pyright has a github action integration https://github.com/microsoft/pyright/blob/main/docs/ci-integration.md

I added the --skipunannotated option to prevent pyright from trying to infer missing return annotation (mypy doesn't do that either). That does not make a difference at the moment but it cuts reportGeneralTypeIssues errors in half (if it was enabled).

@@ -100,6 +91,12 @@ jobs:
run: ci/code_checks.sh typing
if: ${{ steps.build.outcome == 'success' }}

- uses: jakebailey/pyright-action@v1
with:
# note: keep version in sync with .pre-commit-config.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, why do we need this in pre-commit-config and here i.e. can this just be run in pre-commit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyright is only run by pre-commit during the manual stage. The idea is to give developers an easy way to run pyright without having to set it up (it depends on node). The CI doesn't run the manual stage.

I think the reason to keep mypy and pyright separate was that otherwise all the typing packages would need to be installed for the pre-commit hook. Maybe there was a better reason :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason for not running pyright&mypy (by default) in pre-commit is that outdated/missing packages (e.g., numpy) would cause pyright&mypy to fail. We often have issues between numba requiring an older version of numpy but for typing we want the latest numpy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr-Irv I think you set the pyright github action for https://github.com/pandas-dev/pandas-stubs up. How did you manage that pyright finds the virtual env? Running pyright directly (instead of using the github action) seemed to have no issue finding the virtual env.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense for typing checks in pre-commit to not necessarily run on every commit and therefore in manual mode. Is it possible to have the pre-commit job run these pyright checks then in the CI? My motivation is to see if there can be one clear way to run these checks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to only use pre-commit and make mypy&pyright optional!

I think one issue with mypy+pre-commit is that pre-commit isolates the python environment (can probably be avoided by language: system)? Pyright doesn't seem to be affected by that since pre-commit doesn't seem to isolate non-python programs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr-Irv I think you set the pyright github action for https://github.com/pandas-dev/pandas-stubs up. How did you manage that pyright finds the virtual env? Running pyright directly (instead of using the github action) seemed to have no issue finding the virtual env.

I just copied the action from what Microsoft had set up in https://github.com/microsoft/python-type-stubs/blob/main/.github/workflows/test.yml . I think since it is a sequence of steps, the virtual env is automatically set up from the previous steps.

@twoertwein twoertwein marked this pull request as draft May 19, 2022 23:42
@jreback jreback added CI Continuous Integration Typing type annotations, mypy/pyright type checking labels May 20, 2022
@twoertwein
Copy link
Member Author

Closing this. Will try to add mypy to the manual pre-commit stage and then run mypy&pyright through pre-commit.

@twoertwein twoertwein closed this May 20, 2022
@mroeschke
Copy link
Member

Thanks @twoertwein. No objection adding it via this PR if the pre-commit version doesn't work out

@Dr-Irv
Copy link
Contributor

Dr-Irv commented May 24, 2022

Closing this. Will try to add mypy to the manual pre-commit stage and then run mypy&pyright through pre-commit.

This could slow down development. When I run mypy on my laptop on the pandas source, it can sometimes take 3 minutes to complete. So adding that amount of time as part of the pre-commit might be burdensome.

@mroeschke
Copy link
Member

This was implemented as a manual step in pre-commit, so typing checks won't be run automatically on every local commit. It must be run manually but a manual pre-commit command is now the runner: https://github.com/pandas-dev/pandas/pull/47075/files#diff-a5a8fc529fd73f3c8aa836fde7c12d7c331b4ca84e48252fd881d2c803c24adfR263

@twoertwein twoertwein deleted the pyright_githubaction branch May 26, 2022 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants