diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93c17997a95f7..c8f5f0385732f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 pyright@1.1.171 + - name: Build Pandas uses: ./.github/actions/build_pandas diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 0609755678d78..9afb0e34f1075 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 22c805733aff2..f15a340e75181 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -89,7 +89,8 @@ repos: language: node pass_filenames: false types: [python] - additional_dependencies: ['pyright@1.1.170'] + # note: keep version in sync with .github/workflows/ci.yml + additional_dependencies: ['pyright@1.1.171'] - repo: local hooks: - id: flake8-rst diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 7e4b5775af317..76aae2e908de4 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -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 diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index 6fe0fa82236c3..eeba46a46dfd9 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -395,12 +395,17 @@ This module will ultimately house types for repeatedly used concepts like "path- Validating type hints ~~~~~~~~~~~~~~~~~~~~~ -pandas uses `mypy `_ 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 `_ and `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 diff --git a/pyproject.toml b/pyproject.toml index 65f49dafb5136..6b0191326518f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -139,7 +139,6 @@ reportOptionalIterable = false reportOptionalMemberAccess = false reportOptionalOperand = false reportOptionalSubscript = false -reportOverlappingOverload = false reportPrivateImportUsage = false reportPrivateUsage = false reportPropertyTypeMismatch = false