mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
c81ec9aeec
* add support for annotation only fields, fix #34 * adding tests with mypy * adding docs for mypy usage * adding mypy failure test * adding alias tests * tweak mypy tests
22 lines
411 B
Python
22 lines
411 B
Python
"""
|
|
Test mypy failure with invalid types.
|
|
"""
|
|
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, NoneStr
|
|
|
|
|
|
class Model(BaseModel):
|
|
age: int
|
|
first_name = 'John'
|
|
last_name: NoneStr = None
|
|
signup_ts: Optional[datetime] = None
|
|
list_of_ints: List[int]
|
|
|
|
|
|
m = Model(age=42, list_of_ints=[1, '2', b'3'])
|
|
|
|
assert m.age == 42, m.age
|
|
m.age = 'not integer'
|