Skip to content

Commit 7ad9e9f

Browse files
committed
[ModelExecutionCmd] fix variable shadow
1 parent 6f179c1 commit 7ad9e9f

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,31 +142,31 @@ def arg_set(
142142
"""
143143

144144
def override2str(
145-
key: str,
146-
val: str | bool | numbers.Number,
145+
orkey: str,
146+
orval: str | bool | numbers.Number,
147147
) -> str:
148148
"""
149149
Convert a value for 'override' to a string taking into account differences between Modelica and Python.
150150
"""
151151
# check oval for any string representations of numbers (or bool) and convert these to Python representations
152-
if isinstance(val, str):
152+
if isinstance(orval, str):
153153
try:
154-
val_evaluated = ast.literal_eval(val)
154+
val_evaluated = ast.literal_eval(orval)
155155
if isinstance(val_evaluated, (numbers.Number, bool)):
156-
val = val_evaluated
156+
orval = val_evaluated
157157
except (ValueError, SyntaxError):
158158
pass
159159

160-
if isinstance(val, str):
161-
val_str = val.strip()
162-
elif isinstance(val, bool):
163-
val_str = 'true' if val else 'false'
164-
elif isinstance(val, numbers.Number):
165-
val_str = str(val)
160+
if isinstance(orval, str):
161+
val_str = orval.strip()
162+
elif isinstance(orval, bool):
163+
val_str = 'true' if orval else 'false'
164+
elif isinstance(orval, numbers.Number):
165+
val_str = str(orval)
166166
else:
167-
raise ModelExecutionException(f"Invalid value for override key {key}: {type(val)}")
167+
raise ModelExecutionException(f"Invalid value for override key {orkey}: {type(orval)}")
168168

169-
return f"{key}={val_str}"
169+
return f"{orkey}={val_str}"
170170

171171
if not isinstance(key, str):
172172
raise ModelExecutionException(f"Invalid argument key: {repr(key)} (type: {type(key)})")
@@ -195,7 +195,7 @@ def override2str(
195195
f"(was: {repr(self._arg_override[okey])})")
196196

197197
if oval is not None:
198-
self._arg_override[okey] = override2str(key=okey, val=oval)
198+
self._arg_override[okey] = override2str(orkey=okey, orval=oval)
199199

200200
argval = ','.join(sorted(self._arg_override.values()))
201201
elif val is None:

0 commit comments

Comments
 (0)