{"record":{"id":"b906fb7b9c89efd6","repo":"pytest-dev/pytest","slug":"expected-an-int-string-for-option-name-of-type-i","errorCode":null,"errorMessage":"Expected an int string for option {name} of type integer, but got: {value!r}","messagePattern":"Expected an int string for option (.+?) of type integer, but got: (.+?)","errorType":"exception","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":1931,"sourceCode":"                if self.inipath is not None\n                else self.invocation_params.dir\n            )\n            input_values = shlex.split(value) if isinstance(value, str) else value\n            return [dp / x for x in input_values]\n        elif type == \"args\":\n            return shlex.split(value) if isinstance(value, str) else value\n        elif type == \"linelist\":\n            if isinstance(value, str):\n                return [t for t in map(lambda x: x.strip(), value.split(\"\\n\")) if t]\n            else:\n                return value\n        elif type == \"bool\":\n            return _strtobool(str(value).strip())\n        elif type == \"string\":\n            return value\n        elif type == \"int\":\n            if not isinstance(value, str):\n                raise TypeError(\n                    f\"Expected an int string for option {name} of type integer, but got: {value!r}\"\n                ) from None\n            return int(value)\n        elif type == \"float\":\n            if not isinstance(value, str):\n                raise TypeError(\n                    f\"Expected a float string for option {name} of type float, but got: {value!r}\"\n                ) from None\n            return float(value)\n        else:\n            return self._getini_unknown_type(name, type, value)\n\n    def _getini_toml(\n        self,\n        name: str,\n        canonical_name: str,\n        type: str,\n        value: object,","sourceCodeStart":1913,"sourceCodeEnd":1949,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/__init__.py#L1913-L1949","documentation":"Raised by _getini_ini() at config/__init__.py:1927-1930 when an ini option of type 'int' receives a value that is not a string. The function comment at capture.py:1891-1895 states INI-mode values are always str or list[str], so this defensive TypeError is effectively unreachable through normal pytest usage - it guards against bugs in pytest itself or in code that monkeypatches the value pipeline. The outer handler at config/__init__.py:1847-1848 converts it to UsageError.","triggerScenarios":"Only reachable if a non-string value reaches _getini_ini for an int-typed option - e.g. a plugin monkeypatching _inicfg to inject a non-string, or an internal pytest bug. capture.py:1928 checks `not isinstance(value, str)` and raises.","commonSituations":"Effectively does not occur in normal pytest runs. If you see it, suspect a plugin that bypasses the normal config loading or a test harness that injects values directly into Config._inicfg.","solutions":["Confirm the option is declared with type='int' (or int) and you are not bypassing pytest's config loading","If you have a custom plugin that writes to Config._inicfg, ensure values are strings in INI mode","Report upstream if the value comes from a standard pyproject.toml/pytest.ini load - this branch should be unreachable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# In INI mode ensure int-typed values are strings\nif not isinstance(value, str):\n    value = str(value)","typeGuard":"def is_int_string(v) -> bool:\n    return isinstance(v, str) and v.lstrip('-').isdigit()","tryCatchPattern":"from _pytest.config import UsageError\ntry:\n    val = config.getini('opt')\nexcept UsageError as e:\n    print(f'Internal: non-string reached int branch: {e}')","preventionTips":["Do not inject non-string values into Config._inicfg directly","If monkeypatching in tests, mirror pytest's str-only contract","Treat this error as a bug report candidate - it should not occur via normal config files"],"tags":["config","ini","int","defensive","internal"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}