update docs, cleaning
This commit is contained in:
28
docs/mypy.md
Normal file
28
docs/mypy.md
Normal file
@ -0,0 +1,28 @@
|
||||
To provide better errors check you should use mypy with pydantic [plugin][plugin]
|
||||
|
||||
Note that legacy model declaration type will raise static type analyzers errors.
|
||||
|
||||
So you **cannot use the old notation** like this:
|
||||
|
||||
```Python hl_lines="15-17"
|
||||
--8<-- "../docs_src/models/docs011.py"
|
||||
```
|
||||
|
||||
Instead switch to notation introduced in version 0.4.0.
|
||||
|
||||
```Python hl_lines="15-17"
|
||||
--8<-- "../docs_src/models/docs012.py"
|
||||
```
|
||||
|
||||
Note that above example is not using the type hints, so further operations with mypy might fail, depending on the context.
|
||||
|
||||
Preferred notation should look liked this:
|
||||
|
||||
```Python hl_lines="15-17"
|
||||
--8<-- "../docs_src/models/docs001.py"
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
[plugin]: https://pydantic-docs.helpmanual.io/mypy_plugin/
|
||||
Reference in New Issue
Block a user