feedly/transfer-nlp

None default causes problems

kireet opened this issue · 0 comments

this config didn't work:

@register_plugin
class DemoDefaults:

    def __init__(self, strval: str, intval1: int = 5, intval2: int = None):
        self.strval = strval
        self.intval1 = intval1
        self.intval2 = intval2

@register_plugin
class DemoComplexDefaults:

    def __init__(self, strval: str, obj: DemoDefaults = None): # use different param and property names as additonal check
        self.simple = strval
        self.complex = obj

experiment = {
    'demo': {
        '_name': 'DemoComplexDefaults',
        'strval': 'foo'
    },
    'obj': {
        '_name': 'DemoDefaults',
        'strval': 'bar',
        'intval1': 20
    }
}

it's because intval2's default is None and this is causing it to be unconfigured in the params mode 1 step. then both objects are configured using all default values in mode=2.