Skip to content

Commit

Permalink
lisa.wlgen.rta: Use ComposableMultiConcretePropertyBase._ATTRIBUTES t…
Browse files Browse the repository at this point in the history
…ypes

FEATURE

Use the type of each attribute to process user input. For example, this
will ensure uclamp values are integers and not user-provided floats.
  • Loading branch information
douglas-raillard-arm committed Oct 10, 2023
1 parent 37727f7 commit 011375d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lisa/wlgen/rta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2341,10 +2341,12 @@ class ComposableMultiConcretePropertyBase(MultiConcreteProperty):

def __init__(self, **kwargs):
def check(key, val):
if key in self._ATTRIBUTES:
return val
else:
try:
desc = self._ATTRIBUTES[key]
except KeyError:
raise TypeError(f'Unknown parameter "{key}". Only {sorted(self._ATTRIBUTES)} are allowed')
else:
return desc.get('type_', lambda x: x)(val)

attrs = {
key: check(key, val)
Expand Down

0 comments on commit 011375d

Please sign in to comment.