diff --git a/.github/workflows/optional.yml b/.github/workflows/optional.yml index fac7a969..4cbeccc0 100644 --- a/.github/workflows/optional.yml +++ b/.github/workflows/optional.yml @@ -38,3 +38,19 @@ jobs: - name: Run mypy tests with mypy nightly run: poetry run poe mypy --mypy_nightly + + pyright_strict: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: '3.11' + + - name: Run pyright tests with full strict mode + run: poetry run poe pyright_strict diff --git a/docs/tests.md b/docs/tests.md index 1314a459..fdf2dd5e 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -18,4 +18,5 @@ The following tests are **optional**. Some of them are run by the CI but it is o - Run pytest against pandas nightly: `poe pytest --nightly` - Use mypy nightly to validate the annotations: `poe mypy --mypy_nightly` +- Use pyright in full strict mode: `poe pyright_strict` - Run stubtest to compare the installed pandas-stubs against pandas (this will fail): `poe stubtest`. If you have created an allowlist to ignore certain errors: `poe stubtest path_to_the_allow_list` diff --git a/pyproject.toml b/pyproject.toml index b6889888..71c22ca5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,6 +109,10 @@ script = "scripts.test:test(dist=True, type_checker='mypy')" help = "Run pyright on 'tests' (using the local stubs) and on the local stubs" script = "scripts.test.run:pyright_src" +[tool.poe.tasks.pyright_strict] +help = "Run pyright on 'tests' (using the local stubs) and on the local stubs in full strict mode" +script = "scripts.test.run:pyright_src_strict" + [tool.poe.tasks.pyright_dist] help = "Run pyright on 'tests' using the installed stubs" script = "scripts.test:test(dist=True, type_checker='pyright')" diff --git a/pyrightconfig-strict.json b/pyrightconfig-strict.json new file mode 100644 index 00000000..4d5e9b0e --- /dev/null +++ b/pyrightconfig-strict.json @@ -0,0 +1,9 @@ +{ + "typeCheckingMode": "strict", + "stubPath": ".", + "include": ["tests", "pandas-stubs"], + "enableTypeIgnoreComments": false, + "reportUnnecessaryTypeIgnoreComment": true, + "reportMissingModuleSource": true, + "useLibraryCodeForTypes": false +} diff --git a/scripts/test/_step.py b/scripts/test/_step.py index 882a9a46..5bd07717 100644 --- a/scripts/test/_step.py +++ b/scripts/test/_step.py @@ -9,6 +9,10 @@ name="Run pyright on 'tests' (using the local stubs) and on the local stubs", run=run.pyright_src, ) +pyright_src_strict = Step( + name="Run pyright on 'tests' (using the local stubs) and on the local stubs in full strict mode", + run=run.pyright_src_strict, +) pytest = Step(name="Run pytest", run=run.pytest) style = Step(name="Run pre-commit", run=run.style) build_dist = Step(name="Build pandas-stubs", run=run.build_dist) diff --git a/scripts/test/run.py b/scripts/test/run.py index c30395da..24ca194c 100644 --- a/scripts/test/run.py +++ b/scripts/test/run.py @@ -15,6 +15,11 @@ def pyright_src(): subprocess.run(cmd, check=True) +def pyright_src_strict(): + cmd = ["pyright", "--project", "pyrightconfig-strict.json"] + subprocess.run(cmd, check=True) + + def pytest(): cmd = ["pytest", "--cache-clear"] subprocess.run(cmd, check=True)