Skip to content

CI/TYP: run pyright at manual stage in pre-commit #43799

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

Merged
merged 5 commits into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
concurrency:
group: ${{ github.ref }}-pre-commit
cancel-in-progress: ${{github.event_name == 'pull_request'}}
env:
SKIP: pyright
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ repos:
language: node
pass_filenames: false
types: [python]
stages: [manual]
# note: keep version in sync with .github/workflows/ci.yml
additional_dependencies: ['[email protected]']
- repo: local
Expand Down
4 changes: 3 additions & 1 deletion doc/source/development/contributing_codebase.rst
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,12 @@ pandas uses `mypy <http://mypy-lang.org>`_ and `pyright <https://github.com/micr
mypy pandas

# let pre-commit setup and run pyright
pre-commit run --all-files pyright
pre-commit run --hook-stage manual --all-files pyright
# or if pyright is installed (requires node.js)
pyright

A recent version of ``numpy`` (>=1.21.0) is required for type validation.

Comment on lines +409 to +410
Copy link
Member

Choose a reason for hiding this comment

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

Does the [email protected] dependency include this? Because if not, as it's running as a local hook, then it won't have access to numpy, even if you have it installed in your virtual environment

Perhaps it should be repo: system?

(granted, I haven't tried running this, am just pointing out a common misconception about repo: local)

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 seems that pre-commit does not isolate pyright from the current python environment: if numpy is installed in the currently active environment, pyright seems to have access to it.

I tried adding it as a dependency (in the pre-commit), but it seems that pre-commit does not support mixing languages (pyright: node, numpy:python) - it tries to use node to install numpy.

Copy link
Member

Choose a reason for hiding this comment

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

It seems that pre-commit does not isolate pyright from the current python environment: if numpy is installed in the currently active environment, pyright seems to have access to it.

I find this surprising, but if that's the case, then great 👍

.. _contributing.ci:

Testing with continuous integration
Expand Down