Skip to content

[bug] PydanticSerializationError on mcf_str #84

@jm-rivera

Description

@jm-rivera

def mcf_str(value: str | list[str] | None) -> str | None:

def mcf_str(value: str | list[str] | None) -> str | None:
    """Serialise a string or list of strings without adding quotes.

    Args:
        value: A string, list of strings, or None to serialise.

    Returns:
        A comma-delimited string, a single string, or None if input is None or an empty list.
    """
    if value is None:
        return None

    if isinstance(value, list):
        if not value:
            return None  # <-- add something like this to deal with empty lists
        if len(value) == 1:
            return str(value[0])
        return ", ".join(str(item) for item in value)

    return value

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions