Skip to content

Accept native TOML types for the remaining built-in ini options - #15153

Merged
RonnyPfannschmidt merged 2 commits into
mainfrom
claude/project-thread-ts7rab
Oct 9, 2026
Merged

RonnyPfannschmidt merged 2 commits into
mainfrom
claude/project-thread-ts7rab

Conversation

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

Requested by Ronny · project thread

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

Follow-up to #14692, #14954 and #15133. This finishes the job for every built-in option whose value is naturally a number, a boolean or a fixed choice.

Before: in a native pytest.toml / [tool.pytest] config, verbosity_assertions = 2, tmp_path_retention_count = 3, log_level = 10 or log_auto_indent = true failed with "expects a string, got int/bool", and the docs told users to quote them. log_file_mode = "x" crashed with an INTERNALERROR, and an unknown parametrize_long_str_id_strategy was only caught when a long id was generated.

After: these values are accepted unquoted. Quoted strings and ini files keep working. Invalid choices are reported as a UsageError when the option is read.

option new type
verbosity_assertions, verbosity_test_cases, verbosity_subtests int | Literal["auto"]
tmp_path_retention_count int | str (default is now 3)
log_level, log_cli_level, log_file_level int | str
log_auto_indent int | bool | str
log_file_mode Literal["w", "a"]
parametrize_long_str_id_strategy its Literal choices

How: these options now use the addini(type=...) expressions from #14751 and #14791. get_log_level_for_setting now handles int levels directly. An int 0 (NOTSET) still counts as set, matching the old "0" string. The int | bool | str order for log_auto_indent keeps ini "1" meaning one space, not True.

Compat note: because union members are tried in order, getini() now returns int for ini-file values like verbosity_assertions = 2 or log_level = 10, where it used to return a str. This is the same trade-off #14954 made for max_warnings. Callers in pytest already convert with int(). A third-party plugin that calls getini() on these options and expects a str would see the change.

Docs: the "must be quoted in TOML" notes are removed. The TOML minversion = 3.0 example is now quoted, because a float is rejected there and would turn 8.10 into 8.1. Copy-pasted log_cli_level lines in the log_level and log_file_level examples are fixed, and the --help dump is refreshed (it also had a stale faulthandler_timeout).

  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits.
  • If AI agents were used, they are credited in Co-authored-by commit trailers.
  • Create a new changelog file in the changelog directory.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KnFJBdcVQB59PKYw3q1w7X


Generated by Claude Code

Ronny Pfannschmidt and others added 2 commits October 9, 2026 12:04
Follow-up to #14692, #14954 and #15133: the remaining options whose
values are naturally numbers or booleans were still registered as plain
strings, so native TOML configs had to quote them.

- verbosity_assertions, verbosity_test_cases, verbosity_subtests:
  int | Literal["auto"]
- tmp_path_retention_count: int | str
- log_level, log_cli_level, log_file_level: int | str; int levels are
  now handled directly and an int 0 (NOTSET) still counts as set
- log_auto_indent: int | bool | str
- log_file_mode: Literal["w", "a"] (an invalid value was an INTERNALERROR)
- parametrize_long_str_id_strategy: its Literal choices

The reference docs drop the "must be quoted in TOML" notes, fix the
minversion TOML example (a float there is rejected), fix copy-pasted
log_cli_level examples, and refresh the --help dump.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KnFJBdcVQB59PKYw3q1w7X
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KnFJBdcVQB59PKYw3q1w7X
@RonnyPfannschmidt RonnyPfannschmidt self-assigned this Oct 9, 2026
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 9, 2026

@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.

Satisfying cleanup !

@RonnyPfannschmidt
RonnyPfannschmidt marked this pull request as ready for review October 9, 2026 12:28
@RonnyPfannschmidt
RonnyPfannschmidt merged commit e4f7f17 into main Oct 9, 2026
68 checks passed
@RonnyPfannschmidt
RonnyPfannschmidt deleted the claude/project-thread-ts7rab branch October 9, 2026 12:46
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.

2 participants