Skip to content

Commit e2167b1

Browse files
authored
CI: run pyright with mypy (#43747)
1 parent dd7158b commit e2167b1

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

.github/workflows/ci.yml

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ jobs:
4545
environment-file: ${{ env.ENV_FILE }}
4646
use-only-tar-bz2: true
4747

48+
- name: Install node.js (for pyright)
49+
uses: actions/setup-node@v2
50+
with:
51+
node-version: "16"
52+
53+
- name: Install pyright
54+
# note: keep version in sync with .pre-commit-config.yaml
55+
run: npm install -g [email protected]
56+
4857
- name: Build Pandas
4958
uses: ./.github/actions/build_pandas
5059

.github/workflows/pre-commit.yml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
concurrency:
1414
group: ${{ github.ref }}-pre-commit
1515
cancel-in-progress: ${{github.event_name == 'pull_request'}}
16+
env:
17+
SKIP: pyright
1618
steps:
1719
- uses: actions/checkout@v2
1820
- uses: actions/setup-python@v2

.pre-commit-config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ repos:
8989
language: node
9090
pass_filenames: false
9191
types: [python]
92-
additional_dependencies: ['[email protected]']
92+
# note: keep version in sync with .github/workflows/ci.yml
93+
additional_dependencies: ['[email protected]']
9394
- repo: local
9495
hooks:
9596
- id: flake8-rst

ci/code_checks.sh

+7
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ if [[ -z "$CHECK" || "$CHECK" == "typing" ]]; then
104104
MSG='Performing static analysis using mypy' ; echo $MSG
105105
mypy pandas
106106
RET=$(($RET + $?)) ; echo $MSG "DONE"
107+
108+
# run pyright, if it is installed
109+
if command -v pyright &> /dev/null ; then
110+
MSG='Performing static analysis using pyright' ; echo $MSG
111+
pyright
112+
RET=$(($RET + $?)) ; echo $MSG "DONE"
113+
fi
107114
fi
108115

109116
exit $RET

doc/source/development/contributing_codebase.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,17 @@ This module will ultimately house types for repeatedly used concepts like "path-
395395
Validating type hints
396396
~~~~~~~~~~~~~~~~~~~~~
397397

398-
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
398+
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
399399

400400
.. code-block:: shell
401401
402402
mypy pandas
403403
404+
# let pre-commit setup and run pyright
405+
pre-commit run --all-files pyright
406+
# or if pyright is installed (requires node.js)
407+
pyright
408+
404409
.. _contributing.ci:
405410

406411
Testing with continuous integration

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ reportOptionalIterable = false
138138
reportOptionalMemberAccess = false
139139
reportOptionalOperand = false
140140
reportOptionalSubscript = false
141-
reportOverlappingOverload = false
142141
reportPrivateImportUsage = false
143142
reportPrivateUsage = false
144143
reportPropertyTypeMismatch = false

0 commit comments

Comments
 (0)