style: code cleanups from Steven Burch (#29292)
* chore: update deprecated import from collections * chore: remove outdated imports from markdown library as it hasn't been supported since 2.0.3 and we're on 3.x. This was deprecated at least as early as 2012! * docs: add docstring and remove lint-amnesty to markdown plugin * chore: remove deprecated etree import * style: remove unnecessary-comprehension for sets * style: resolve a number of amnestied pylint complaints Co-authored-by: stvn <stvn@mit.edu>
This commit is contained in:
@@ -194,7 +194,7 @@ class TestModulestoreAssetSize(unittest.TestCase):
|
||||
|
||||
results = asset_collection.map_reduce(mapper, reducer, "size_results")
|
||||
result_str = "{} - Store: {:<15} - Num Assets: {:>6} - Result: {}\n".format(
|
||||
self.test_run_time, SHORT_NAME_MAP[source_ms], num_assets, [r for r in results.find()] # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
self.test_run_time, SHORT_NAME_MAP[source_ms], num_assets, results.find()
|
||||
)
|
||||
with open("bson_sizes.txt", "a") as f:
|
||||
f.write(result_str)
|
||||
|
||||
@@ -432,7 +432,7 @@ class SharedModuleStoreTestCase(
|
||||
for Django ORM models that will get cleaned up properly.
|
||||
"""
|
||||
# Tell Django to clean out all databases, not just default
|
||||
databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
databases = set(connections)
|
||||
|
||||
@classmethod
|
||||
@contextmanager
|
||||
@@ -527,7 +527,7 @@ class ModuleStoreTestCase(
|
||||
CREATE_USER = True
|
||||
|
||||
# Tell Django to clean out all databases, not just default
|
||||
databases = {alias for alias in connections} # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
databases = set(connections)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
@@ -553,11 +553,7 @@ class ImportTestCase(BaseCourseTestCase): # lint-amnesty, pylint: disable=missi
|
||||
|
||||
# Expect to find an error/exception about characters in "®esources"
|
||||
expect = "InvalidKeyError"
|
||||
errors = [
|
||||
(msg, err)
|
||||
for msg, err # lint-amnesty, pylint: disable=unnecessary-comprehension
|
||||
in modulestore.get_course_errors(course.id)
|
||||
]
|
||||
errors = modulestore.get_course_errors(course.id)
|
||||
|
||||
assert any(((expect in msg) or (expect in err)) for (msg, err) in errors)
|
||||
chapters = course.get_children()
|
||||
|
||||
@@ -58,6 +58,8 @@ class VideoStudentViewHandlers:
|
||||
"""
|
||||
Handlers for video module instance.
|
||||
"""
|
||||
global_speed = None
|
||||
transcript_language = None
|
||||
|
||||
def handle_ajax(self, dispatch, data):
|
||||
"""
|
||||
@@ -97,7 +99,7 @@ class VideoStudentViewHandlers:
|
||||
setattr(self, key, value)
|
||||
|
||||
if key == 'speed':
|
||||
self.global_speed = self.speed # lint-amnesty, pylint: disable=attribute-defined-outside-init
|
||||
self.global_speed = self.speed
|
||||
|
||||
return json.dumps({'success': True})
|
||||
|
||||
@@ -238,14 +240,14 @@ class VideoStudentViewHandlers:
|
||||
Return value: JSON response (200 on success, 400 for malformed data)
|
||||
"""
|
||||
completion_service = self.runtime.service(self, 'completion')
|
||||
if completion_service is None: # lint-amnesty, pylint: disable=no-else-raise
|
||||
if completion_service is None:
|
||||
raise JsonHandlerError(500, "No completion service found")
|
||||
elif not completion_service.completion_tracking_enabled():
|
||||
if not completion_service.completion_tracking_enabled():
|
||||
raise JsonHandlerError(404, "Completion tracking is not enabled and API calls are unexpected")
|
||||
if not isinstance(data['completion'], (int, float)): # lint-amnesty, pylint: disable=no-else-raise
|
||||
if not isinstance(data['completion'], (int, float)):
|
||||
message = "Invalid completion value {}. Must be a float in range [0.0, 1.0]"
|
||||
raise JsonHandlerError(400, message.format(data['completion']))
|
||||
elif not 0.0 <= data['completion'] <= 1.0:
|
||||
if not 0.0 <= data['completion'] <= 1.0:
|
||||
message = "Invalid completion value {}. Must be in range [0.0, 1.0]"
|
||||
raise JsonHandlerError(400, message.format(data['completion']))
|
||||
self.runtime.publish(self, "completion", data)
|
||||
@@ -321,8 +323,8 @@ class VideoStudentViewHandlers:
|
||||
log.info("Video: transcript facilities are not available for given language.")
|
||||
return Response(status=404)
|
||||
|
||||
if language != self.transcript_language: # lint-amnesty, pylint: disable=access-member-before-definition
|
||||
self.transcript_language = language # lint-amnesty, pylint: disable=attribute-defined-outside-init
|
||||
if language != self.transcript_language:
|
||||
self.transcript_language = language
|
||||
|
||||
try:
|
||||
if is_bumper:
|
||||
@@ -451,9 +453,9 @@ class VideoStudioViewHandlers:
|
||||
elif (
|
||||
data['language_code'] != data['new_language_code'] and data['new_language_code'] in available_translations
|
||||
):
|
||||
error = _('A transcript with the "{language_code}" language code already exists.'.format( # lint-amnesty, pylint: disable=translation-of-non-string
|
||||
language_code=data['new_language_code']
|
||||
))
|
||||
error = _('A transcript with the "{language_code}" language code already exists.').format(
|
||||
language_code=data['new_language_code'],
|
||||
)
|
||||
elif 'file' not in data:
|
||||
error = _('A transcript file is required.')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user