Skip to content

Commit

Permalink
chore: address lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Oct 7, 2024
1 parent 4aaf64c commit 3de76a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions openedx/core/djangoapps/content_libraries/library_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def can_edit_block(self, user: UserType, usage_key: UsageKeyV2) -> bool:
return True
except PermissionDenied:
return False
except api.ContentLibraryNotFound:
except api.ContentLibraryNotFound as exc:
# A 404 is probably what you want in this case, not a 500 error, so do that by default.
raise NotFound(f"Content Library '{usage_key.lib_key}' does not exist")
raise NotFound(f"Content Library '{usage_key.lib_key}' does not exist") from exc

def can_view_block_for_editing(self, user: UserType, usage_key: UsageKeyV2) -> bool:
"""
Expand All @@ -64,9 +64,9 @@ def can_view_block_for_editing(self, user: UserType, usage_key: UsageKeyV2) -> b
return True
except PermissionDenied:
return False
except api.ContentLibraryNotFound:
except api.ContentLibraryNotFound as exc:
# A 404 is probably what you want in this case, not a 500 error, so do that by default.
raise NotFound(f"Content Library '{usage_key.lib_key}' does not exist")
raise NotFound(f"Content Library '{usage_key.lib_key}' does not exist") from exc

def can_view_block(self, user: UserType, usage_key: UsageKeyV2) -> bool:
"""
Expand All @@ -84,9 +84,9 @@ def can_view_block(self, user: UserType, usage_key: UsageKeyV2) -> bool:
return True
except PermissionDenied:
return False
except api.ContentLibraryNotFound:
except api.ContentLibraryNotFound as exc:
# A 404 is probably what you want in this case, not a 500 error, so do that by default.
raise NotFound(f"Content Library '{usage_key.lib_key}' does not exist")
raise NotFound(f"Content Library '{usage_key.lib_key}' does not exist") from exc

def block_exists(self, usage_key: LibraryUsageLocatorV2):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def test_library_not_found(self):
response = self.client.get(URL_BLOCK_METADATA_URL.format(block_key=valid_not_found_key))
self.assertEqual(response.status_code, 404)
self.assertEqual(response.json(), {
'detail': f"Content Library 'lib:valid:key' does not exist",
'detail': "Content Library 'lib:valid:key' does not exist",
})

def test_block_not_found(self):
Expand Down
4 changes: 2 additions & 2 deletions openedx/core/djangoapps/xblock/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def load_block(usage_key, user, *, check_permission: CheckPerm | None = CheckPer

try:
return runtime.get_block(usage_key)
except NoSuchUsage:
except NoSuchUsage as exc:
# Convert NoSuchUsage to NotFound so we do the right thing (404 not 500) by default.
raise NotFound(f"The component '{usage_key}' does not exist.")
raise NotFound(f"The component '{usage_key}' does not exist.") from exc


def get_block_metadata(block, includes=()):
Expand Down

0 comments on commit 3de76a5

Please sign in to comment.