From d7cf2b3a69914283b3b10d95cdcc41954ae898ff Mon Sep 17 00:00:00 2001 From: Raphael Nestler Date: Tue, 20 Dec 2022 11:51:20 +0100 Subject: [PATCH 1/2] Enable no_implicit_optional mypy check and fix issue --- setup.cfg | 2 +- src/flask_caching/utils.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index afe6b815..65fd7aa3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -91,7 +91,7 @@ disallow_subclassing_any = true # disallow_incomplete_defs = true # check_untyped_defs = true disallow_untyped_decorators = true -# no_implicit_optional = true +no_implicit_optional = true warn_redundant_casts = true warn_unused_ignores = true # warn_return_any = true diff --git a/src/flask_caching/utils.py b/src/flask_caching/utils.py index d499098c..b853a8b6 100644 --- a/src/flask_caching/utils.py +++ b/src/flask_caching/utils.py @@ -2,6 +2,7 @@ import string from typing import Callable from typing import List +from typing import Optional TEMPLATE_FRAGMENT_KEY_TEMPLATE = "_template_fragment_cache_%s%s" # Used to remove control characters and whitespace from cache keys. @@ -102,7 +103,9 @@ def function_namespace(f, args=None): return ns, ins -def make_template_fragment_key(fragment_name: str, vary_on: List[str] = None) -> str: +def make_template_fragment_key( + fragment_name: str, vary_on: Optional[List[str]] = None +) -> str: """Make a cache key for a specific fragment name.""" if vary_on: fragment_name = "%s_" % fragment_name From af3cf922812de5ded0b986c0de7dabc4d99bfe78 Mon Sep 17 00:00:00 2001 From: Raphael Nestler Date: Tue, 20 Dec 2022 12:11:29 +0100 Subject: [PATCH 2/2] Document typing fix in CHANGES.rst --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 2f1759bf..687f6e80 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Changelog ========= +Unreleased +---------- + +- fix type signature in ``flask_caching.utils.make_template_fragment_key``. :pr:`430` + Version 2.0.2 -------------