forked from pydantic/pydantic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change tests to align with removal of PEP 746 support. Move Pyright tests out of the mypy CI job.
- Loading branch information
Showing
7 changed files
with
69 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,26 +267,39 @@ jobs: | |
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-mypy${{ matrix.mypy-version }} | ||
CONTEXT: linux-py${{ matrix.python-version }}-mypy${{ matrix.mypy-version }} | ||
|
||
- name: store coverage files | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-${{ matrix.python-version }}-mypy${{ matrix.mypy-version }} | ||
path: coverage | ||
include-hidden-files: true | ||
|
||
test-pyright: | ||
name: Pyright tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: install node for pyright | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
node-version: '20' | ||
|
||
- uses: pdm-project/setup-pdm@v4 | ||
with: | ||
python-version: '3.12' | ||
cache: true | ||
|
||
- name: install deps | ||
run: | | ||
pdm venv create --force $PYTHON | ||
pdm install | ||
- name: install pyright | ||
run: npm install -g [email protected].369 # try to keep this in sync with .pre-commit-config.yaml | ||
run: npm install -g [email protected].384 # keep this in sync with .pre-commit-config.yaml | ||
|
||
- name: run pyright tests | ||
run: make test-pyright | ||
env: | ||
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-pyright | ||
CONTEXT: linux-py${{ matrix.python-version }}-pyright | ||
|
||
- name: store coverage files | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-${{ matrix.python-version }}-mypy${{ matrix.mypy-version }} | ||
path: coverage | ||
include-hidden-files: true | ||
|
||
coverage-combine: | ||
needs: [test, test-mypy] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ repos: | |
types: [python] | ||
language: node | ||
pass_filenames: false | ||
additional_dependencies: ["[email protected].369"] # try to keep this in sync with .github/workflows/ci.yml | ||
additional_dependencies: ["[email protected].384"] # keep this in sync with .github/workflows/ci.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Pyright test suite | ||
|
||
Use [`assert_type`](https://docs.python.org/3/library/typing.html#typing.assert_type) to make assertions: | ||
|
||
```python | ||
from typing_extensions import assert_type | ||
|
||
from pydantic import TypeAdapter | ||
|
||
ta1 = TypeAdapter(int) | ||
assert_type(ta1, TypeAdapter[int]) | ||
``` | ||
|
||
To assert on invalid cases, add a `pyright: ignore` comment: | ||
|
||
```python | ||
from pydantic import BaseModel | ||
|
||
|
||
class Model(BaseModel): | ||
a: int | ||
|
||
|
||
Model() # pyright: ignore[reportCallIssue] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters