Bug
Please complete:
- OS: OSX
- Python version
import sys; print(sys.version): 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 14:38:56)
- Pydantic version
import pydantic; print(pydantic.VERSION): 0.32.1
Please read the docs and search through issues to
confirm your bug hasn't already been reported before.
Where possible please include a self contained code snippet describing your bug:
from pydantic import BaseModel
class A(BaseModel):
value: int = 1
class B(A):
value = 'G'
print(A.__annotations__, A.__fields__)
# ({'value': int}, {'value': <Field(value type=int default=1)>})
print(A.__annotations__, A.__fields__)
# ({'value': int}, {'value': <Field(value type=str default='G')>})
The film type should be int in both cases. __annotations__ is empty in the metaclass so a type will be inferred for the field even without a type hint.
A solution would be to take the parents' annotations into consideration as well, or to introduce another config option to prevent inferring the type of the default value as the type hint for the field. I'm not sure how would the former one affect the rest of the features.
Bug
Please complete:
import sys; print(sys.version): 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 14:38:56)import pydantic; print(pydantic.VERSION): 0.32.1Please read the docs and search through issues to
confirm your bug hasn't already been reported before.
Where possible please include a self contained code snippet describing your bug:
The film type should be int in both cases.
__annotations__is empty in the metaclass so a type will be inferred for the field even without a type hint.A solution would be to take the parents' annotations into consideration as well, or to introduce another config option to prevent inferring the type of the default value as the type hint for the field. I'm not sure how would the former one affect the rest of the features.