{"id":"1c42c1aa25eb8c9e","repo":"pytest-dev/pytest","slug":"self-inipath-config-option-name-expects-a-s-1c42c1","errorCode":null,"errorMessage":"{self.inipath}: config option '{name}' expects a string, got {value_type}: {value!r}","messagePattern":"(.+?): config option '(.+?)' expects a string, got (.+?): (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":2020,"sourceCode":"            # Expect an integer (but not bool, which is a subclass of int).\n            if not isinstance(value, int) or isinstance(value, bool):\n                raise TypeError(\n                    f\"{self.inipath}: config option '{name}' expects an int, \"\n                    f\"got {value_type}: {value!r}\"\n                )\n            return value\n        elif type == \"float\":\n            # Expect a float or integer only.\n            if not isinstance(value, (float, int)) or isinstance(value, bool):\n                raise TypeError(\n                    f\"{self.inipath}: config option '{name}' expects a float, \"\n                    f\"got {value_type}: {value!r}\"\n                )\n            return value\n        elif type == \"string\":\n            # Expect a string.\n            if not isinstance(value, str):\n                raise TypeError(\n                    f\"{self.inipath}: config option '{name}' expects a string, \"\n                    f\"got {value_type}: {value!r}\"\n                )\n            return value\n        else:\n            return self._getini_unknown_type(name, type, value)\n\n    def _getconftest_pathlist(\n        self, name: str, path: pathlib.Path\n    ) -> list[pathlib.Path] | None:\n        try:\n            mod, relroots = self.pluginmanager._rget_with_confmod(name, path)\n        except KeyError:\n            return None\n        assert mod.__file__ is not None\n        modpath = pathlib.Path(mod.__file__).parent\n        values: list[pathlib.Path] = []\n        for relroot in relroots:","sourceCodeStart":2002,"sourceCodeEnd":2038,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L2002-L2038","documentation":"Raised by Config._getini_toml (config/__init__.py:2017-2023) for a 'string'-typed option in TOML mode when the value is not a Python str. TOML preserves native types, so a bare int/bool/float/list where a string is required is rejected (no coercion, unlike INI mode).","triggerScenarios":"Setting a string option in pyproject.toml to an unquoted bareword that TOML parses as a number/bool, e.g. minversion = 8 instead of minversion = \"8\".","commonSituations":"Forgetting quotes around values that look numeric or boolean (e.g. minversion, markers); INI->TOML migration; treating TOML like a shell config.","solutions":["Quote the value in TOML: x = \"value\".","Watch for barewords that TOML parses as int/bool (8, true) and wrap them in quotes.","Confirm the option's registered type is 'string' (or a Literal choice)."],"exampleFix":"# before (pyproject.toml)\n[tool.pytest.ini_options]\nminversion = 8\n\n# after\nminversion = \"8.0\"","handlingStrategy":"validation","validationCode":"def ensure_toml_str(value):\n    if not isinstance(value, str):\n        raise TypeError('string option in TOML must be a quoted string')\n    return value","typeGuard":"def is_str(value) -> bool:\n    return isinstance(value, str)","tryCatchPattern":"try:\n    config.getini(name)\nexcept Exception:\n    # quote the value in pyproject.toml and reload","preventionTips":["Quote string values in TOML, especially ones that look numeric/boolean.","Validate pyproject.toml pytest sections with a linter.","Beware barewords (8, true) parsed as non-string types."],"tags":["config","toml","string","type-mismatch","pytest"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}