Skip to content

fix: allow int type for truncation_limit_lines and truncation_limit_chars in TOML configs#14689

Closed
muhamedfazalps wants to merge 1 commit into
pytest-dev:mainfrom
muhamedfazalps:fix/truncation-limit-int-type
Closed

fix: allow int type for truncation_limit_lines and truncation_limit_chars in TOML configs#14689
muhamedfazalps wants to merge 1 commit into
pytest-dev:mainfrom
muhamedfazalps:fix/truncation-limit-int-type

Conversation

@muhamedfazalps

Copy link
Copy Markdown

These config options were parsed as strings, causing a TypeError when users specified integer values in pyproject.toml or pytest.toml. Using type='int' allows both string and integer values.

Fixes #14675

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this. I have a feeling that we can also avoid a bunch of int call and handling both int and string (or "no restriction" being encoded as either 0 or None), downstream later. We still need to take into account the public API that should keep working for string though. I didn't look too much into it, let me know if the scope become too big and necessitate another PR.

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

Also we'd need a changelog for that I think.

@muhamedfazalps muhamedfazalps force-pushed the fix/truncation-limit-int-type branch from 9af050a to 69302f5 Compare July 8, 2026 13:11
@muhamedfazalps

Copy link
Copy Markdown
Author

I have added a changelog entry as requested. Please review again.

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jul 8, 2026
@muhamedfazalps

Copy link
Copy Markdown
Author

@Pierre-Sassoulas Thank you for the thorough review. I agree the scope here is limited - the fix is intentionally minimal (just adding the changelog entry for the int type support). If a larger refactoring of the truncation config handling is needed, that would indeed be a separate PR. Happy to adjust if you have specific changes in mind.

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

The actual changes disapeared and there's only the changelog now afaics

@muhamedfazalps

Copy link
Copy Markdown
Author

Thanks for the review @Pierre-Sassoulas! You're right — we can handle both int and string downstream to avoid repeated int() calls. I'll expand the scope to:

  1. Keep the type='int' in the addoption calls (current fix) so TOML int values work
  2. Add downstream handling to accept both int and string consistently
  3. Ensure the public API keeps working for string values

I'll update the PR with the broader fix. Let me know if the scope gets too big and needs splitting.

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

Let's do this.

@The-Compiler

Copy link
Copy Markdown
Member
image image

@Pierre-Sassoulas you're most likely not talking to a human there. Unless you insist on spending more time on this, I'd propose nuking the clanker 😉

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

Closing in favor of #14692

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

truncation_limit_lines and truncation_limit_chars should accept integer values in .toml configs

3 participants