Files
pydantic/tests/mypy/modules/fail3.py
T
dmontagu 0c18619769 Mypy plugin (#722)
* Add mypy plugin

* Make all arguments optional for BaseSettings

* Get test coverage up

* Add changes

* Add type-checking for BaseModel.construct, and checking for from_orm

* Fix formatting and linting

* Fix the build

* Heavy refactor of plugin and mypy tests

* Make linting pass

* Handle dynamic aliases

* Better organize plugin code

* Add docs

* Add support for error codes

* Fix minor docs typo

* Rename config settings, add docstrings, and incorporate other feedback

* Incorporate feedback

* Update docs, remove dataclasses for cython

* fix mypy example
2019-10-31 13:19:01 +01:00

23 lines
454 B
Python

"""
Test mypy failure with invalid types.
"""
from typing import Generic, List, TypeVar
from pydantic import BaseModel
from pydantic.generics import GenericModel
T = TypeVar('T')
class Model(BaseModel):
list_of_ints: List[int]
class WrapperModel(GenericModel, Generic[T]):
payload: T
model_instance = Model(list_of_ints=[1])
wrapper_instance = WrapperModel[Model](payload=model_instance)
wrapper_instance.payload.list_of_ints.append('1')