File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 1010
1111
1212class PropertyConverter :
13- def __init__ (self ):
13+ def __init__ (self , required = True , allow_none = False ):
1414 self ._registry = TypeRegistry ()
1515 self ._registry .register (List , self ._list_converter )
1616 self ._registry .register (list , self ._list_converter )
1717
18+ self ._required = required
19+ self ._allow_none = allow_none
20+
1821 def _list_converter (self , subtypes : Tuple [type ], ** opts ) -> FieldABC :
1922 return fields .List (subtypes [0 ], ** opts )
2023
2124 def convert (self , value , ** kwargs ) -> FieldABC :
22- # sane defaults
23- allow_none = False
24- required = True
25+ allow_none = self ._allow_none
26+ required = self ._required
2527 example = value
2628
2729 # set this after optional check
@@ -49,7 +51,7 @@ def data_dict_to_schema(data_dict: dict):
4951 Returns:
5052 dict: Dictionary of Marshmallow fields matching input data types
5153 """
52- converter = PropertyConverter ()
54+ converter = PropertyConverter (required = False )
5355
5456 working_dict = copy .deepcopy (data_dict )
5557
You can’t perform that action at this time.
0 commit comments