From 3ea57399bf8595dada51f68bd1aeff90a31c6a35 Mon Sep 17 00:00:00 2001 From: Gianluca Gippetto Date: Mon, 24 May 2021 16:49:32 +0200 Subject: [PATCH] Fix is_bool_flag being set to True even if is_flag is False Fixes #1925. --- CHANGES.rst | 3 +++ src/click/core.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index e647915d2..0832cf455 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ Version 8.0.2 Unreleased +- Fix ``is_bool_flag`` being always set to ``True`` for boolean options, + even when ``is_flag`` is ``False``. :issue:`1925` + Version 8.0.1 ------------- diff --git a/src/click/core.py b/src/click/core.py index 8f04ff421..3a4614bd0 100644 --- a/src/click/core.py +++ b/src/click/core.py @@ -2528,7 +2528,7 @@ def __init__( self.type = types.convert_type(None, flag_value) self.is_flag: bool = is_flag - self.is_bool_flag = isinstance(self.type, types.BoolParamType) + self.is_bool_flag = is_flag and isinstance(self.type, types.BoolParamType) self.flag_value: t.Any = flag_value # Counting