Skip to content

Commit 9d5348e

Browse files
Setup optional CI jobs using pyright strict mode (#954)
* Setup optional CI jobs using pyright strict mode * Revert temporary test CI settings * Fix pyright strict config
1 parent 7e5b771 commit 9d5348e

File tree

6 files changed

+39
-0
lines changed

6 files changed

+39
-0
lines changed

Diff for: .github/workflows/optional.yml

+16
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,19 @@ jobs:
3838

3939
- name: Run mypy tests with mypy nightly
4040
run: poetry run poe mypy --mypy_nightly
41+
42+
pyright_strict:
43+
runs-on: ubuntu-latest
44+
timeout-minutes: 10
45+
46+
steps:
47+
- uses: actions/checkout@v3
48+
49+
- name: Install project dependencies
50+
uses: ./.github/setup
51+
with:
52+
os: ubuntu-latest
53+
python-version: '3.11'
54+
55+
- name: Run pyright tests with full strict mode
56+
run: poetry run poe pyright_strict

Diff for: docs/tests.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ The following tests are **optional**. Some of them are run by the CI but it is o
1818

1919
- Run pytest against pandas nightly: `poe pytest --nightly`
2020
- Use mypy nightly to validate the annotations: `poe mypy --mypy_nightly`
21+
- Use pyright in full strict mode: `poe pyright_strict`
2122
- 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 for: pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ script = "scripts.test:test(dist=True, type_checker='mypy')"
109109
help = "Run pyright on 'tests' (using the local stubs) and on the local stubs"
110110
script = "scripts.test.run:pyright_src"
111111

112+
[tool.poe.tasks.pyright_strict]
113+
help = "Run pyright on 'tests' (using the local stubs) and on the local stubs in full strict mode"
114+
script = "scripts.test.run:pyright_src_strict"
115+
112116
[tool.poe.tasks.pyright_dist]
113117
help = "Run pyright on 'tests' using the installed stubs"
114118
script = "scripts.test:test(dist=True, type_checker='pyright')"

Diff for: pyrightconfig-strict.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"typeCheckingMode": "strict",
3+
"stubPath": ".",
4+
"include": ["tests", "pandas-stubs"],
5+
"enableTypeIgnoreComments": false,
6+
"reportUnnecessaryTypeIgnoreComment": true,
7+
"reportMissingModuleSource": true,
8+
"useLibraryCodeForTypes": false
9+
}

Diff for: scripts/test/_step.py

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
name="Run pyright on 'tests' (using the local stubs) and on the local stubs",
1010
run=run.pyright_src,
1111
)
12+
pyright_src_strict = Step(
13+
name="Run pyright on 'tests' (using the local stubs) and on the local stubs in full strict mode",
14+
run=run.pyright_src_strict,
15+
)
1216
pytest = Step(name="Run pytest", run=run.pytest)
1317
style = Step(name="Run pre-commit", run=run.style)
1418
build_dist = Step(name="Build pandas-stubs", run=run.build_dist)

Diff for: scripts/test/run.py

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ def pyright_src():
1515
subprocess.run(cmd, check=True)
1616

1717

18+
def pyright_src_strict():
19+
cmd = ["pyright", "--project", "pyrightconfig-strict.json"]
20+
subprocess.run(cmd, check=True)
21+
22+
1823
def pytest():
1924
cmd = ["pytest", "--cache-clear"]
2025
subprocess.run(cmd, check=True)

0 commit comments

Comments
 (0)