{"record":{"id":"f03b17a0ba21d2a1","repo":"pytest-dev/pytest","slug":"help-argument-cannot-be-none-for-name","errorCode":null,"errorMessage":"help argument cannot be None for {name}","messagePattern":"help argument cannot be None for (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/_pytest/helpconfig.py","lineNumber":203,"sourceCode":"        \"terminalreporter\"\n    )\n    assert reporter is not None\n    tw = reporter._tw\n    tw.write(config._parser.optparser.format_help())\n    tw.line()\n    tw.line(\n        \"[pytest] configuration options in the first \"\n        \"pytest.toml|pytest.ini|tox.ini|setup.cfg|pyproject.toml file found:\"\n    )\n    tw.line()\n\n    columns = tw.fullwidth  # costly call\n    indent_len = 24  # based on argparse's max_help_position=24\n    indent = \" \" * indent_len\n    for name in config._parser._inidict:\n        help, type, _default = config._parser._inidict[name]\n        if help is None:\n            raise TypeError(f\"help argument cannot be None for {name}\")\n        spec = f\"{name} ({_ini_type_repr(type)}):\"\n        tw.write(f\"  {spec}\")\n        spec_len = len(spec)\n        if spec_len > (indent_len - 3):\n            # Display help starting at a new line.\n            tw.line()\n            helplines = textwrap.wrap(\n                help,\n                columns,\n                initial_indent=indent,\n                subsequent_indent=indent,\n                break_on_hyphens=False,\n            )\n\n            for line in helplines:\n                tw.line(line)\n        else:\n            # Display help starting after the spec, following lines indented.","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/helpconfig.py#L185-L221","documentation":"helpconfig.py:203 raises TypeError('help argument cannot be None for {name}') when iterating _inidict during 'pytest --help'/'--version'-style ini option rendering and an ini option was registered with help=None. Every ini option registered via parser.addini must supply a non-None help string so the help output can format it.","triggerScenarios":"A plugin/conftest calling config.addini('myopt', help=None, ...); an extension registering a custom ini key without a description string; then the user runs 'pytest --help' or 'pytest -p <plugin>'.","commonSituations":"Plugin authors forgetting the help argument; copy-pasting addini calls and dropping the help text; upgrading pytest which tightened this validation.","solutions":["Find every addini/register call for the named option and provide a non-None help string.","If the option is from a third-party plugin, upgrade it or open an issue; pin pytest if a regression.","Audit conftest.py for pytest_addoption/addini calls missing help."],"exampleFix":"// before\nparser.addini('my_flag', default=False, type='bool')\n// after\nparser.addini('my_flag', help='enable my custom behavior', default=False, type='bool')","handlingStrategy":"validation","validationCode":"# In pytest_addoption, validate help is not None\ndef addini_checked(parser, name, help, **kw):\n    assert help is not None, f'help required for ini option {name!r}'\n    parser.addini(name, help=help, **kw)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a non-None help string to parser.addini.","Add a CI test that runs 'pytest --help' to surface missing help.","Code-review plugin addini calls."],"tags":["pytest","config","ini","help","plugin"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}