Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug to make memorize no longer loss type hint #277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions diskcache/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
import zlib


try:
import typing as T

def decohints(decorator: T.Callable) -> T.Callable:
return decorator
except ImportError: # if it is < 3.5, then we don't have typing
def decohints(decorator):
return decorator


def full_name(func):
"""Return full name of `func` by adding the module and function name."""
return func.__module__ + '.' + func.__qualname__
Expand Down Expand Up @@ -1863,6 +1873,7 @@ def memoize(
if callable(name):
raise TypeError('name cannot be callable')

@decohints
def decorator(func):
"""Decorator created by memoize() for callable `func`."""
base = (full_name(func),) if name is None else (name,)
Expand Down