{"record":{"id":"c78ca14ac0917c00","repo":"pytest-dev/pytest","slug":"self-inipath-config-option-name-expects-an","errorCode":null,"errorMessage":"{self.inipath}: config option '{name}' expects an int, got {value_type}: {value!r}","messagePattern":"(.+?): config option '(.+?)' expects an int, got (.+?): (.+?)","errorType":"exception","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":2004,"sourceCode":"                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}\"\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}\"","sourceCodeStart":1986,"sourceCodeEnd":2022,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/__init__.py#L1986-L2022","documentation":"Raised by pytest's TOML config parser when an 'int'-type ini option receives a non-integer value, including a boolean. Because bool is a subclass of int in Python, the check explicitly rejects bools via `isinstance(value, bool)`. Floats and strings are also rejected.","triggerScenarios":"An addini(type='int') option is set to a float, string, or bool in pyproject.toml. Example: verbosity = \"2\" (string) or verbosity = 2.0 (float) or verbosity = true (bool) instead of verbosity = 2 (integer). The check `not isinstance(value, int) or isinstance(value, bool)` triggers.","commonSituations":"Quoting an integer (making it a string). Using a float literal where an int is expected. Accidentally writing true/false (bool) for a numeric option. Confusing TOML number typing.","solutions":["Use an unquoted integer: change `verbosity = \"2\"` to `verbosity = 2`","Remove decimal points: change `verbosity = 2.0` to `verbosity = 2`","Replace true/false with the intended integer (e.g., 1/0)"],"exampleFix":"// pyproject.toml — before\n[tool.pytest.ini_options]\nverbosity = \"2\"\n\n// after\n[tool.pytest.ini_options]\nverbosity = 2","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, bool):\n        print(f\"{key}: got TOML bool, but type may expect int\")\n    elif isinstance(val, str):\n        print(f\"{key}: got string {val!r}, consider unquoted int if type is 'int'\")\n    elif isinstance(val, float):\n        print(f\"{key}: got float {val}, consider int if type is 'int'\")","typeGuard":"def is_toml_int_strict(value: object) -> bool:\n    return isinstance(value, int) and not isinstance(value, bool)","tryCatchPattern":null,"preventionTips":["Use unquoted integer literals for int options","Never quote integers or use decimal points for int options","Remember TOML true/false are bools, not ints — pytest rejects them for int options"],"tags":["pytest","config","toml","type-validation","int"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}