{"id":"c4b2483c8c494bfc","repo":"pytest-dev/pytest","slug":"self-inipath-config-option-name-expects-a-l","errorCode":null,"errorMessage":"{self.inipath}: config option '{name}' expects a list for type 'paths', got {value_type}: {value!r}","messagePattern":"(.+?): config option '(.+?)' expects a list for type 'paths', got (.+?): (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":1961,"sourceCode":"\n    def _getini_toml(\n        self,\n        name: str,\n        canonical_name: str,\n        type: str,\n        value: object,\n        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.","sourceCodeStart":1943,"sourceCodeEnd":1979,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L1943-L1979","documentation":"Raised by Config._getini_toml (config/__init__.py:1958-1964) for a 'paths'-typed option in TOML mode when the value is not a Python list. paths in TOML must be an array of strings (each resolved relative to inipath); scalars or dicts are rejected with the actual type name embedded in the message.","triggerScenarios":"Setting a paths-typed ini option in pyproject.toml to a scalar string or anything other than a TOML array, e.g. testpaths = \"tests\" instead of testpaths = [\"tests\"].","commonSituations":"Migrating testpaths/norecursedirs/pythonpath/etc. from .ini (where a bare string is accepted and shlex-split) to pyproject.toml without wrapping in an array; misunderstanding TOML's stricter typing for paths.","solutions":["Wrap the value in a TOML array: testpaths = [\"tests\", \"integration\"].","Confirm the option's registered type is 'paths' (it expects path-like strings as a list in TOML).","If you need the .ini single-string shorthand, keep the setting in pytest.ini instead."],"exampleFix":"# before (pyproject.toml)\n[tool.pytest.ini_options]\ntestpaths = \"tests\"\n\n# after\ntestpaths = [\"tests\"]","handlingStrategy":"validation","validationCode":"def ensure_paths_list(value):\n    if not isinstance(value, list):\n        raise TypeError('paths option must be a list in TOML mode')\n    return value","typeGuard":"def is_paths_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    # wrap the scalar in a list in pyproject.toml and reload","preventionTips":["Always express TOML paths as arrays of strings.","When migrating from .ini, wrap single strings in [] for paths options.","Lint pyproject.toml pytest sections in CI."],"tags":["config","toml","paths","type-mismatch","pytest"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}