File: README.md

package info (click to toggle)
pydantic 2.12.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,640 kB
  • sloc: python: 75,984; javascript: 181; makefile: 115; sh: 38
file content (33 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Type checking test suite

This test suite is meant to assert the correct behavior of the type hints we use in the Pydantic code.
In CI, we run both Mypy and Pyright on these files, using the [`pyproject.toml`](./pyproject.toml)
configuration file.

Note that these tests do not relate to the Mypy plugin, which is tested under the [`mypy/`](../mypy/) folder.

## Assertions

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 `type: ignore` (for Mypy, must go first) and/or a  `pyright: ignore` (for Pyright) comment:

```python
from pydantic import BaseModel


class Model(BaseModel):
    a: int


Model()  # type: ignore[call-arg]  # pyright: ignore[reportCallIssue]
```