Skip to content

CI: run pyright with mypy #43747

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 4 commits into from
Sep 26, 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
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ jobs:
environment-file: ${{ env.ENV_FILE }}
use-only-tar-bz2: true

- name: Install node.js (for pyright)
uses: actions/setup-node@v2
with:
node-version: "16"

- name: Install pyright
# note: keep version in sync with .pre-commit-config.yaml
run: npm install -g [email protected]

- name: Build Pandas
uses: ./.github/actions/build_pandas

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ 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
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ repos:
language: node
pass_filenames: false
types: [python]
additional_dependencies: ['[email protected]']
# note: keep version in sync with .github/workflows/ci.yml
additional_dependencies: ['[email protected]']
- repo: local
hooks:
- id: flake8-rst
Expand Down
7 changes: 7 additions & 0 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ if [[ -z "$CHECK" || "$CHECK" == "typing" ]]; then
MSG='Performing static analysis using mypy' ; echo $MSG
mypy pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

# run pyright, if it is installed
if command -v pyright &> /dev/null ; then
MSG='Performing static analysis using pyright' ; echo $MSG
pyright
RET=$(($RET + $?)) ; echo $MSG "DONE"
fi
fi

exit $RET
7 changes: 6 additions & 1 deletion doc/source/development/contributing_codebase.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,17 @@ This module will ultimately house types for repeatedly used concepts like "path-
Validating type hints
~~~~~~~~~~~~~~~~~~~~~

pandas uses `mypy <http://mypy-lang.org>`_ to statically analyze the code base and type hints. After making any change you can ensure your type hints are correct by running
pandas uses `mypy <http://mypy-lang.org>`_ and `pyright <https://github.com/microsoft/pyright>`_ to statically analyze the code base and type hints. After making any change you can ensure your type hints are correct by running

.. code-block:: shell

mypy pandas

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

.. _contributing.ci:

Testing with continuous integration
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ reportOptionalIterable = false
reportOptionalMemberAccess = false
reportOptionalOperand = false
reportOptionalSubscript = false
reportOverlappingOverload = false
reportPrivateImportUsage = false
reportPrivateUsage = false
reportPropertyTypeMismatch = false
Expand Down