diff --git a/common/djangoapps/course_groups/cohorts.py b/common/djangoapps/course_groups/cohorts.py index 37c0abf959..d10c6309dc 100644 --- a/common/djangoapps/course_groups/cohorts.py +++ b/common/djangoapps/course_groups/cohorts.py @@ -219,9 +219,11 @@ def get_cohort(user, course_key): return None try: - return CourseUserGroup.objects.get(course_id=course_key, - group_type=CourseUserGroup.COHORT, - users__id=user.id) + return CourseUserGroup.objects.get( + course_id=course_key, + group_type=CourseUserGroup.COHORT, + users__id=user.id, + ) except CourseUserGroup.DoesNotExist: # Didn't find the group. We'll go on to create one if needed. pass diff --git a/common/djangoapps/course_groups/models.py b/common/djangoapps/course_groups/models.py index 7c17898899..aae9f40604 100644 --- a/common/djangoapps/course_groups/models.py +++ b/common/djangoapps/course_groups/models.py @@ -24,8 +24,11 @@ class CourseUserGroup(models.Model): # Note: groups associated with particular runs of a course. E.g. Fall 2012 and Spring # 2013 versions of 6.00x will have separate groups. - course_id = CourseKeyField(max_length=255, db_index=True, - help_text="Which course is this group associated with?") + course_id = CourseKeyField( + max_length=255, + db_index=True, + help_text="Which course is this group associated with?", + ) # For now, only have group type 'cohort', but adding a type field to support # things like 'question_discussion', 'friends', 'off-line-class', etc diff --git a/common/djangoapps/geoinfo/tests/test_middleware.py b/common/djangoapps/geoinfo/tests/test_middleware.py index 2ef8e9fc6a..3e6b7159ac 100644 --- a/common/djangoapps/geoinfo/tests/test_middleware.py +++ b/common/djangoapps/geoinfo/tests/test_middleware.py @@ -46,8 +46,10 @@ class CountryMiddlewareTests(TestCase): return ip_dict.get(ip_addr, 'US') def test_country_code_added(self): - request = self.request_factory.get('/somewhere', - HTTP_X_FORWARDED_FOR='117.79.83.1') + request = self.request_factory.get( + '/somewhere', + HTTP_X_FORWARDED_FOR='117.79.83.1', + ) request.user = self.authenticated_user self.session_middleware.process_request(request) # No country code exists before request. @@ -59,8 +61,10 @@ class CountryMiddlewareTests(TestCase): self.assertEqual('117.79.83.1', request.session.get('ip_address')) def test_ip_address_changed(self): - request = self.request_factory.get('/somewhere', - HTTP_X_FORWARDED_FOR='4.0.0.0') + request = self.request_factory.get( + '/somewhere', + HTTP_X_FORWARDED_FOR='4.0.0.0', + ) request.user = self.anonymous_user self.session_middleware.process_request(request) request.session['country_code'] = 'CN' @@ -71,8 +75,10 @@ class CountryMiddlewareTests(TestCase): self.assertEqual('4.0.0.0', request.session.get('ip_address')) def test_ip_address_is_not_changed(self): - request = self.request_factory.get('/somewhere', - HTTP_X_FORWARDED_FOR='117.79.83.1') + request = self.request_factory.get( + '/somewhere', + HTTP_X_FORWARDED_FOR='117.79.83.1', + ) request.user = self.anonymous_user self.session_middleware.process_request(request) request.session['country_code'] = 'CN' @@ -83,8 +89,10 @@ class CountryMiddlewareTests(TestCase): self.assertEqual('117.79.83.1', request.session.get('ip_address')) def test_same_country_different_ip(self): - request = self.request_factory.get('/somewhere', - HTTP_X_FORWARDED_FOR='117.79.83.100') + request = self.request_factory.get( + '/somewhere', + HTTP_X_FORWARDED_FOR='117.79.83.100', + ) request.user = self.anonymous_user self.session_middleware.process_request(request) request.session['country_code'] = 'CN' diff --git a/common/djangoapps/student/management/commands/userinfo.py b/common/djangoapps/student/management/commands/userinfo.py index 263b86ef78..4106694aa2 100644 --- a/common/djangoapps/student/management/commands/userinfo.py +++ b/common/djangoapps/student/management/commands/userinfo.py @@ -19,13 +19,15 @@ Pass a single filename.""" l = [] for user in users: up = UserProfile.objects.get(user=user) - d = {'username': user.username, - 'email': user.email, - 'is_active': user.is_active, - 'joined': user.date_joined.isoformat(), - 'name': up.name, - 'language': up.language, - 'location': up.location} + d = { + 'username': user.username, + 'email': user.email, + 'is_active': user.is_active, + 'joined': user.date_joined.isoformat(), + 'name': up.name, + 'language': up.language, + 'location': up.location, + } l.append(d) json.dump(l, f) f.close() diff --git a/common/djangoapps/track/middleware.py b/common/djangoapps/track/middleware.py index 242e819a5f..4a6507b0ac 100644 --- a/common/djangoapps/track/middleware.py +++ b/common/djangoapps/track/middleware.py @@ -59,8 +59,10 @@ class TrackMiddleware(object): if string in get_dict: get_dict[string] = '*' * 8 - event = {'GET': dict(get_dict), - 'POST': dict(post_dict)} + event = { + 'GET': dict(get_dict), + 'POST': dict(post_dict), + } # TODO: Confirm no large file uploads event = json.dumps(event) diff --git a/common/lib/chem/chem/chemcalc.py b/common/lib/chem/chem/chemcalc.py index 930c5818f4..27ce78b3f7 100644 --- a/common/lib/chem/chem/chemcalc.py +++ b/common/lib/chem/chem/chemcalc.py @@ -339,8 +339,13 @@ def divide_chemical_expression(s1, s2, ignore_state=False): if treedic['1 phases'] != treedic['2 phases']: return False - if any(map(lambda x, y: x / y - treedic['1 factors'][0] / treedic['2 factors'][0], - treedic['1 factors'], treedic['2 factors'])): + if any( + map( + lambda x, y: x / y - treedic['1 factors'][0] / treedic['2 factors'][0], + treedic['1 factors'], + treedic['2 factors'], + ) + ): # factors are not proportional return False else: diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py index 48e30837ed..9134b14872 100644 --- a/lms/djangoapps/courseware/grades.py +++ b/lms/djangoapps/courseware/grades.py @@ -260,8 +260,10 @@ def _grade(student, request, course, keep_raw_scores): if graded_total.possible > 0: format_scores.append(graded_total) else: - log.info("Unable to grade a section with a total possible score of zero. " + - str(section_descriptor.location)) + log.info( + "Unable to grade a section with a total possible score of zero. " + + str(section_descriptor.location) + ) totaled_scores[section_format] = format_scores diff --git a/lms/djangoapps/lms_migration/management/commands/create_user.py b/lms/djangoapps/lms_migration/management/commands/create_user.py index 6f72ec5d94..327a597166 100644 --- a/lms/djangoapps/lms_migration/management/commands/create_user.py +++ b/lms/djangoapps/lms_migration/management/commands/create_user.py @@ -28,8 +28,11 @@ class MyCompleter(object): # Custom completer def complete(self, text, state): if state == 0: # on first trigger, build possible matches if text: # cache matches (entries that start with entered text) - self.matches = [s for s in self.options - if s and s.startswith(text)] + self.matches = [ + option + for option in self.options + if option and option.startswith(text) + ] else: # no text entered, all matches possible self.matches = self.options[:] diff --git a/lms/djangoapps/open_ended_grading/open_ended_notifications.py b/lms/djangoapps/open_ended_grading/open_ended_notifications.py index bfa9e337bd..798e6ad91d 100644 --- a/lms/djangoapps/open_ended_grading/open_ended_notifications.py +++ b/lms/djangoapps/open_ended_grading/open_ended_notifications.py @@ -158,8 +158,12 @@ def combined_notifications(course, user): try: #Get the notifications from the grading controller - notifications = controller_qs.check_combined_notifications(course.id, student_id, user_is_staff, - last_time_viewed) + notifications = controller_qs.check_combined_notifications( + course.id, + student_id, + user_is_staff, + last_time_viewed, + ) if notifications.get('success'): if (notifications.get('staff_needs_to_grade') or notifications.get('student_needs_to_peer_grade')): diff --git a/pavelib/paver_tests/test_paver_bok_choy_cmds.py b/pavelib/paver_tests/test_paver_bok_choy_cmds.py index fbddd16ae4..4685930c7c 100644 --- a/pavelib/paver_tests/test_paver_bok_choy_cmds.py +++ b/pavelib/paver_tests/test_paver_bok_choy_cmds.py @@ -14,14 +14,18 @@ class TestPaverBokChoy(unittest.TestCase): def _expected_command(self, expected_text_append): if expected_text_append: expected_text_append = "/" + expected_text_append - expected_statement = ("DEFAULT_STORE=None SCREENSHOT_DIR='{repo_dir}/test_root/log' " - "BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log/hars' " - "SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log' " - "nosetests {repo_dir}/common/test/acceptance/tests{exp_text} " - "--with-xunit " - "--xunit-file={repo_dir}/reports/bok_choy/xunit.xml " - "--verbosity=2 ".format(repo_dir=REPO_DIR, - exp_text=expected_text_append)) + expected_statement = ( + "DEFAULT_STORE=None SCREENSHOT_DIR='{repo_dir}/test_root/log' " + "BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log/hars' " + "SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log' " + "nosetests {repo_dir}/common/test/acceptance/tests{exp_text} " + "--with-xunit " + "--xunit-file={repo_dir}/reports/bok_choy/xunit.xml " + "--verbosity=2 ".format( + repo_dir=REPO_DIR, + exp_text=expected_text_append, + ) + ) return expected_statement def test_default_bokchoy(self):