Skip to content

Conversation

@john0isaac
Copy link
Contributor

Ensures boolean flag options correctly determine their default values when not explicitly set.
Adds tests to validate proper behavior for various flag configurations, improving reliability.

Fixes #2897

Ensures boolean flag options correctly determine their default values when not explicitly set.
Adds tests to validate proper behavior for various flag configurations, improving reliability.

Fixes pallets#2897
@john0isaac john0isaac changed the base branch from main to stable May 13, 2025 19:23
@john0isaac
Copy link
Contributor Author

john0isaac commented May 13, 2025

Although it's the same issue this won't fix #2894 as it's talking about type=str, the fix would be to revert back the changed lines completely but it will break the introduced behaviour in #2829

Maybe we can revert the lines back but with flag_value = not bool(self.default) transforming it to a boolean first before negating it? this will fix both issues but it will still change the behaviour introduced in #2829 but it will no longer raise ValueError for numpy.ndarray or astropy.units.Quantity as they will be casted as a boolean.

Please let me know what you prefer.

@Rowlando13 Rowlando13 deleted the branch pallets:stable May 17, 2025 06:35
@Rowlando13 Rowlando13 closed this May 17, 2025
@davidism davidism reopened this May 17, 2025
@davidism
Copy link
Member

Thanks for working on this. A contributor at the PyCon sprint ended up looking into this more and fixing it in a way we think is a little more correct in some cases, see #2930.

@davidism davidism closed this May 20, 2025
@john0isaac john0isaac deleted the fix-default-value-bool-flag branch May 20, 2025 20:24
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Boolean flags are always False

3 participants