diff --git a/src/click/core.py b/src/click/core.py index 1c1a46714..e783729c7 100644 --- a/src/click/core.py +++ b/src/click/core.py @@ -2597,11 +2597,10 @@ def __init__( else: self.default = False - if flag_value is None: - flag_value = not self.default - self.type: types.ParamType if is_flag and type is None: + 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) diff --git a/tests/test_info_dict.py b/tests/test_info_dict.py index 79d39ee51..11b670311 100644 --- a/tests/test_info_dict.py +++ b/tests/test_info_dict.py @@ -58,7 +58,7 @@ "help": None, "prompt": None, "is_flag": False, - "flag_value": False, + "flag_value": None, "count": False, "hidden": False, },