Closed moskomule closed 3 years ago
Fix sequence like this:
def sequence(*values: Any,
size: Optional[int] = None,
help: Optional[str] = None
) -> dataclasses.Field:
""" Add a default value of list, which is invalid in dataclass.
Args:
*values:
size: size of sequence. If specified, the length is fixed, and if violated, ValueError will be raised.
help: help message
Returns: sequence with a help message
"""
meta = {'default': list(values)}
meta['nargs'] = size or '+'
if help is not None:
meta['help'] = help
return dataclasses.field(default=tuple(values), metadata=meta)
chika.sequence
does not work as expected whensize
is not specified. Also, the float values seem to be converted to[("0", ".", "9")]
etc.