fix config: add deprecation warning for non-string value in string-typed ini option - #14811
Open
EternalRights wants to merge 1 commit into
Open
fix config: add deprecation warning for non-string value in string-typed ini option#14811EternalRights wants to merge 1 commit into
EternalRights wants to merge 1 commit into
Conversation
…ped ini option _getini_ini returns the value as-is for type="string", unlike _getini_toml which validates with isinstance(value, str). In [tool.pytest.ini_options], make_scalar keeps TOML arrays as lists, so a list value reaches _getini_ini and gets returned without warning. "int" and "float" types already have the guard. Add a PytestRemovedIn10Warning for non-str values in _getini_ini's string branch. The value is still returned for now; in pytest 10 this will raise TypeError, matching _getini_toml. Closes pytest-dev#14808
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.
Ran into this while comparing _getini_toml and _getini_ini. The former validates with isinstance(value, str) for type="string", but _getini_ini just returns the value as-is. In [tool.pytest.ini_options], make_scalar keeps TOML arrays as lists, so a list reaches _getini_ini and gets returned without any warning. "int" and "float" types in _getini_ini already have the guard. "string" is the only scalar type missing it.
As Ronny pointed out, this needs a deprecation path rather than raising immediately, since addini(type=None) normalizes to "string" and many plugins rely on the implicit default.
The fix adds a PytestRemovedIn10Warning when _getini_ini sees a non-str value on a string-typed option. The value is still returned for backward compatibility. In pytest 10 this will become a TypeError, matching the _getini_toml path.
Closes #14808