Skip to content

Commit 3f7fefb

Browse files
committed
fix: fix quality check for video block code
1 parent bbf0d8d commit 3f7fefb

File tree

15 files changed

+135
-106
lines changed

15 files changed

+135
-106
lines changed

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
USE_TZ=True,
2727
LANGUAGE_CODE="en-us",
2828
LANGUAGES=[("en", "English")],
29+
INSTALLED_APPS=[
30+
"edxval",
31+
],
32+
TRANSCRIPT_LANG_CACHE_TIMEOUT=60 * 60 * 24, # 24 hours, required by edxval
2933
)
3034

3135
django.setup()

test_settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
INSTALLED_APPS = [
66
"django.contrib.auth",
77
"django.contrib.contenttypes",
8+
"edxval",
89
]
910

1011
DATABASES = {
1112
"default": {
1213
"ENGINE": "django.db.backends.sqlite3",
1314
}
1415
}
16+
17+
TRANSCRIPT_LANG_CACHE_TIMEOUT = 60 * 60 * 24 # 24 hours

xblocks_contrib/common/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from django.conf import settings
66

77

8-
98
def get_resource_url(xblock, path, package_scope=None):
109
"""
1110
Return the runtime URL for a static resource in this XBlock's package.

xblocks_contrib/html/html.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def get_context(self):
322322
# the root /c4x/ url for assets. This allows client-side substitutions to occur.
323323
return {
324324
"module": self,
325-
"editable_metadata_fields": self.editable_metadata_fields, # pylint: disable=no-member
325+
"editable_metadata_fields": self.editable_metadata_fields,
326326
"data": self.data,
327327
"base_asset_url": self.get_base_url_path_for_course_assets(self.location.course_key),
328328
"enable_latex_compiler": self.use_latex_compiler,
@@ -371,7 +371,7 @@ def bind_for_student(self, user_id, wrappers=None):
371371
if self.scope_ids.user_id is not None and user_id == self.scope_ids.user_id:
372372
if getattr(self.runtime, "position", None):
373373
# update the position of the tab
374-
self.position = self.runtime.position # pylint: disable=attribute-defined-outside-init
374+
self.position = self.runtime.position
375375
return
376376

377377
# # If we are switching users mid-request, save the data from the old user.
@@ -402,7 +402,7 @@ def bind_for_student(self, user_id, wrappers=None):
402402
wrapped_field_data = self.runtime.service(self, "field-data-unbound")
403403
for wrapper in wrappers:
404404
wrapped_field_data = wrapper(wrapped_field_data)
405-
self._bound_field_data = wrapped_field_data # pylint: disable=attribute-defined-outside-init
405+
self._bound_field_data = wrapped_field_data
406406
if getattr(self.runtime, "uses_deprecated_field_data", False):
407407
# This approach is deprecated but old mongo's CachingDescriptorSystem still requires it.
408408
# For Split mongo's CachingDescriptor system, don't set ._field_data this way.

xblocks_contrib/video/content.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
""" Video Block Static Content, class copied from StaticContent class in edx-platform/xmodule/contentstore/content.py """
1+
"""
2+
Video Block Static Content.
3+
4+
Class copied from StaticContent class in edx-platform/xmodule/contentstore/content.py
5+
"""
26
from opaque_keys import InvalidKeyError
37
from opaque_keys.edx.keys import AssetKey
48
from opaque_keys.edx.locator import AssetLocator
59

6-
class VideoBlockStaticContent: # lint-amnesty, pylint: disable=missing-class-docstring
7-
def __init__(self, loc, name, content_type, data, last_modified_at=None, thumbnail_location=None, import_path=None,
8-
length=None, locked=False, content_digest=None):
10+
11+
class VideoBlockStaticContent:
12+
"""
13+
Represents static content associated with a video block (such as video files or related assets).
14+
"""
15+
def __init__( # pylint: disable=too-many-positional-arguments
16+
self, loc, name, content_type, data, last_modified_at=None,
17+
thumbnail_location=None, import_path=None, length=None, locked=False, content_digest=None
18+
):
919
self.location = loc
10-
self.name = name # a display string which can be edited, and thus not part of the location which needs to be fixed # lint-amnesty, pylint: disable=line-too-long
20+
# a display string which can be edited, and thus not part of the location which needs to be fixed
21+
self.name = name
1122
self.content_type = content_type
1223
self._data = data
1324
self.length = length
@@ -20,7 +31,7 @@ def __init__(self, loc, name, content_type, data, last_modified_at=None, thumbna
2031
self.content_digest = content_digest
2132

2233
@staticmethod
23-
def compute_location(course_key, path, revision=None, is_thumbnail=False): # lint-amnesty, pylint: disable=unused-argument
34+
def compute_location(course_key, path, revision=None, is_thumbnail=False): # pylint: disable=unused-argument
2435
"""
2536
Constructs a location object for static content.
2637
@@ -48,6 +59,7 @@ def get_location_from_path(path):
4859
if path.startswith('/') or path.endswith('/'):
4960
# try stripping off the leading slash and try again
5061
return AssetKey.from_string(path.strip('/'))
62+
return None
5163

5264
@staticmethod
5365
def serialize_asset_key_with_slash(asset_key):

xblocks_contrib/video/mixin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
from xblock.core import XBlockMixin
66
from xblock.fields import Scope, String
77

8-
# Make '_' a no-op so we can scrape strings. Using lambda instead of
8+
9+
# Make '_' a no-op so we can scrape strings. Using dummy function instead of
910
# `django.utils.translation.gettext_noop` because Django cannot be imported in this file
10-
_ = lambda text: text
11+
def _(text):
12+
return text
1113

1214

1315
class LicenseMixin(XBlockMixin):

xblocks_contrib/video/studio_metadata_mixin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def editable_metadata_fields(self):
123123
editable_fields.pop('sub')
124124

125125
languages = [{'label': label, 'code': lang} for lang, label in settings.ALL_LANGUAGES]
126-
languages.sort(key=lambda l: l['label'])
126+
languages.sort(key=lambda lang_item: lang_item['label'])
127127
editable_fields['transcripts']['custom'] = True
128128
editable_fields['transcripts']['languages'] = languages
129129
editable_fields['transcripts']['type'] = 'VideoTranslations'
@@ -148,7 +148,9 @@ def editable_metadata_fields(self):
148148
if video_config_service:
149149
for sub_id in possible_sub_ids:
150150
try:
151-
_, sub_id, _ = video_config_service.get_transcript(self, lang='en', output_format=TranscriptExtensions.TXT)
151+
_, sub_id, _ = video_config_service.get_transcript(
152+
self, lang='en', output_format=TranscriptExtensions.TXT
153+
)
152154
transcripts_info['transcripts'] = dict(transcripts_info['transcripts'], en=sub_id)
153155
break
154156
except TranscriptNotFoundError:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Tests for the video xblock.
3+
"""

xblocks_contrib/video/tests/test_video.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

xblocks_contrib/video/validation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class StudioValidationMessage(ValidationMessage):
1515

1616
TYPES = [ValidationMessage.WARNING, ValidationMessage.ERROR, NOT_CONFIGURED]
1717

18-
def __init__(self, message_type, message_text, action_label=None, action_class=None, action_runtime_event=None):
18+
def __init__( # pylint: disable=too-many-positional-arguments
19+
self, message_type, message_text, action_label=None, action_class=None, action_runtime_event=None
20+
):
1921
"""
2022
Create a new message.
2123

0 commit comments

Comments
 (0)