-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
Please let me know if I'm doing something incorrect here, and if not, I would love to submit a pull request fixing this issue :)
from decimal import Decimal
from pydantic import BaseModel
class Test(BaseModel):
value: Decimal = None---------------------------------------------------------------------------
ConfigError Traceback (most recent call last)
<ipython-input-12-7f02e90f9299> in <module>()
----> 1 class Test(BaseModel):
2 value: Decimal = None
3
/usr/local/Cellar/python/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pydantic/main.py in __new__(mcs, name, bases, namespace)
116 annotation=annotations.get(var_name),
117 class_validators=vg.get_validators(var_name),
--> 118 config=config,
119 )
120
/usr/local/Cellar/python/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pydantic/fields.py in infer(cls, name, value, annotation, class_validators, config)
82 required=required,
83 model_config=config,
---> 84 description=field_config and field_config.get('description'),
85 )
86
/usr/local/Cellar/python/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pydantic/fields.py in __init__(self, name, type_, class_validators, default, required, model_config, alias, allow_none, description)
68 self.shape: Shape = Shape.SINGLETON
69 self.info = {}
---> 70 self.prepare()
71
72 @classmethod
/usr/local/Cellar/python/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pydantic/fields.py in prepare(self)
111
112 self._populate_sub_fields()
--> 113 self._populate_validators()
114
115 self.info = {
/usr/local/Cellar/python/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pydantic/fields.py in _populate_validators(self)
190 v_funcs = (
191 *tuple(v.func for v in self.class_validators if not v.whole and v.pre),
--> 192 *(get_validators() if get_validators else find_validators(self.type_)),
193 *tuple(v.func for v in self.class_validators if not v.whole and not v.pre),
194 )
/usr/local/Cellar/python/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pydantic/validators.py in find_validators(type_)
162 except TypeError as e:
163 raise TypeError(f'error checking inheritance of {type_!r} (type: {display_as_type(type_)})') from e
--> 164 raise ConfigError(f'no validator found for {type_}')
ConfigError: no validator found for <class 'decimal.Decimal'>BTW, excellent project here, it's one of my new favorites!
AlexanderPershin
Metadata
Metadata
Assignees
Labels
No labels