Repository navigation
🐛 fix(unset): let skip-if-set keep the variable - #337
Merged
Merged
Conversation
An entry marked both unset and skip-if-set removed a variable that was already set, because the unset branch ran first. The README says skip_if_set leaves an existing variable unchanged and that flags combine in any order. Reported by Anthropic's OSS Scanner: ANT-2026-1TT2R7UY. Fixes pytest-dev#329
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.
_apply_entriestestedentry.unsetbeforeentry.skip_if_set(old lines), so an entry marked both ways removed a variable that was already set. WithKEEPexported, the INI entryD:U:KEEPor the TOML entryKEEP = { unset = true, skip_if_set = true }started the session withoutKEEP, while the README saysskip_if_setleaves an existing variable unchanged and that flags combine in any order. 🐛 After this PR the existing variable is kept. Fixes #329.Unset ran before the skip check
The skip check sat in an
elifbehind the unset branch, so it was reached only by entries that were not unset, and neither parser rejects the combination._apply_entriesnow checks skip-if-set first, then unset, then the assignment.Behavior changes
An entry that combines
D:withU:, orskip_if_setwithunset, leaves an existing variable in place, and--pytest-env-verbosereports it asSKIP. When the variable is not set, the entry has nothing to remove and the result is the same as before. A configuration that used the combination to strip a variable has to dropD:orskip_if_set. Entries with only one of the two flags behave as before.Reported by Anthropic's OSS Scanner: ANT-2026-1TT2R7UY.