Skip to content

Commit

Permalink
Enable no_implicit_optional mypy check and fix issue (#430)
Browse files Browse the repository at this point in the history
* Enable no_implicit_optional mypy check and fix issue

* Document typing fix in CHANGES.rst

---------

Co-authored-by: Gabriel Fioravante <[email protected]>
  • Loading branch information
rnestler and northernSage authored Oct 7, 2023
1 parent fd8068c commit 5a6be78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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
-------------

Expand All @@ -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
-------------

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/flask_caching/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5a6be78

Please sign in to comment.