Skip to content

Commit

Permalink
fix adding Schema dict item to ListProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
ameily committed Aug 15, 2019
1 parent 7deb6e6 commit ba0031e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions cincoconfig/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import sys
from typing import Union, Any, Iterator, Tuple, Callable
from types import ModuleType
from itertools import chain
from .abc import Field, BaseConfig, BaseSchema, SchemaField, AnyField
from .fields import IncludeField
Expand Down Expand Up @@ -75,7 +74,7 @@ def __call__(self, validator: ConfigValidator = None) -> 'Config':
'''
return Config(self, validator=validator)

def make_type(self, name: str, module: ModuleType = None, key_filename: str = None,
def make_type(self, name: str, module: str = None, key_filename: str = None,
validator: ConfigValidator = None) -> type:
'''
Create a new type that wraps this schema. This method should only be called once per
Expand Down Expand Up @@ -109,7 +108,7 @@ def make_type(self, name: str, module: ModuleType = None, key_filename: str = No
# same schema as above
config = schema()
Item = item_schema.make_class('Item')
Item = item_schema.make_type('Item')
item = Item(url='https://google.com', verify_ssl=False)
config.endpoints.append(item)
Expand Down
17 changes: 9 additions & 8 deletions cincoconfig/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,17 @@ def _validate(self, value: Any) -> Any:
'''
if isinstance(self.field, BaseSchema):
if isinstance(value, dict):
cfg = self.field()
cfg = self.field() # type: ignore
cfg._parent = self.cfg
cfg.load_tree(value)
value = cfg

if not isinstance(value, BaseConfig):
raise ValueError('invalid configuration')
elif isinstance(value, BaseConfig):
value._parent = self.cfg
value._validate()
cfg = value
else:
raise ValueError('invalid configuration object')

value._parent = self.cfg
value._validate()
return value
return cfg

return self.field.validate(self.cfg, value)

Expand Down

0 comments on commit ba0031e

Please sign in to comment.