Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions cms/djangoapps/contentstore/api/views/course_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,7 @@ def leaf_filter(block):
len(cls._get_children(block)) == 0
)

return [
block for block in # lint-amnesty, pylint: disable=unnecessary-comprehension
traverse_pre_order(unit, cls._get_visible_children, leaf_filter)
]
return list(traverse_pre_order(unit, cls._get_visible_children, leaf_filter))

def _stats_dict(self, data): # lint-amnesty, pylint: disable=missing-function-docstring
if not data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ def handle(self, *args, **options):

with open(file_path) as csv_file:
csv_reader = csv.reader(csv_file)

email_mappings = [
(current_email, new_email)
for (current_email, new_email) # lint-amnesty, pylint: disable=unnecessary-comprehension
in csv_reader
]
email_mappings = list(csv_reader)

successful_updates = []
failed_updates = []
Expand Down
2 changes: 1 addition & 1 deletion common/lib/symmath/symmath/test_symmath_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class SymmathCheckTest(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
def test_symmath_check_integers(self):
number_list = [i for i in range(-100, 100)] # lint-amnesty, pylint: disable=unnecessary-comprehension
number_list = range(-100, 100)
self._symmath_check_numbers(number_list)

def test_symmath_check_floats(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def test_asset_sizes(self, source_ms, num_assets):

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)
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def setUp(self):
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
Expand Down Expand Up @@ -491,7 +491,7 @@ class FooTest(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):
Expand Down
6 changes: 1 addition & 5 deletions common/lib/xmodule/xmodule/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,7 @@ def test_unicode(self):

# 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()
Expand Down
22 changes: 12 additions & 10 deletions common/lib/xmodule/xmodule/video_module/video_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class VideoStudentViewHandlers:
"""
Handlers for video module instance.
"""
global_speed = None
transcript_language = None

def handle_ajax(self, dispatch, data):
"""
Expand Down Expand Up @@ -97,7 +99,7 @@ def handle_ajax(self, dispatch, data):
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})

Expand Down Expand Up @@ -238,14 +240,14 @@ def publish_completion(self, data, dispatch): # pylint: disable=unused-argument
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)
Expand Down Expand Up @@ -321,8 +323,8 @@ def transcript(self, request, dispatch):
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:
Expand Down Expand Up @@ -446,9 +448,9 @@ def validate_transcript_upload_data(self, data):
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.')

Expand Down
2 changes: 1 addition & 1 deletion common/test/acceptance/fixtures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def session_cookies(self):
Log in as a staff user, then return the cookies for the session (as a dict)
Raises a `StudioApiLoginError` if the login fails.
"""
return {key: val for key, val in self.session.cookies.items()} # lint-amnesty, pylint: disable=unnecessary-comprehension
return dict(self.session.cookies.items())

@lazy
def headers(self):
Expand Down
2 changes: 1 addition & 1 deletion common/test/acceptance/fixtures/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def session_cookies(self):
Log in as a staff user, then return the cookies for the session (as a dict)
Raises a `ConfigModelFixtureError` if the login fails.
"""
return {key: val for key, val in self.session.cookies.items()} # lint-amnesty, pylint: disable=unnecessary-comprehension
return dict(self.session.cookies.items())

@lazy
def headers(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FieldOverridePerformanceTestCase(FieldOverrideTestMixin, ProceduralCourseT
"""
__test__ = False
# 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)

# TEST_DATA must be overridden by subclasses
TEST_DATA = None
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/course_goals/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_course_goal_options():
Returns the valid options for goal keys, mapped to their translated
strings, as defined by theCourseGoal model.
"""
return {goal_key: goal_text for goal_key, goal_text in GOAL_KEY_CHOICES} # lint-amnesty, pylint: disable=unnecessary-comprehension
return dict(GOAL_KEY_CHOICES)


def get_course_goal_text(goal_key):
Expand Down
16 changes: 7 additions & 9 deletions lms/djangoapps/course_wiki/plugins/markdownedx/mdx_mathjax.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Source: https://github.com/mayoff/python-markdown-mathjax # lint-amnesty, pylint: disable=missing-module-docstring
"""
Add MathJax Markdown support

Source: https://github.com/mayoff/python-markdown-mathjax
"""
from xml.etree import ElementTree

import markdown

try:
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
# but import the 2.0.3 version if it fails
from markdown.util import etree, AtomicString
except: # lint-amnesty, pylint: disable=bare-except
from markdown import etree, AtomicString
from markdown.util import AtomicString


class MathJaxPattern(markdown.inlinepatterns.Pattern): # lint-amnesty, pylint: disable=missing-class-docstring
Expand All @@ -17,7 +15,7 @@ def __init__(self):
markdown.inlinepatterns.Pattern.__init__(self, r'(?<!\\)(\$\$?)(.+?)\2')

def handleMatch(self, m):
el = etree.Element('span')
el = ElementTree.Element('span')
el.text = AtomicString(m.group(2) + m.group(3) + m.group(2))
return el

Expand Down
17 changes: 5 additions & 12 deletions lms/djangoapps/course_wiki/plugins/markdownedx/mdx_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,10 @@
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.gametrailers.com/remote_wrap.php?mid=58079" height="392" type="application/x-shockwave-flash" width="480"><param name="movie" value="http://www.gametrailers.com/remote_wrap.php?mid=58079" /><param name="allowFullScreen" value="true" /></object></p>'
"""

from xml.etree import ElementTree

import markdown

try:
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
# but import the 2.0.3 version if it fails
from markdown.util import etree
except ImportError:
from markdown import etree


version = "0.1.6"

Expand Down Expand Up @@ -254,7 +247,7 @@ def handleMatch(self, m):
width = self.ext.config['yahoo_width'][0]
height = self.ext.config['yahoo_height'][0]
obj = flash_object(url, width, height)
param = etree.Element('param')
param = ElementTree.Element('param')
param.set('name', 'flashVars')
param.set('value', "id={}&vid={}".format(m.group('yahooid'), m.group('yahoovid')))
obj.append(param)
Expand All @@ -271,16 +264,16 @@ def handleMatch(self, m):


def flash_object(url, width, height): # lint-amnesty, pylint: disable=missing-function-docstring
obj = etree.Element('object')
obj = ElementTree.Element('object')
obj.set('type', 'application/x-shockwave-flash')
obj.set('width', width)
obj.set('height', height)
obj.set('data', url)
param = etree.Element('param')
param = ElementTree.Element('param')
param.set('name', 'movie')
param.set('value', url)
obj.append(param)
param = etree.Element('param')
param = ElementTree.Element('param')
param.set('name', 'allowFullScreen')
param.set('value', 'true')
obj.append(param)
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/tests/test_model_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class TestStudentModuleStorage(OtherUserFailureTestMixin, TestCase):
other_key_factory = partial(DjangoKeyValueStore.Key, Scope.user_state, 2, LOCATION('usage_id')) # user_id=2, not 1
existing_field_name = "a_field"
# 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)

def setUp(self):
super().setUp()
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_set_many_failure(self):

class TestMissingStudentModule(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
# 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)

def setUp(self):
super().setUp()
Expand Down
8 changes: 4 additions & 4 deletions lms/djangoapps/courseware/tests/test_submitting_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl
"""

# 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)
# arbitrary constant
COURSE_SLUG = "100"
COURSE_NAME = "test_course"
Expand Down Expand Up @@ -339,7 +339,7 @@ class TestCourseGrader(TestSubmittingProblems):
Suite of tests for the course grader.
"""
# 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)

def basic_setup(self, late=False, reset=False, showanswer=False):
"""
Expand Down Expand Up @@ -752,7 +752,7 @@ def test_min_grade_credit_requirements_status(self, mode):
class ProblemWithUploadedFilesTest(TestSubmittingProblems):
"""Tests of problems with uploaded files."""
# 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)

def setUp(self):
super().setUp()
Expand Down Expand Up @@ -808,7 +808,7 @@ class TestPythonGradedResponse(TestSubmittingProblems):
Check that we can submit a schematic and custom response, and it answers 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)

SCHEMATIC_SCRIPT = dedent("""
# for a schematic response, submission[i] is the json representation
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/tests/test_user_state_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestDjangoUserStateClient(UserStateClientTestBase, ModuleStoreTestCase):
"""
__test__ = 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)

def _user(self, user_idx): # lint-amnesty, pylint: disable=arguments-differ
return self.users[user_idx].username
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/coursewarehistoryextended/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class TestStudentModuleHistoryBackends(TestCase):
""" Tests of data in CSMH and CSMHE """
# 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)

def setUp(self):
super().setUp()
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man
try:
upload_file = request.FILES.get('students_list')
if upload_file.name.endswith('.csv'):
students = [row for row in csv.reader(upload_file.read().decode('utf-8').splitlines())] # lint-amnesty, pylint: disable=unnecessary-comprehension
students = list(csv.reader(upload_file.read().decode('utf-8').splitlines()))
course = get_course_by_id(course_id)
else:
general_errors.append({
Expand Down Expand Up @@ -3185,7 +3185,7 @@ def build_row_errors(key, _user, row_count):
try:
upload_file = request.FILES.get('students_list')
if upload_file.name.endswith('.csv'):
students = [row for row in csv.reader(upload_file.read().decode('utf-8').splitlines())] # lint-amnesty, pylint: disable=unnecessary-comprehension
students = list(csv.reader(upload_file.read().decode('utf-8').splitlines()))
else:
general_errors.append(_('Make sure that the file you upload is in CSV format with no '
'extraneous characters or rows.'))
Expand Down
3 changes: 1 addition & 2 deletions lms/djangoapps/instructor_analytics/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ def profile_distribution(course_id, feature):
raw_choices = UserProfile.LEVEL_OF_EDUCATION_CHOICES

# short name and display name (full) of the choices.
choices = [(short, full)
for (short, full) in raw_choices] + [('no_data', 'No Data')] # lint-amnesty, pylint: disable=unnecessary-comprehension
choices = list(raw_choices) + [('no_data', 'No Data')]

def get_filter(feature, value):
""" Get the orm filter parameters for a feature. """
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor_task/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def verify_rows_in_csv(self, expected_rows, file_index=0, verify_order=True, ign
report_path = report_store.path_to(self.course.id, report_csv_filename)
with report_store.storage.open(report_path) as csv_file:
# Expand the dict reader generator so we don't lose it's content
csv_rows = [row for row in unicodecsv.DictReader(csv_file, encoding='utf-8-sig')] # lint-amnesty, pylint: disable=unnecessary-comprehension
csv_rows = list(unicodecsv.DictReader(csv_file, encoding='utf-8-sig'))

if ignore_other_columns:
csv_rows = [
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor_task/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
log = logging.getLogger(__name__)

# return status for completed tasks and tasks in progress
STATES_WITH_STATUS = [state for state in READY_STATES] + [PROGRESS] # lint-amnesty, pylint: disable=unnecessary-comprehension
STATES_WITH_STATUS = list(READY_STATES) + [PROGRESS]


def _get_instructor_task_status(task_id):
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/support/views/program_enrollments.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _validate_and_link(program_uuid_string, linkage_text):
for item in ext_key_to_username.items()
if item not in link_errors
]
errors = [message for message in link_errors.values()] # lint-amnesty, pylint: disable=unnecessary-comprehension
errors = list(link_errors.values())
return successes, errors


Expand Down
5 changes: 4 additions & 1 deletion lms/envs/devstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing


########################## Course Discovery #######################
LANGUAGE_MAP = {'terms': {lang: display for lang, display in ALL_LANGUAGES}, 'name': 'Language'} # lint-amnesty, pylint: disable=unnecessary-comprehension
LANGUAGE_MAP = {
'terms': dict(ALL_LANGUAGES),
'name': 'Language',
}
COURSE_DISCOVERY_MEANINGS = {
'org': {
'name': 'Organization',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def mock_registered_transformers(transformers):
'openedx.core.djangoapps.content.block_structure.transformer_registry.'
'TransformerRegistry.get_registered_transformers'
) as mock_available_transforms:
mock_available_transforms.return_value = {transformer for transformer in transformers} # lint-amnesty, pylint: disable=unnecessary-comprehension
mock_available_transforms.return_value = set(transformers)
yield


Expand Down
Loading