Repository navigation
Accept native TOML types for the remaining built-in ini options - #15153
Merged
Merged
Conversation
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
Pierre-Sassoulas
approved these changes
Oct 9, 2026
Pierre-Sassoulas
left a comment
Member
There was a problem hiding this comment.
Satisfying cleanup !
RonnyPfannschmidt
marked this pull request as ready for review
October 9, 2026 12:28
RonnyPfannschmidt
enabled auto-merge
October 9, 2026 12:29
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.
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 = 10orlog_auto_indent = truefailed 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 unknownparametrize_long_str_id_strategywas 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
UsageErrorwhen the option is read.verbosity_assertions,verbosity_test_cases,verbosity_subtestsint | Literal["auto"]tmp_path_retention_countint | str(default is now3)log_level,log_cli_level,log_file_levelint | strlog_auto_indentint | bool | strlog_file_modeLiteral["w", "a"]parametrize_long_str_id_strategyLiteralchoicesHow: these options now use the
addini(type=...)expressions from #14751 and #14791.get_log_level_for_settingnow handles int levels directly. An int0(NOTSET) still counts as set, matching the old"0"string. Theint | bool | strorder forlog_auto_indentkeeps ini"1"meaning one space, notTrue.Compat note: because union members are tried in order,
getini()now returnsintfor ini-file values likeverbosity_assertions = 2orlog_level = 10, where it used to return astr. This is the same trade-off #14954 made formax_warnings. Callers in pytest already convert withint(). A third-party plugin that callsgetini()on these options and expects astrwould see the change.Docs: the "must be quoted in TOML" notes are removed. The TOML
minversion = 3.0example is now quoted, because a float is rejected there and would turn8.10into8.1. Copy-pastedlog_cli_levellines in thelog_levelandlog_file_levelexamples are fixed, and the--helpdump is refreshed (it also had a stalefaulthandler_timeout).Co-authored-bycommit trailers.changelogdirectory.🤖 Generated with Claude Code
https://claude.ai/code/session_01KnFJBdcVQB59PKYw3q1w7X
Generated by Claude Code