{"record":{"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":"UsageError","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/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/__init__.py#L1943-L1979","documentation":"Raised by pytest's TOML config parser (_getini_toml) when an ini option declared with type 'paths' is set to a non-list value in pyproject.toml or tox.ini. Unlike legacy ini parsing, TOML mode performs strict type validation with no coercion — the value must already be a native TOML array. The error includes the config file path, option name, actual type, and the offending value.","triggerScenarios":"A plugin or pytest itself registers an ini option with addini(type='paths'). The user provides a scalar (e.g., a string or integer) instead of an inline array in the [tool.pytest.ini_options] section of pyproject.toml. Example: testpaths = \"tests\" instead of testpaths = [\"tests\"]. The check `isinstance(value, list)` fails and TypeError is raised.","commonSituations":"Migrating from pytest.ini (where bare strings are accepted for path options) to pyproject.toml without converting the value to a TOML array. Copying TOML snippets from outdated blog posts. Confusing TOML syntax (a quoted string is not an array).","solutions":["Wrap the value in square brackets in pyproject.toml: change `testpaths = \"tests\"` to `testpaths = [\"tests\"]`","Verify the TOML file parses to a list by checking with a TOML parser or `python -c \"import tomllib; print(tomllib.loads(open('pyproject.toml','rb').read())['tool']['pytest']['ini_options']['testpaths'])\"`","If you intentionally want a single path, still use a single-element list: testpaths = [\"tests\"]"],"exampleFix":"// pyproject.toml — before\n[tool.pytest.ini_options]\ntestpaths = \"tests\"\n\n// after\n[tool.pytest.ini_options]\ntestpaths = [\"tests\"]","handlingStrategy":"validation","validationCode":"# Before writing pyproject.toml, validate paths options parse as lists\nimport tomllib\nwith open('pyproject.toml', 'rb') as f:\n    data = tomllib.load(f)\nopts = data.get('tool', {}).get('pytest', {}).get('ini_options', {})\nfor key, val in opts.items():\n    if isinstance(val, list):\n        for item in val:\n            if not isinstance(item, str):\n                print(f\"{key}: item {item!r} is not a string\")\n    elif key in ('testpaths', 'python_files', 'python_classes', 'python_functions'):\n        print(f\"{key}: expected a list, got {type(val).__name__}\")","typeGuard":"def is_path_list(value: object) -> bool:\n    return isinstance(value, list) and all(isinstance(item, str) for item in value)","tryCatchPattern":null,"preventionTips":["Always use TOML inline arrays for paths-type options: key = [\"value\"]","Run `python -c \"import tomllib; ...\"` to validate config after editing pyproject.toml","Migrate pytest.ini values to TOML arrays when moving to pyproject.toml"],"tags":["pytest","config","toml","type-validation","paths"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}