Skip to content

Commit c97a4c4

Browse files
refactor: address doc quality issues
1 parent becc68e commit c97a4c4

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

openedx_authz/api/data.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
from opaque_keys import InvalidKeyError
88
from opaque_keys.edx.locator import LibraryLocatorV2
99

10+
11+
__all__ = [
12+
"UserData",
13+
"PermissionData",
14+
"GroupingPolicyIndex",
15+
"PolicyIndex",
16+
"ActionData",
17+
"RoleAssignmentData",
18+
"RoleData",
19+
"ScopeData",
20+
"SubjectData",
21+
]
22+
1023
AUTHZ_POLICY_ATTRIBUTES_SEPARATOR = "^"
1124

1225

@@ -289,6 +302,10 @@ class UserData(SubjectData):
289302
def username(self) -> str:
290303
"""The username for the user (e.g., 'john_doe').
291304
305+
TODO: Temporary :no-index: to avoid duplicate object warnings from wildcard import in __init__.py
306+
307+
:no-index:
308+
292309
This is an alias for external_key that represents the username without the namespace prefix.
293310
294311
Returns:
@@ -358,16 +375,22 @@ class RoleData(AuthZData):
358375
permissions: A list of permissions assigned to the role.
359376
metadata: A dictionary of metadata assigned to the role. This can include
360377
information such as the description of the role, creation date, etc.
378+
379+
TODO: Temporary :no-index: on attributes to avoid duplicate object warnings from wildcard import in __init__.py
361380
"""
362381

363382
NAMESPACE: ClassVar[str] = "role"
364-
permissions: list[PermissionData] = None
365-
metadata: RoleMetadataData = None
383+
permissions: list[PermissionData] = None #: :no-index:
384+
metadata: RoleMetadataData = None #: :no-index:
366385

367386
@property
368387
def name(self) -> str:
369388
"""The human-readable name of the role (e.g., 'Library Admin', 'Course Instructor').
370389
390+
TODO: Temporary :no-index: to avoid duplicate object warnings from wildcard import in __init__.py
391+
392+
:no-index:
393+
371394
This property transforms the external_key into a human-readable display name
372395
by replacing underscores with spaces and capitalizing each word.
373396
@@ -386,8 +409,10 @@ class RoleAssignmentData(AuthZData):
386409
email: The email of the user.
387410
role_name: The name of the role.
388411
scope: The scope in which the role is assigned.
412+
413+
TODO: Temporary :no-index: on attributes to avoid duplicate object warnings from wildcard import in __init__.py
389414
"""
390415

391-
subject: SubjectData = None # Needs defaults to avoid value error from attrs
416+
subject: SubjectData = None #: :no-index:
392417
role: RoleData = None
393-
scope: ScopeData = None
418+
scope: ScopeData = None #: :no-index:

openedx_authz/api/roles.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def get_permissions_for_active_roles_in_scope(
8787
This function operates on the principle that roles defined in policies are templates
8888
that become active only when assigned to subjects with specific scopes.
8989
90-
Role Definition vs Role Assignment:
90+
**Role Definition vs Role Assignment:**
91+
9192
- Policy roles define potential permissions with namespace patterns (e.g., 'lib@*')
9293
- Actual permissions are granted only when roles are assigned to subjects with
9394
concrete scopes (e.g., 'lib@123')
@@ -96,7 +97,8 @@ def get_permissions_for_active_roles_in_scope(
9697
- The specific scope at assignment time ('lib@123') determines the exact
9798
resource the permissions apply to
9899
99-
Behavior:
100+
**Behavior:**
101+
100102
- Returns permissions only for roles that have been assigned to subjects
101103
- Unassigned roles (those defined in policy but not given to any subject)
102104
contribute no permissions to the result

0 commit comments

Comments
 (0)