Repository navigation
Accept numeric strings for verbosity options in TOML again, with a deprecation - #15296
Merged
Merged
Conversation
#15153 registered the verbosity_* options as `int | Literal["auto"]`. In native TOML mode neither member accepts a numeric string, so `verbosity_assertions = "2"` raised a UsageError, although the changelog promised strings keep working. Register them as `int | str` (like tmp_path_retention_count) and validate the string in `Config.get_verbosity`, which now raises a UsageError naming the option for values that are neither an int nor "auto". Fixes #15290. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Native TOML has real integers, so `verbosity_assertions = "2"` is only kept working for backward compatibility. Issue a PytestRemovedIn10Warning once per option when get_verbosity has to convert such a string, and document the deprecation. ini files are unaffected: the int member of the option type converts their values before get_verbosity sees them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same as the verbosity options: TOML has real integers, so a string like "3" only stays accepted for backward compatibility and now issues a PytestRemovedIn10Warning. The deprecation message and docs section are generalized to cover both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks done
bluetech
approved these changes
Oct 29, 2026
bluetech
left a comment
Member
There was a problem hiding this comment.
LGTM.
(I'm assuming that you checked and tmp_path_retention_count is the only other case that needs to be deprecated)
Backport to 9.2.x: 💚 backport PR created✅ Backport PR branch: Backported as #15339 🤖 @patchback |
3 tasks done
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.
Closes #15290.
#15153 made numeric strings like
verbosity_assertions = "2"a hard error in native TOML, with no deprecation period. With this PR they are accepted again, with a deprecation warning:The
verbosity_*options andtmp_path_retention_countaccept numeric strings in TOML again and issue onePytestRemovedIn10Warningper option. ini files are not affected.Values that are neither an int nor
"auto"raise aUsageErrorfromget_verbosity.The deprecation is documented in
deprecations.rst#toml-numeric-strings, and the PR adds bugfix and deprecation changelog entries.Tests
Changelog
AI agents credited in
Co-authored-bytrailers