{"id":"199b710214e16b18","repo":"pytest-dev/pytest","slug":"self-inipath-config-option-name-expects-a-l-199b71","errorCode":null,"errorMessage":"{self.inipath}: config option '{name}' expects a list for type '{type}', got {value_type}: {value!r}","messagePattern":"(.+?): config option '(.+?)' expects a list for type '(.+?)', got (.+?): (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":1981,"sourceCode":"                    f\"got {value_type}: {value!r}\"\n                )\n            for i, item in enumerate(value):\n                if not isinstance(item, str):\n                    item_type = builtins.type(item).__name__\n                    raise TypeError(\n                        f\"{self.inipath}: config option '{name}' expects a list of strings, \"\n                        f\"but item at index {i} is {item_type}: {item!r}\"\n                    )\n            dp = (\n                self.inipath.parent\n                if self.inipath is not None\n                else self.invocation_params.dir\n            )\n            return [dp / x for x in value]\n        elif type in {\"args\", \"linelist\"}:\n            # Expect a list of strings.\n            if not isinstance(value, list):\n                raise TypeError(\n                    f\"{self.inipath}: config option '{name}' expects a list for type '{type}', \"\n                    f\"got {value_type}: {value!r}\"\n                )\n            for i, item in enumerate(value):\n                if not isinstance(item, str):\n                    item_type = builtins.type(item).__name__\n                    raise TypeError(\n                        f\"{self.inipath}: config option '{name}' expects a list of strings, \"\n                        f\"but item at index {i} is {item_type}: {item!r}\"\n                    )\n            return list(value)\n        elif type == \"bool\":\n            # Expect a boolean.\n            if not isinstance(value, bool):\n                raise TypeError(\n                    f\"{self.inipath}: config option '{name}' expects a bool, \"\n                    f\"got {value_type}: {value!r}\"\n                )","sourceCodeStart":1963,"sourceCodeEnd":1999,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L1963-L1999","documentation":"Raised by Config._getini_toml (config/__init__.py:1978-1984) for options of type 'args' or 'linelist' in TOML mode when the supplied value is not a list. In TOML these types strictly require an array; a scalar string or other type is rejected, unlike INI mode where a string is split into tokens.","triggerScenarios":"Setting an args/linelist option (e.g. addopts, filterwarnings, markers) in pyproject.toml to a bare scalar instead of an array.","commonSituations":"Writing addopts = '-v' (string) instead of addopts = ['-v'] (array) in pyproject.toml; porting from pytest.ini's `addopts = -v --foo` line directly into TOML.","solutions":["Express the value as a TOML array of strings: addopts = [\"-v\", \"--foo\"].","For linelist, each array entry is one line — do not concatenate with newlines.","Confirm the registered type (args vs linelist) and follow that array convention."],"exampleFix":"# before (pyproject.toml)\naddopts = \"-v --strict-markers\"\n\n# after\naddopts = [\"-v\", \"--strict-markers\"]","handlingStrategy":"validation","validationCode":"def ensure_list(value):\n    if not isinstance(value, list):\n        raise TypeError('args/linelist option must be a list in TOML mode')\n    return value","typeGuard":"def is_str_list(value) -> bool:\n    return isinstance(value, list) and all(isinstance(x, str) for x in value)","tryCatchPattern":"try:\n    config.getini(name)\nexcept Exception:\n    # convert scalar to [scalar] in pyproject.toml and reload","preventionTips":["Express addopts/filterwarnings as TOML arrays of strings.","Do not paste INI single-line values verbatim into TOML.","Lint [tool.pytest.ini_options] in CI."],"tags":["config","toml","args","linelist","type-mismatch","pytest"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}