mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
b84df079a7
* Added generic functionality * Skip tests in python 3.6 * double quote -> single quote * Simplified, with more comprehensive tests * double quote -> single quote * Remove unintentional file * Add caching * don't cythonize generics.py * Make work with mypy * Remove __parameters__ * double quote -> single quote i'll remember one day * More cleanup and validation * Removed unwanted file * A little more cleanup, and finish the PR * Add proper inheritance * Added note about inheritance to docs * Added error for double-parameterizing * Should build for python3.7 * Works with both 3.6 and 3.7 * Fixed bug with caching for single argument * handle __name__ for generic models * double quote -> single quote * Updated error messages
23 lines
454 B
Python
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')
|