Skip to content
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

Setup optional CI jobs using pyright strict mode #954

Merged
merged 3 commits into from
Jun 29, 2024
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
16 changes: 16 additions & 0 deletions .github/workflows/optional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand Down
9 changes: 9 additions & 0 deletions pyrightconfig-strict.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"typeCheckingMode": "strict",
"stubPath": ".",
"include": ["tests", "pandas-stubs"],
"enableTypeIgnoreComments": false,
"reportUnnecessaryTypeIgnoreComment": true,
"reportMissingModuleSource": true,
"useLibraryCodeForTypes": false
}
4 changes: 4 additions & 0 deletions scripts/test/_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions scripts/test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading