{"id":"bb38990438f3f4fc","repo":"pytest-dev/pytest","slug":"self-inipath-config-option-name-expects-a-b","errorCode":null,"errorMessage":"{self.inipath}: config option '{name}' expects a bool, got {value_type}: {value!r}","messagePattern":"(.+?): config option '(.+?)' expects a bool, got (.+?): (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":1996,"sourceCode":"        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                )\n            return value\n        elif type == \"int\":\n            # 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}\"","sourceCodeStart":1978,"sourceCodeEnd":2014,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L1978-L2014","documentation":"Raised by Config._getini_toml (config/__init__.py:1993-1999) for a 'bool'-typed option in TOML mode when the value is not a Python bool. TOML has a native boolean type, so pytest requires true/false; the strings \"true\"/\"false\" or 1/0 are rejected because they are not bool.","triggerScenarios":"Setting a bool option in pyproject.toml to a string (\"true\"), an int (1), or any non-bool type. Example: addopts = 1 for an option registered as bool.","commonSituations":"Quoting booleans in TOML (`x = \"true\"`); using 1/0 integers (valid in INI via _strtobool, rejected in TOML); copy-paste from INI without converting to native bool.","solutions":["Use TOML native booleans: x = true (or false), unquoted.","Remove quotes around the value.","If you need 1/0/yes/no accepted, keep the option in pytest.ini where _strtobool coerces strings."],"exampleFix":"# before (pyproject.toml)\n[tool.pytest.ini_options]\ncache_provider = \"true\"\n\n# after\ncache_provider = true","handlingStrategy":"validation","validationCode":"def ensure_toml_bool(value):\n    if not isinstance(value, bool):\n        raise TypeError('bool option in TOML must be true/false')\n    return value","typeGuard":"def is_native_bool(value) -> bool:\n    return isinstance(value, bool)","tryCatchPattern":"try:\n    config.getini(name)\nexcept Exception:\n    # set value to a native TOML true/false and reload","preventionTips":["Use unquoted true/false in TOML for bool options.","Avoid 1/0 or 'yes'/'no' in pyproject.toml.","Keep a config linter that flags quoted booleans."],"tags":["config","toml","bool","type-mismatch","pytest"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}