{"id":"f5016b8dd772f962","repo":"pytest-dev/pytest","slug":"self-inipath-config-option-name-expects-a-l-f5016b","errorCode":null,"errorMessage":"{self.inipath}: config option '{name}' expects a list of strings, but item at index {i} is {item_type}: {item!r}","messagePattern":"(.+?): config option '(.+?)' expects a list of strings, but item at index (.+?) is (.+?): (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":1968,"sourceCode":"        default: Any,\n    ):\n        \"\"\"Handle TOML config values with strict type validation and no coercion.\n\n        In TOML mode, values already have native types from TOML parsing.\n        We validate types match expectations exactly, including list items.\n        \"\"\"\n        value_type = builtins.type(value).__name__\n        if type == \"paths\":\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 'paths', \"\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            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):","sourceCodeStart":1950,"sourceCodeEnd":1986,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L1950-L1986","documentation":"Raised by Config._getini_toml (config/__init__.py:1965-1971) for a 'paths'-typed option in TOML mode when the value IS a list but at least one element is not a str. The message names the offending index, item type, and value to pinpoint the bad entry.","triggerScenarios":"Supplying a TOML array for testpaths/pythonpath/norecursedirs where one element is an int, bool, or nested table, e.g. testpaths = [\"tests\", 42].","commonSituations":"Mixed-type arrays after a partial TOML edit; copy-paste from YAML/JSON leaving unquoted numerics; booleans (true/false) accidentally included as path entries.","solutions":["Ensure every element of the paths array is a quoted TOML string.","Use the reported index to find and fix the specific bad entry.","Remove any non-path elements (numbers/bools) from the array."],"exampleFix":"# before (pyproject.toml)\ntestpaths = [\"tests\", 42]\n\n# after\ntestpaths = [\"tests\", \"tests_42\"]","handlingStrategy":"validation","validationCode":"def validate_paths_items(value):\n    for i, item in enumerate(value):\n        if not isinstance(item, str):\n            raise TypeError(f'paths[{i}] must be str, got {type(item).__name__}')\n    return value","typeGuard":"def all_items_str(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    # stringify/remove non-path entries and reload","preventionTips":["Quote every entry of TOML path arrays.","Avoid mixing types in a single array.","Use the reported index to locate the bad item quickly."],"tags":["config","toml","paths","list-item-type","pytest"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}