Repository navigation
truncation_limit_lines and truncation_limit_chars should accept integer values in .toml configs #14675
Description
Activity
- addedtype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
on Jul 4, 2026 Due to backward compat, we need to keep supporting string. This means that if we want to allow int, we need to support both.
@RonnyPfannschmidt had a proposal/draft PR to parse the config based on a pydantic-style class with fields and type annotations. I can't find it quickly right now..
I had a simpler more short-term idea, that in addition to the current
parser.addini(..., type="int")style, we also allow passing a limited set of type expressions totype, so in the case of this issue we could writetype=int | str. It seems like a mostly straightforward enhancement to me, though maybe the devil is in the details.Reacted by Bruno OliveiraForgot to mention regarding the type expression idea. There are some config keys (mostly logging ones IIRC) which mostly take numeric values but are currently str because there is some extra possible string value. For these cases it would be nice to support
int Literal["empty"]forms. Also, for typing this the newtyping.TypeFormmight come in handy (it's new in Python 3.15 but can be imported fromtyping_extensionson older versions).- added 14 commits that reference this issue
on Jul 10, 2026
I think in
pyproject.tomlandpytest.toml, pytest should accept integer values rather than strings. Currently it's the other way around - I get a type error when using integers and have to use strings.or
Steps to reproduce:
pyproject.tomladd:Current behavior:
Expected behavior:
Environment:
pytest version:
9.1.1, Windows 11