Repository navigation
verbosity_assertions needs a string in TOML, docs show int #13904
Copy link
Copy link
Labels
topic: configrelated to config handling, argument parsing and config filerelated to config handling, argument parsing and config filetype: docsdocumentation improvement, missing or needing clarificationdocumentation improvement, missing or needing clarification
Description
Using 8.4.2 I had this in pyproject.toml:
[tool.pytest.ini_options]
verbosity_assertions = 5With 9.0.0, I changed to:
[tool.pytest]
verbosity_assertions = 5But this causes an error:
self = <_pytest.config.Config object at 0x104f63220>, name = 'verbosity_assertions', canonical_name = 'verbosity_assertions', type = 'string', value = 5
default = 'auto'
def _getini_toml(
self,
name: str,
canonical_name: str,
type: str,
value: object,
default: Any,
):
"""Handle TOML config values with strict type validation and no coercion.
In TOML mode, values already have native types from TOML parsing.
We validate types match expectations exactly, including list items.
"""
value_type = builtins.type(value).__name__
if type == "paths":
# Expect a list of strings.
if not isinstance(value, list):
raise TypeError(
f"{self.inipath}: config option '{name}' expects a list for type 'paths', "
f"got {value_type}: {value!r}"
)
for i, item in enumerate(value):
if not isinstance(item, str):
item_type = builtins.type(item).__name__
raise TypeError(
f"{self.inipath}: config option '{name}' expects a list of strings, "
f"but item at index {i} is {item_type}: {item!r}"
)
dp = (
self.inipath.parent
if self.inipath is not None
else self.invocation_params.dir
)
return [dp / x for x in value]
elif type in {"args", "linelist"}:
# Expect a list of strings.
if not isinstance(value, list):
raise TypeError(
f"{self.inipath}: config option '{name}' expects a list for type '{type}', "
f"got {value_type}: {value!r}"
)
for i, item in enumerate(value):
if not isinstance(item, str):
item_type = builtins.type(item).__name__
raise TypeError(
f"{self.inipath}: config option '{name}' expects a list of strings, "
f"but item at index {i} is {item_type}: {item!r}"
)
return list(value)
elif type == "bool":
# Expect a boolean.
if not isinstance(value, bool):
raise TypeError(
f"{self.inipath}: config option '{name}' expects a bool, "
f"got {value_type}: {value!r}"
)
return value
elif type == "int":
# Expect an integer (but not bool, which is a subclass of int).
if not isinstance(value, int) or isinstance(value, bool):
raise TypeError(
f"{self.inipath}: config option '{name}' expects an int, "
f"got {value_type}: {value!r}"
)
return value
elif type == "float":
# Expect a float or integer only.
if not isinstance(value, (float, int)) or isinstance(value, bool):
raise TypeError(
f"{self.inipath}: config option '{name}' expects a float, "
f"got {value_type}: {value!r}"
)
return value
elif type == "string":
# Expect a string.
if not isinstance(value, str):
> raise TypeError(
f"{self.inipath}: config option '{name}' expects a string, "
f"got {value_type}: {value!r}"
)
E TypeError: /Users/ned/coverage/trunk/pyproject.toml: config option 'verbosity_assertions' expects a string, got int: 5
/usr/local/virtualenvs/coverage/lib/python3.10/site-packages/_pytest/config/__init__.py:1816: TypeError
This fixes it, but the docs say it should be an int:
[tool.pytest]
verbosity_assertions = "5"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
topic: configrelated to config handling, argument parsing and config filerelated to config handling, argument parsing and config filetype: docsdocumentation improvement, missing or needing clarificationdocumentation improvement, missing or needing clarification
Activity
bluetech commentedon Nov 9, 2025
Thanks, we'll fix it.
doc: fix toml type of verbosity options in API reference
doc: fix toml type of verbosity options in API reference
remimd commentedon Nov 12, 2025
Same issue for
tmp_path_retention_countbluetech commentedon Nov 13, 2025
Thanks for the report @remimd.
This one looks like a mistake, in this case there is no reason for it to be an string rather than an int.
I wonder if we can still fix it (change to int) or if it's too late. Maybe it's possible to make both int and str work using some hack. I will check.
doc: fix TOML example for `tmp_path_retention_count`, it's a string
chore(deps): update pytest (major)
Merge branch 'renovate/pytest-9.x' into 'main'
🔒️ Update dependency pytest to v9 [SECURITY] (#16)
[SECURITY] Update dependency pytest to v9 [SECURITY] (#2)
Update dependency pytest to v9 (#35)