Skip to content

Commit

Permalink
fix: Use AbstractBaseUser for type-hinting of the user parameter in c…
Browse files Browse the repository at this point in the history
…ache module (#1495)
  • Loading branch information
payamnj committed Sep 13, 2024
1 parent 44255c8 commit b50f66e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions filer/cache.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import typing

from django.contrib.auth import get_user_model
from django.contrib.auth.models import AbstractBaseUser
from django.core.cache import cache


User = get_user_model()


def get_folder_perm_cache_key(user: User, permission: str) -> str:
def get_folder_perm_cache_key(user: AbstractBaseUser, permission: str) -> str:
"""
Generates a unique cache key for a given user and permission.
Expand All @@ -27,7 +24,7 @@ def get_folder_perm_cache_key(user: User, permission: str) -> str:
return f"filer:perm:{permission}"


def get_folder_permission_cache(user: User, permission: str) -> typing.Optional[dict]:
def get_folder_permission_cache(user: AbstractBaseUser, permission: str) -> typing.Optional[dict]:
"""
Retrieves the cached folder permissions for a given user and permission.
Expand All @@ -47,7 +44,7 @@ def get_folder_permission_cache(user: User, permission: str) -> typing.Optional[
return None


def clear_folder_permission_cache(user: User, permission: typing.Optional[str] = None) -> None:
def clear_folder_permission_cache(user: AbstractBaseUser, permission: typing.Optional[str] = None) -> None:
"""
Clears the cached folder permissions for a given user.
Expand All @@ -65,7 +62,7 @@ def clear_folder_permission_cache(user: User, permission: typing.Optional[str] =
cache.delete(get_folder_perm_cache_key(user, permission))


def update_folder_permission_cache(user: User, permission: str, id_list: typing.List[int]) -> None:
def update_folder_permission_cache(user: AbstractBaseUser, permission: str, id_list: typing.List[int]) -> None:
"""
Updates the cached folder permissions for a given user and permission.
Expand Down

0 comments on commit b50f66e

Please sign in to comment.