Reconcile default value passing and default activation#3239
Open
kdeldycke wants to merge 1 commit intopallets:stablefrom
Open
Reconcile default value passing and default activation#3239kdeldycke wants to merge 1 commit intopallets:stablefrom
kdeldycke wants to merge 1 commit intopallets:stablefrom
Conversation
a61dcee to
22351f8
Compare
22351f8 to
41ed4bc
Compare
Collaborator
Author
|
Ah sorry I fuck-up jungling with all these PRs to rebase. This commit 6c4a77b shouldn't have been pushed to |
Collaborator
Author
|
Ok, juste revert |
1296a4c to
4af30ca
Compare
d5a6a46 to
30aca6b
Compare
Fix pallets#3111 Reintroduce a commit pushed by mistake in 6c4a77b and reverted in bb7be1f Refine tests introduced in 06847da for pallets#3030 Document the interaction between `default` and `flag_value`
30aca6b to
d34f72b
Compare
davidism
reviewed
Apr 9, 2026
| The `default` value is given to the underlying function as-is. So if you set `default=None`, the function receives `None`. Same for any other type. | ||
|
|
||
| Which means, in example above, this option: | ||
| But there is a special case for **non-boolean** flags: if a flag has a non-boolean `flag_value` (like a string or a class), then `default=True` is interpreted as *the flag should be activated by default*. The function receives the `flag_value`, not the Python `True`. |
davidism
reviewed
Apr 9, 2026
| .. versionchanged:: 8.3.3 | ||
| ``default=True`` is no longer substituted with ``flag_value`` for | ||
| boolean flags, fixing negative boolean flags like ``flag_value=False, | ||
| default=True``. :issue:`3111` |
Member
There was a problem hiding this comment.
Do not link to issues or PRs in docs
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.
This is an attempt to address #3111, and explore the consequences of reconciling the two meaning of the
defaultparameter:default=Truethen function getsTruedefault=Truethen function getsflag_valueA way to do that would be to consider
default=Trueas a sentinel (yes, you can call me the sentinel-guy), for non-boolean flags. We do it lazily in theget_defaultmethod to not interfere with class instanciation, which we implemented in #3225 to fix #3121.This has the side-effect of refining the test cases introduced in 06847da for #3030.