{"record":{"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":"UsageError","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/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/__init__.py#L1963-L1999","documentation":"Raised by pytest's TOML config parser when an ini option declared as 'args' or 'linelist' is set to a non-list value. These types require a TOML array of strings. Like all TOML-mode validation, there is no implicit coercion from string or scalar.","triggerScenarios":"An addini(type='args') or addini(type='linelist') option is given a bare string or scalar in pyproject.toml instead of an inline array. Example: filterwarnings = \"ignore\" instead of filterwarnings = [\"ignore\"]. The `isinstance(value, list)` check in the `elif type in {\"args\", \"linelist\"}` branch fails.","commonSituations":"Treating a multi-value TOML option as a single string. Copying ini-style single-line values into TOML without array syntax. Expecting pytest to auto-split a comma-separated string (it does not in TOML mode).","solutions":["Convert the value to a TOML inline array: change `addopts = \"-v --tb=short\"` to `addopts = [\"-v\", \"--tb=short\"]`","For linelist types, each list element is one line — do not embed newlines in a single string","Verify with tomllib that the value parses as a list of strings"],"exampleFix":"// pyproject.toml — before\n[tool.pytest.ini_options]\naddopts = \"-v --tb=short\"\n\n// after\n[tool.pytest.ini_options]\naddopts = [\"-v\", \"--tb=short\"]","handlingStrategy":"validation","validationCode":"import tomllib\nwith open('pyproject.toml', 'rb') as f:\n    data = tomllib.load(f)\nopts = data.get('tool', {}).get('pytest', {}).get('ini_options', {})\nfor key in ('addopts', 'filterwarnings', 'markers', 'norecursedirs'):\n    if key in opts and not isinstance(opts[key], list):\n        print(f\"{key}: expected a TOML list, got {type(opts[key]).__name__}\")","typeGuard":"def is_args_list(value: object) -> bool:\n    return isinstance(value, list) and all(isinstance(item, str) for item in value)","tryCatchPattern":null,"preventionTips":["Use TOML inline arrays for args/linelist options","Do not expect pytest to auto-split comma-separated strings in TOML mode","Validate config with tomllib after editing"],"tags":["pytest","config","toml","type-validation","args","linelist"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}