deepfakes/faceswap · error · ValueError

[{self._name}] List values should be set as a Str or List. G

Error message

[{self._name}] List values should be set as a Str or List. Got {type(value)} ({value})

What it means

Generic datatype check in ConfigOption.validate: after list handling, the value must be an instance of the option's declared datatype (str/int/float/bool/list). Otherwise ValueError is raised with the expected vs received type, prefixed by the option's name for easy identification.

Source

Thrown at lib/config/objects.py:385

        """Set the item's option value

        Parameters
        ----------
        value
            The value to set this item to. Must be of type :attr:`datatype`

        Raises
        ------
        ValueError
            If the given value does not pass type and content validation checks
        """
        if not self._name:
            raise ValueError("The name of this object should have been set before any value is"
                             "added")

        if self.datatype is list:
            if not isinstance(value, (str, list)):
                raise ValueError(f"[{self._name}] List values should be set as a Str or List. Got "
                                 f"{type(value)} ({value})")
            value = cast(T, self._parse_list(value))

        if not isinstance(value, self.datatype):
            raise ValueError(
                f"[{self._name}] Expected {self.datatype} got {type(value)} ({value})")

        if isinstance(self.choices, list) and self.choices:
            assert isinstance(value, (list, str))
            value = cast(T, self._validate_selection(value))

        if self.choices == "colorchooser":
            assert isinstance(value, str)
            if not value.startswith("#") or len(value) != 7:
                raise ValueError(f"Hex color codes should start with a '#' and be 6 "
                                 f"characters long. Got: '{value}'")

        self._value = value

View on GitHub (pinned to f530cb7508)

Solutions

  1. Convert the value to the option's datatype before setting: int('2'), float(1), bool flags via strtobool semantics
  2. Inspect the option (option.datatype) and correct the value or the option's declared datatype
  3. For .ini files, remove quotes around numerics so configparser+Faceswap coerces correctly

Example fix

# before
option.datatype is int
option.set("256")  # -> [name] Expected <class 'int'> got <class 'str'> ('256')

# after
option.set(int("256"))
Defensive patterns

Strategy: type-guard

Validate before calling

def coerce_list_value(value):
    if isinstance(value, str):
        return value
    if isinstance(value, (list, tuple, set)):
        return list(value)
    raise TypeError(f"cannot coerce {type(value).__name__} to list")

option.set(coerce_list_value(value))

Type guard

def is_list_option_value(v) -> bool:
    """True when ConfigOption.set accepts v for a list-datatype option."""
    return isinstance(v, (str, list))

Try / catch

try:
    option.set(value)
except ValueError as err:
    if "List values should be set as a Str or List" in str(err):
        option.set(list(value) if not isinstance(value, str) else value)
    else:
        raise

Prevention

When it happens

Trigger: option.set(value) where datatype is int but a str '2' is passed; datatype bool with 1/0; datatype float with an int where the option declared float (isinstance passes for int/float pairings only in one direction); datatype str with bytes.

Common situations: Hand-editing a plugin .ini where a quoted number stays a string; programmatic config writers using unconverted values from argparse or JSON; plugin authors declaring datatype=int but defaulting to '128'.

Related errors


AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15). Data as JSON: /api/errors/971493355c344d79. Report an issue: GitHub.