make arguments of Parameter and Override consistent

- allow description _and_ datatype being positional args
- disallow ctr, unit, reorder being positional
This commit is contained in:
l_samenv 2020-12-04 13:28:04 +01:00
parent cab2bb85ba
commit 569c0a3399

View File

@ -120,7 +120,7 @@ class Parameter(Accessible):
NoneOr(BoolType()), export=False, default=None, mandatory=False, settable=False), NoneOr(BoolType()), export=False, default=None, mandatory=False, settable=False),
} }
def __init__(self, description, datatype, ctr=None, unit=None, **kwds): def __init__(self, description, datatype, *, ctr=None, unit=None, **kwds):
if ctr is not None: if ctr is not None:
self.ctr = ctr self.ctr = ctr
@ -227,13 +227,15 @@ class Override(CountedObj):
note: overrides are applied by the metaclass during class creating note: overrides are applied by the metaclass during class creating
reorder= True: use position of Override instead of inherited for the order reorder= True: use position of Override instead of inherited for the order
""" """
def __init__(self, description="", reorder=False, **kwds): def __init__(self, description="", datatype=None, *, reorder=False, **kwds):
super(Override, self).__init__() super(Override, self).__init__()
self.kwds = kwds self.kwds = kwds
self.reorder = reorder self.reorder = reorder
# allow to override description without keyword # allow to override description and datatype without keyword
if description: if description:
self.kwds['description'] = description self.kwds['description'] = description
if datatype is not None:
self.kwds['datatype'] = datatype
# for now, do not use the Override ctr # for now, do not use the Override ctr
# self.kwds['ctr'] = self.ctr # self.kwds['ctr'] = self.ctr