You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Click 8.2.0 ignores the use of options defined with is_flag and type=str.
Of course, combining is_flag and type=str does not make sense, but it happened in one of our projects. Click before 8.2.0 ignored type=str and processed this as expected for is_flag.
Click 8.2.0 does not set a value for such an option.
I could trace this change to PR #2829 - If I install click 8.2.0 and manually undo the change in core.py that is done by that PR, it works as before.
The "undo" of PR #2829 has the following changes in core.py, starting at line 2613:
# Undo PR 2829: Added the following two lines
if flag_value is None:
flag_value = not self.default
self.type: types.ParamType
if is_flag and type is None:
# Undo PR 2829: Removed the following two lines
# if flag_value is None:
# flag_value = not self.default
# Re-guess the type from the flag value instead of the
# default.
self.type = types.convert_type(None, flag_value)
Environment:
Python version: 3.12.7 on macOS (it happens on all Python versions supported by click 8.2.0, but not on all OSs)
The fix for projects using click is of course to remove type when is_flag is used.
Even though this is basically an incorrect use of click, I would expect click to surface this as an incorrect use, instead of silently not setting a value for the option.
Click 8.2.0 ignores the use of options defined with
is_flagandtype=str.Of course, combining
is_flagandtype=strdoes not make sense, but it happened in one of our projects. Click before 8.2.0 ignoredtype=strand processed this as expected foris_flag.Click 8.2.0 does not set a value for such an option.
I could trace this change to PR #2829 - If I install click 8.2.0 and manually undo the change in
core.pythat is done by that PR, it works as before.To reproduce:
main.pywith:The "undo" of PR #2829 has the following changes in
core.py, starting at line 2613:Environment:
Based on our CI test run, the issue happens only on macOS and Windows, but not on Ubuntu:
https://github.com/zhmcclient/zhmccli/actions/runs/14949544297. I did not investigate why it does not happen on Ubuntu.
The fix for projects using click is of course to remove
typewhenis_flagis used.Even though this is basically an incorrect use of click, I would expect click to surface this as an incorrect use, instead of silently not setting a value for the option.