From 0d1c7ba76ffc00fcfb714536a63b27abce7061e6 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Wed, 27 Jan 2021 09:09:46 +0100 Subject: [PATCH] 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 Reviewed-by: Enrico Faulhaber Reviewed-by: Markus Zolliker --- secop/params.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/secop/params.py b/secop/params.py index b951c00..cb7feb4 100644 --- a/secop/params.py +++ b/secop/params.py @@ -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)