Fix negative flag (flag_value=False) ignoring default=True#3308
Closed
vigneshakaviki wants to merge 2 commits intopallets:mainfrom
Closed
Fix negative flag (flag_value=False) ignoring default=True#3308vigneshakaviki wants to merge 2 commits intopallets:mainfrom
vigneshakaviki wants to merge 2 commits intopallets:mainfrom
Conversation
A flag option with flag_value=False (a negative flag) and default=True was incorrectly returning False when the flag was not passed. get_default() was unconditionally converting default=True to flag_value for all flag types, including negative flags where flag_value=False. This caused default=True to be silently overridden with False. Fix the condition to skip the conversion when flag_value is explicitly False, preserving default=True as the actual default for negative flags. Fixes pallets#3111
Author
|
Closing this in favour of the existing fix in #3239 by @kdeldycke, which covers this case more comprehensively. Thanks! |
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.
Fixes #3111
A negative flag (
flag_value=False,default=True) was incorrectly returningFalsewhen the flag was not passed.Root cause:
Option.get_default()unconditionally converteddefault=Truetoflag_valuefor all flag types. For negative flags whereflag_value=False, this silently overrode the explicit default.Fix: Skip the conversion when
flag_value is False:This preserves legacy behaviour for all other flag types while correctly keeping
default=Truefor negative flags.Tests: Added
test_negative_flag_with_true_defaultregression test; updated existing parametrized cases that encoded the buggy behaviour. Full suite: 1386 passed, 21 skipped.