mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
0500610ec5
* Add .venv/ to .gitignore * Allow typecheckers to infer Json inner type * Fix and improve mypy tests * Add type tests * Add Json[Any] case to schema test * Update example in docs * Add changes file * Use <3.9 compatible annotations for tests
24 lines
505 B
Python
24 lines
505 B
Python
"""
|
|
Test mypy failure with missing attribute
|
|
"""
|
|
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, NoneStr
|
|
from pydantic.types import Json
|
|
|
|
|
|
class Model(BaseModel):
|
|
age: int
|
|
first_name = 'John'
|
|
last_name: NoneStr = None
|
|
signup_ts: Optional[datetime] = None
|
|
list_of_ints: List[int]
|
|
json_list_of_ints: Json[List[int]]
|
|
|
|
|
|
m = Model(age=42, list_of_ints=[1, '2', b'3'])
|
|
|
|
print(m.age + 'not integer')
|
|
m.json_list_of_ints[0] + 'not integer'
|