From 42b3211e0afb034fbac0ecf7b6e127c494b2ec64 Mon Sep 17 00:00:00 2001 From: 40gilad <40gilad.shenkar@gmail.com> Date: Tue, 20 Aug 2024 14:05:48 +0300 Subject: [PATCH] refactor hard coded false attributes in get_debug_flag() and get_load_dotenv() --- src/flask/helpers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/flask/helpers.py b/src/flask/helpers.py index 00abe046..4d43954b 100644 --- a/src/flask/helpers.py +++ b/src/flask/helpers.py @@ -18,6 +18,7 @@ from .globals import current_app from .globals import request from .globals import request_ctx from .globals import session +from .globals import _false_attributes from .signals import message_flashed if t.TYPE_CHECKING: # pragma: no cover @@ -29,7 +30,7 @@ def get_debug_flag() -> bool: :envvar:`FLASK_DEBUG` environment variable. The default is ``False``. """ val = os.environ.get("FLASK_DEBUG") - return bool(val and val.lower() not in {"0", "false", "no"}) + return bool(val and val.lower() not in _false_attributes) def get_load_dotenv(default: bool = True) -> bool: @@ -44,7 +45,7 @@ def get_load_dotenv(default: bool = True) -> bool: if not val: return default - return val.lower() in ("0", "false", "no") + return val.lower() in _false_attributes def stream_with_context(