Skip to content

Commit deaee93

Browse files
committed
refactor: update NAMESPACE attributes to use ClassVar for type hinting
1 parent 8d68f1f commit deaee93

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

openedx_authz/rest_api/v1/permissions.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Permissions for the Open edX AuthZ REST API."""
22

3+
from typing import ClassVar
4+
35
from rest_framework.permissions import BasePermission
46

57
from openedx_authz import api
@@ -51,8 +53,8 @@ class BaseScopePermission(BasePermission, metaclass=PermissionMeta):
5153
specific authorization logic for their scope types.
5254
"""
5355

54-
NAMESPACE = "sc"
55-
"""The namespace identifier for this permission class (default: ``sc`` for generic scopes)."""
56+
NAMESPACE: ClassVar[str] = "sc"
57+
"""The namespace identifier for this permission class. Default ``sc`` for generic scopes."""
5658

5759
def get_scope_value(self, request) -> str | None:
5860
"""Extract the scope value from the request.
@@ -127,7 +129,7 @@ class ContentLibraryPermission(BaseScopePermission):
127129
- GET requests require ``view_library_team`` permission.
128130
"""
129131

130-
NAMESPACE = "lib"
132+
NAMESPACE: ClassVar[str] = "lib"
131133
"""``lib`` for content library scopes."""
132134

133135
def has_permission(self, request, view) -> bool:
@@ -177,8 +179,8 @@ class DynamicScopePermission(BaseScopePermission):
177179
Superusers and staff members always have permission regardless of scope.
178180
"""
179181

180-
NAMESPACE = None
181-
"""``None`` (this is a dispatcher, not tied to a specific namespace)."""
182+
NAMESPACE: ClassVar[None] = None
183+
"""This is a dispatcher, not tied to a specific namespace."""
182184

183185
def _get_permission_instance(self, request) -> BaseScopePermission:
184186
"""Instantiate the permission class for the request scope.

0 commit comments

Comments
 (0)