{"record":{"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":"UsageError","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/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/__init__.py#L1994-L2030","documentation":"Raised by pytest's TOML config parser when a 'float'-type ini option receives a non-numeric value. Integers are accepted (since int is in the accepted tuple), but booleans are explicitly rejected via `isinstance(value, bool)`. Strings are rejected.","triggerScenarios":"An addini(type='float') option is set to a string or bool in pyproject.toml. Example: timeout = \"60\" (string) or timeout = true (bool) instead of timeout = 60.0 or timeout = 60. The check `not isinstance(value, (float, int)) or isinstance(value, bool)` triggers.","commonSituations":"Quoting a float (making it a string). Using true/false (bool) for a threshold. Assuming TOML coerces strings to numbers (it does not).","solutions":["Use an unquoted number: change `timeout = \"60\"` to `timeout = 60.0` or `timeout = 60`","Replace true/false with the intended numeric value","Ensure the value is a literal float or int, not a string expression"],"exampleFix":"// pyproject.toml — before\n[tool.pytest.ini_options]\ntimeout = \"60\"\n\n// after\n[tool.pytest.ini_options]\ntimeout = 60.0","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, val in opts.items():\n    if isinstance(val, str):\n        print(f\"{key}: got string {val!r}, consider unquoted number if type is 'float'\")\n    elif isinstance(val, bool):\n        print(f\"{key}: got bool, but float type rejects bool\")","typeGuard":"def is_toml_number_not_bool(value: object) -> bool:\n    return isinstance(value, (int, float)) and not isinstance(value, bool)","tryCatchPattern":null,"preventionTips":["Use unquoted numeric literals for float options","Remember both int and float literals are accepted for float type, but bool is not","Never quote numbers in TOML"],"tags":["pytest","config","toml","type-validation","float"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}