Skip to content

Commit b7dbf55

Browse files
refactor: address quality errors
1 parent 59cd003 commit b7dbf55

6 files changed

Lines changed: 11 additions & 24 deletions

File tree

openedx_authz/api/data.py

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

10-
1110
__all__ = [
1211
"UserData",
1312
"PermissionData",
@@ -206,7 +205,7 @@ class ScopeData(AuthZData, metaclass=ScopeMeta):
206205
NAMESPACE: ClassVar[str] = "sc"
207206

208207
@classmethod
209-
def validate_external_key(cls, external_key: str) -> bool:
208+
def validate_external_key(cls, _: str) -> bool:
210209
"""Validate the external_key format for ScopeData.
211210
212211
For the base ScopeData class, we accept any external_key works. This
@@ -389,7 +388,7 @@ class RoleData(AuthZData):
389388
"""
390389

391390
NAMESPACE: ClassVar[str] = "role"
392-
permissions: list[PermissionData] = list()
391+
permissions: list[PermissionData] = []
393392

394393
@property
395394
def name(self) -> str:
@@ -415,5 +414,5 @@ class RoleAssignmentData(AuthZData):
415414
"""
416415

417416
subject: SubjectData = None # Needs defaults to avoid value error from attrs
418-
roles: list[RoleData] = list()
417+
roles: list[RoleData] = []
419418
scope: ScopeData = None

openedx_authz/api/permissions.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
are not explicitly defined, but are inferred from the policy rules.
66
"""
77

8-
from openedx_authz.api.data import (
9-
ActionData,
10-
PermissionData,
11-
PolicyIndex,
12-
ScopeData,
13-
SubjectData,
14-
)
8+
from openedx_authz.api.data import ActionData, PermissionData, PolicyIndex, ScopeData, SubjectData
159
from openedx_authz.engine.enforcer import enforcer
1610

1711
__all__ = [

openedx_authz/api/users.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,16 @@
99
(e.g., 'user@john_doe').
1010
"""
1111

12-
from openedx_authz.api.data import (
13-
ActionData,
14-
RoleAssignmentData,
15-
RoleData,
16-
ScopeData,
17-
UserData,
18-
)
12+
from openedx_authz.api.data import ActionData, RoleAssignmentData, RoleData, ScopeData, UserData
1913
from openedx_authz.api.permissions import is_subject_allowed
2014
from openedx_authz.api.roles import (
2115
assign_role_to_subject_in_scope,
2216
batch_assign_role_to_subjects_in_scope,
2317
batch_unassign_role_from_subjects_in_scope,
2418
get_all_subject_role_assignments_in_scope,
2519
get_subject_role_assignments,
26-
get_subject_role_assignments_in_scope,
2720
get_subject_role_assignments_for_role_in_scope,
21+
get_subject_role_assignments_in_scope,
2822
unassign_role_from_subject_in_scope,
2923
)
3024

openedx_authz/management/commands/load_policies.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
python manage.py load_policies --policy-file-path /path/to/policy.csv
1010
"""
1111

12-
import casbin
1312
import os
14-
from openedx_authz import ROOT_DIRECTORY
13+
14+
import casbin
1515
from django.core.management.base import BaseCommand
1616

17+
from openedx_authz import ROOT_DIRECTORY
1718
from openedx_authz.engine.enforcer import enforcer as global_enforcer
1819
from openedx_authz.engine.utils import migrate_policy_between_enforcers
1920

openedx_authz/tests/api/test_roles.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
batch_assign_role_to_subjects_in_scope,
2525
get_all_subject_role_assignments_in_scope,
2626
get_permissions_for_active_roles_in_scope,
27-
get_permissions_for_roles,
2827
get_permissions_for_single_role,
2928
get_role_definitions_in_scope,
3029
get_subject_role_assignments,
31-
get_subject_role_assignments_in_scope,
3230
get_subject_role_assignments_for_role_in_scope,
31+
get_subject_role_assignments_in_scope,
3332
unassign_role_from_subject_in_scope,
3433
)
3534
from openedx_authz.engine.enforcer import enforcer as global_enforcer

openedx_authz/tests/api/test_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
get_user_role_assignments,
1919
get_user_role_assignments_for_role_in_scope,
2020
get_user_role_assignments_in_scope,
21-
unassign_role_from_user,
2221
is_user_allowed,
22+
unassign_role_from_user,
2323
)
2424
from openedx_authz.tests.api.test_roles import RolesTestSetupMixin
2525

0 commit comments

Comments
 (0)