{"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":"exception","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/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/helpconfig.py#L185-L221","documentation":"Raised while rendering `pytest --help`/config help (in `showhelp`) for an ini option whose `help` text is None. Every ini option registered via `parser.addini(name, help=...)` must carry a help string; a None help makes the help formatter unable to render the option, so pytest raises TypeError naming the offending option.","triggerScenarios":"A plugin/conftest calls `parser.addini(\"my_opt\", default=..., help=None)` or omits help, and the user runs `pytest --help`. The error names the option key.","commonSituations":"Plugin authors forgetting the help argument. Third-party plugins with incomplete addini calls. A conftest.py registering a custom ini key for project config.","solutions":["Pass a non-None help string to addini: `parser.addini(\"my_opt\", help=\"Description here\", default=...)`.","Update the offending plugin to the latest version where help text was added.","If you control the conftest, audit every `addini` call for a help argument."],"exampleFix":"// before\ndef pytest_addoption(parser):\n    parser.addini(\"my_opt\", default=\"x\")  # help=None\n// after\ndef pytest_addoption(parser):\n    parser.addini(\"my_opt\", help=\"Controls my thing\", default=\"x\")","handlingStrategy":"validation","validationCode":"def safe_addini(parser, name, help=None, **kw):\n    if help is None:\n        raise TypeError(f\"help argument cannot be None for {name}\")\n    parser.addini(name, help=help, **kw)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a non-empty help string to parser.addini.","Audit plugin addini calls during code review.","Update third-party plugins that omit help text."],"tags":["pytest","config","plugin","help","addini","typeerror"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}