{"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":"TypeError","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/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/__init__.py#L1986-L2022","documentation":"Raised by Config._getini_toml (config/__init__.py:2001-2007) for an 'int'-typed option in TOML mode when the value is not an int — and explicitly rejects bool, because bool is a subclass of int in Python (`isinstance(True, int)` is True), so the guard uses `not isinstance(value, int) or isinstance(value, bool)`.","triggerScenarios":"Setting an int option in pyproject.toml to a string (\"2\"), a float (2.0), or a bool (true). A native TOML integer is required.","commonSituations":"Quoting ints in TOML; passing a float where an int is expected; accidentally using true/false for an int flag; INI->TOML migration leaving values as strings.","solutions":["Use a bare TOML integer: x = 2 (no quotes).","If a bool was intended, change the option's registered type to 'bool'.","Ensure floats are not used where ints are required (truncate/convert at the source)."],"exampleFix":"# before (pyproject.toml)\nverbosity_test_cases = \"2\"\n\n# after\nverbosity_test_cases = 2","handlingStrategy":"validation","validationCode":"def ensure_toml_int(value):\n    if not isinstance(value, int) or isinstance(value, bool):\n        raise TypeError('int option in TOML must be a bare integer')\n    return value","typeGuard":"def is_native_int(value) -> bool:\n    return isinstance(value, int) and not isinstance(value, bool)","tryCatchPattern":"try:\n    config.getini(name)\nexcept Exception:\n    # convert to a bare TOML integer and reload","preventionTips":["Use bare unquoted integers in TOML.","Never substitute true/false for an int option.","Remember bool is an int subclass — the guard explicitly excludes it."],"tags":["config","toml","int","bool-vs-int","type-mismatch","pytest"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}