make arguments of Parameter and Override consistent

- allow (description and) datatype being positional args in Override
- disallow ctr and unit being a positional arg in Parameter
- disallow reorder being a positional arg in Override

Change-Id: Ic5711d091af11d5843943b0b2b31567127f8ed8c
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/24934
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
zolliker 2021-01-27 09:09:46 +01:00
parent 05fec236da
commit 24cffad4df

View File

@ -118,7 +118,7 @@ class Parameter(Accessible):
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 not isinstance(datatype, DataType):
if issubclass(datatype, DataType):
@ -221,11 +221,13 @@ class Override:
note: overrides are applied by the metaclass during class creating
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):
self.kwds = kwds
# allow to override description without keyword
# allow to override description and datatype without keyword
if description:
self.kwds['description'] = description
if datatype is not None:
self.kwds['datatype'] = datatype
if reorder: # result from apply must use new ctr from Override
self.kwds['ctr'] = next(object_counter)