pytest-dev/pytest · error · TypeError
help argument cannot be None for
Error message
help argument cannot be None for {name} What it means
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.
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.
Example fix
// before
parser.addini('my_flag', default=False, type='bool')
// after
parser.addini('my_flag', help='enable my custom behavior', default=False, type='bool') Defensive patterns
Strategy: validation
Validate before calling
# In pytest_addoption, validate help is not None
def addini_checked(parser, name, help, **kw):
assert help is not None, f'help required for ini option {name!r}'
parser.addini(name, help=help, **kw) Prevention
- 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.
When it happens
Trigger: 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>'.
Common situations: Plugin authors forgetting the help argument; copy-pasting addini calls and dropping the help text; upgrading pytest which tightened this validation.
Related errors
- unknown configuration type
- ' ' is not recognized as a logging level name for ' '…
- unknown configuration value
- alias conflicts with existing configuration option
- is already an alias of
AI-assisted analysis of pytest-dev/pytest@0d6fbdeffa (2026-08-11).
Data as JSON: /api/errors/f03b17a0ba21d2a1.
Report an issue: GitHub.
Appendix: source
Thrown at src/_pytest/helpconfig.py:203
"terminalreporter"
)
assert reporter is not None
tw = reporter._tw
tw.write(config._parser.optparser.format_help())
tw.line()
tw.line(
"[pytest] configuration options in the first "
"pytest.toml|pytest.ini|tox.ini|setup.cfg|pyproject.toml file found:"
)
tw.line()
columns = tw.fullwidth # costly call
indent_len = 24 # based on argparse's max_help_position=24
indent = " " * indent_len
for name in config._parser._inidict:
help, type, _default = config._parser._inidict[name]
if help is None:
raise TypeError(f"help argument cannot be None for {name}")
spec = f"{name} ({_ini_type_repr(type)}):"
tw.write(f" {spec}")
spec_len = len(spec)
if spec_len > (indent_len - 3):
# Display help starting at a new line.
tw.line()
helplines = textwrap.wrap(
help,
columns,
initial_indent=indent,
subsequent_indent=indent,
break_on_hyphens=False,
)
for line in helplines:
tw.line(line)
else:
# Display help starting after the spec, following lines indented.View on GitHub (pinned to 0d6fbdeffa)