Allow int for truncation_limit_lines and truncation_limit_chars in TOML#14692
Open
Pierre-Sassoulas wants to merge 2 commits into
Open
Allow int for truncation_limit_lines and truncation_limit_chars in TOML#14692Pierre-Sassoulas wants to merge 2 commits into
truncation_limit_lines and truncation_limit_chars in TOML#14692Pierre-Sassoulas wants to merge 2 commits into
Conversation
The truncation_limit_lines and truncation_limit_chars ini options were registered without a type, defaulting to 'string'. In native TOML config ([tool.pytest]), integer values then raised a TypeError instead of being accepted, despite being numeric limits. Register both options with type='int' so TOML integer values are accepted (INI string values keep working via the existing int coercion). Fixes pytest-dev#14675
With truncation_limit_lines/chars registered as type='int', getini returns int | None directly. TruncationBudget.from_config now owns reading those ini options and resolving None (option unset) to the DEFAULT_MAX_* limit, which lives next to the class. The _get_truncation_parameters helper is inlined into truncate_if_required, which short-circuits on verbosity/CI before reading the options at all. String values from INI files and -o overrides are still coerced centrally by the config layer. None means 'use default'; 0 means 'unbounded'.
bluetech
requested changes
Jul 9, 2026
bluetech
left a comment
Member
There was a problem hiding this comment.
We can't just change to int, as that would be a breaking change. We need to allow both, unfortunately.
I will write in the issue how I think we can do it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The truncation_limit_lines and truncation_limit_chars ini options were registered without a type, defaulting to 'string'. In native TOML config ([tool.pytest]), integer values then raised a TypeError instead of being accepted, despite being numeric limits.
Register both options with type='int' so TOML integer values are accepted (INI string values keep working via the existing int coercion).
Basically #14689 but without unwanted AI to human conversation.
Fixes #14675