Only try to set flag_value if is_flag is true by lpsinger · Pull Request #2829 · pallets/click
This statement:
flag_value = not self.default
requires the class to have a working `__bool__` method. However,
there are some classes that explicitly disable this method:
- [`numpy.ndarray`](https://numpy.org/doc/stable/reference/arrays.ndarray.html)
raises `ValueError: The truth value of an array with more than
one element is ambiguous. Use a.any() or a.all()`
- [`astropy.units.Quantity`](https://docs.astropy.org/en/stable/api/astropy.units.Quantity.html)
raises `ValueError: Quantity truthiness is ambiguous, especially
for logarithmic units and temperatures. Use explicit comparisons.`
Move this statement so that it is only executed if `is_flag` is
true.
github-actions
bot
locked as resolved and limited conversation to collaborators
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