@@ -251,22 +251,34 @@ def _row_entries(param_name: str, param_value_raw: str) -> list[str]:
251251 if parse_units_and_comments :
252252 # TODO consolidate with other codebase parameter parsing logic...
253253 param_schema = request_schema ['properties' ].get (param_name , {param_name : {}})
254+ is_array_type = param_schema .get ('type' ) == 'array'
254255
255256 value_non_value_split = (
256- value_entry .split (' ' , maxsplit = 1 )
257- if not param_schema .get ('type' ) == 'array'
258- else value_entry .split (', --' , maxsplit = 1 )
259- )
260- value_entry = value_non_value_split [0 ]
261- unit_and_comment_split = (
262- value_non_value_split [1 ].split (' --' , maxsplit = 1 ) if len (value_non_value_split ) > 1 else ['' , '' ]
257+ value_entry .split (' ' , maxsplit = 1 ) if not is_array_type else value_entry .split (', --' , maxsplit = 1 )
263258 )
259+ value_entry = value_non_value_split [0 ].rstrip (',' ).rstrip ()
260+ remainder = value_non_value_split [1 ] if len (value_non_value_split ) > 1 else ''
264261
265262 default_units_for_param = param_schema .get ('units' , '' )
266- units_entry = unit_and_comment_split [0 ] if unit_and_comment_split [0 ] != '' else default_units_for_param
267263
268- if len (unit_and_comment_split ) > 1 :
269- comment_entry = unit_and_comment_split [1 ]
264+ if is_array_type :
265+ # For array-type params, the ', --' split already consumed the comment delimiter;
266+ # whatever remains is the comment (no units possible from the value string).
267+ comment_entry = remainder .lstrip () if remainder else ''
268+ units_entry = default_units_for_param
269+ else :
270+ # For scalar params, remainder is either "<units>" or "-- <comment>"
271+ # (optionally "<units> -- <comment>").
272+ unit_and_comment_split = remainder .split (' --' , maxsplit = 1 ) if remainder else ['' ]
273+ units_part = unit_and_comment_split [0 ]
274+ if units_part .lstrip ().startswith ('--' ):
275+ # No units, just an inline comment introduced by '-- '.
276+ comment_entry = units_part .lstrip ()[2 :].lstrip ()
277+ units_entry = default_units_for_param
278+ else :
279+ units_entry = units_part if units_part != '' else default_units_for_param
280+ if len (unit_and_comment_split ) > 1 :
281+ comment_entry = unit_and_comment_split [1 ].lstrip ()
270282
271283 return [
272284 'INPUT PARAMETERS' ,
0 commit comments