{"id":"6671456ff48e7755","repo":"pytest-dev/pytest","slug":"self-inipath-config-option-name-expects-a-f","errorCode":null,"errorMessage":"{self.inipath}: config option '{name}' expects a float, got {value_type}: {value!r}","messagePattern":"(.+?): config option '(.+?)' expects a float, got (.+?): (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":2012,"sourceCode":"            # 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}\"\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:","sourceCodeStart":1994,"sourceCodeEnd":2030,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L1994-L2030","documentation":"Raised by Config._getini_toml (config/__init__.py:2009-2015) for a 'float'-typed option in TOML mode when the value is neither a float nor an int — and explicitly rejects bool. ints are accepted (a native TOML int is a valid float), but strings/bools are not.","triggerScenarios":"Setting a float option in pyproject.toml to a quoted string (\"1.5\"), a bool (true), or any non-numeric type.","commonSituations":"Quoting floats in TOML; using true/false; mistyping a numeric threshold; INI->TOML migration leaving strings.","solutions":["Use a bare TOML float: x = 1.5 (no quotes). A bare int (2) is also accepted.","Remove quotes/convert booleans to the intended numeric value.","Confirm the option is registered as 'float' and supply a numeric literal."],"exampleFix":"# before (pyproject.toml)\n[tool.pytest.ini_options]\nfaulthandler_timeout = \"5.0\"\n\n# after\nfaulthandler_timeout = 5.0","handlingStrategy":"validation","validationCode":"def ensure_toml_float(value):\n    if not isinstance(value, (int, float)) or isinstance(value, bool):\n        raise TypeError('float option in TOML must be a numeric literal')\n    return value","typeGuard":"def is_native_number(value) -> bool:\n    return isinstance(value, (int, float)) and not isinstance(value, bool)","tryCatchPattern":"try:\n    config.getini(name)\nexcept Exception:\n    # supply a bare numeric literal and reload","preventionTips":["Use bare numeric literals (1.5 or 2) in TOML for float options.","Avoid quoted numbers and booleans.","Lint [tool.pytest.ini_options] numerics."],"tags":["config","toml","float","type-mismatch","pytest"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}