From 5a6be7846c0e6c119673153fc7e8e6e0053c0eaf Mon Sep 17 00:00:00 2001 From: Raphael Nestler Date: Sun, 8 Oct 2023 00:00:44 +0200 Subject: [PATCH] Enable no_implicit_optional mypy check and fix issue (#430) * Enable no_implicit_optional mypy check and fix issue * Document typing fix in CHANGES.rst --------- Co-authored-by: Gabriel Fioravante --- CHANGES.rst | 6 ++++++ setup.cfg | 2 +- src/flask_caching/utils.py | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 389ae9e7..4ed9497f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,8 +1,13 @@ Changelog ========= +Unreleased +---------- + +- fix type signature in ``flask_caching.utils.make_template_fragment_key``. :pr:`430` - Added docs and example for make_cache_key + Version 2.0.2 ------------- @@ -12,6 +17,7 @@ Released 2023-01-12 - migrate ``flask_caching.backends.RedisCluster`` dependency from redis-py-cluster to redis-py - bug fix: make the ``make_cache_key`` attributed of decorated view functions writeable. :pr:`431`, issue `#97` + Version 2.0.1 ------------- 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