From feaf5011c89629209991a3f83af67d8ab59513ea Mon Sep 17 00:00:00 2001 From: "M. Zulqarnain" <muhammad.zulqarnain@arbisoft.com> Date: Wed, 3 Feb 2021 18:15:03 +0500 Subject: [PATCH] BOM-2287 : Pylint amnesty in teams,tests,survey and verify_student (#26305) * lint amnesty in teams,tests,survey and verify_student --- lms/djangoapps/courseware/field_overrides.py | 2 +- lms/djangoapps/survey/exceptions.py | 4 ++-- lms/djangoapps/survey/models.py | 6 +++--- lms/djangoapps/survey/tests/factories.py | 5 +++-- lms/djangoapps/survey/tests/test_models.py | 6 +++--- lms/djangoapps/survey/tests/test_utils.py | 4 ++-- lms/djangoapps/survey/tests/test_views.py | 2 +- lms/djangoapps/survey/utils.py | 2 +- lms/djangoapps/survey/views.py | 2 +- lms/djangoapps/teams/__init__.py | 2 +- lms/djangoapps/teams/api.py | 4 ++-- lms/djangoapps/teams/csv.py | 2 +- lms/djangoapps/teams/errors.py | 12 +++++------ .../commands/reindex_course_team.py | 2 +- .../tests/test_reindex_course_team.py | 4 ++-- lms/djangoapps/teams/models.py | 16 +++++++-------- lms/djangoapps/teams/search_indexes.py | 4 ++-- lms/djangoapps/teams/serializers.py | 6 +++--- lms/djangoapps/teams/tests/test_csv.py | 16 +++++++-------- lms/djangoapps/teams/tests/test_models.py | 6 +++--- .../teams/tests/test_serializers.py | 4 ++-- lms/djangoapps/teams/tests/test_services.py | 2 +- lms/djangoapps/teams/tests/test_views.py | 16 +++++++-------- lms/djangoapps/teams/views.py | 12 +++++------ lms/djangoapps/tests/test_utils.py | 2 +- lms/djangoapps/verify_student/__init__.py | 2 +- lms/djangoapps/verify_student/admin.py | 2 +- lms/djangoapps/verify_student/image.py | 4 ++-- ...sso_verifications_for_old_account_links.py | 4 ++-- .../commands/manual_verifications.py | 2 +- .../commands/populate_expiration_date.py | 4 ++-- .../retry_failed_photo_verifications.py | 2 +- .../send_verification_expiry_email.py | 20 +++++++++---------- ...sso_verifications_for_old_account_links.py | 8 ++++---- .../tests/test_manual_verify_student.py | 4 ++-- .../test_send_verification_expiry_email.py | 4 ++-- .../commands/tests/test_verify_student.py | 2 +- .../verify_student/message_types.py | 8 ++++---- lms/djangoapps/verify_student/models.py | 8 ++++---- lms/djangoapps/verify_student/services.py | 4 ++-- lms/djangoapps/verify_student/tasks.py | 2 +- .../verify_student/tests/__init__.py | 1 + .../verify_student/tests/factories.py | 6 +++--- .../tests/test_fake_software_secure.py | 10 +++++----- .../verify_student/tests/test_integration.py | 2 +- .../verify_student/tests/test_models.py | 8 ++++---- .../verify_student/tests/test_services.py | 2 +- .../verify_student/tests/test_signals.py | 2 +- .../verify_student/tests/test_tasks.py | 3 ++- .../verify_student/tests/test_utils.py | 2 +- .../verify_student/tests/test_views.py | 18 ++++++++--------- lms/djangoapps/verify_student/views.py | 12 +++++------ lms/lib/xblock/test/test_mixin.py | 2 +- 53 files changed, 147 insertions(+), 144 deletions(-) diff --git a/lms/djangoapps/courseware/field_overrides.py b/lms/djangoapps/courseware/field_overrides.py index 6de340d0843..4b4a10559df 100644 --- a/lms/djangoapps/courseware/field_overrides.py +++ b/lms/djangoapps/courseware/field_overrides.py @@ -199,7 +199,7 @@ class OverrideFieldData(FieldData): return enabled_providers - def __init__(self, user, fallback, providers): + def __init__(self, user, fallback, providers): # pylint: disable=super-init-not-called self.fallback = fallback self.providers = tuple(provider(user, fallback) for provider in providers) diff --git a/lms/djangoapps/survey/exceptions.py b/lms/djangoapps/survey/exceptions.py index 6b883b35bf7..2890af4ca0b 100644 --- a/lms/djangoapps/survey/exceptions.py +++ b/lms/djangoapps/survey/exceptions.py @@ -7,11 +7,11 @@ class SurveyFormNotFound(Exception): """ Thrown when a SurveyForm is not found in the database """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class SurveyFormNameAlreadyExists(Exception): """ Thrown when a SurveyForm is created but that name already exists """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass diff --git a/lms/djangoapps/survey/models.py b/lms/djangoapps/survey/models.py index 4fb87ebac53..c978bc7c36d 100644 --- a/lms/djangoapps/survey/models.py +++ b/lms/djangoapps/survey/models.py @@ -48,7 +48,7 @@ class SurveyForm(TimeStampedModel): self.validate_form_html(self.form) # now call the actual save method - super(SurveyForm, self).save(*args, **kwargs) + super(SurveyForm, self).save(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments @classmethod def validate_form_html(cls, html): @@ -59,9 +59,9 @@ class SurveyForm(TimeStampedModel): fields = cls.get_field_names_from_html(html) except Exception as ex: log.exception(u"Cannot parse SurveyForm html: {}".format(ex)) - raise ValidationError(u"Cannot parse SurveyForm as HTML: {}".format(ex)) + raise ValidationError(u"Cannot parse SurveyForm as HTML: {}".format(ex)) # lint-amnesty, pylint: disable=raise-missing-from - if not len(fields): + if not len(fields): # lint-amnesty, pylint: disable=len-as-condition raise ValidationError("SurveyForms must contain at least one form input field") @classmethod diff --git a/lms/djangoapps/survey/tests/factories.py b/lms/djangoapps/survey/tests/factories.py index ff73e3b1e60..f65732d0009 100644 --- a/lms/djangoapps/survey/tests/factories.py +++ b/lms/djangoapps/survey/tests/factories.py @@ -1,10 +1,11 @@ +# lint-amnesty, pylint: disable=missing-module-docstring import factory from common.djangoapps.student.tests.factories import UserFactory from lms.djangoapps.survey.models import SurveyAnswer, SurveyForm -class SurveyFormFactory(factory.DjangoModelFactory): +class SurveyFormFactory(factory.DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring class Meta(object): model = SurveyForm @@ -12,7 +13,7 @@ class SurveyFormFactory(factory.DjangoModelFactory): form = '<form>First name:<input type="text" name="firstname"/></form>' -class SurveyAnswerFactory(factory.DjangoModelFactory): +class SurveyAnswerFactory(factory.DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring class Meta(object): model = SurveyAnswer diff --git a/lms/djangoapps/survey/tests/test_models.py b/lms/djangoapps/survey/tests/test_models.py index d5dc6995860..9bf85175618 100644 --- a/lms/djangoapps/survey/tests/test_models.py +++ b/lms/djangoapps/survey/tests/test_models.py @@ -7,7 +7,7 @@ from collections import OrderedDict import ddt import six -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ValidationError from django.test import TestCase from django.test.client import Client @@ -26,7 +26,7 @@ class SurveyModelsTests(TestCase): """ Set up the test data used in the specific tests """ - super(SurveyModelsTests, self).setUp() + super(SurveyModelsTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = Client() # Create two accounts @@ -35,7 +35,7 @@ class SurveyModelsTests(TestCase): self.student2 = User.objects.create_user('student2', 'student2@test.com', self.password) self.test_survey_name = 'TestForm' - self.test_form = '<li><input name="field1" /></li><li><input name="field2" /></li><li><select name="ddl"><option>1</option></select></li>' + self.test_form = '<li><input name="field1" /></li><li><input name="field2" /></li><li><select name="ddl"><option>1</option></select></li>' # lint-amnesty, pylint: disable=line-too-long self.test_form_update = '<input name="field1" />' self.course_id = 'foo/bar/baz' diff --git a/lms/djangoapps/survey/tests/test_utils.py b/lms/djangoapps/survey/tests/test_utils.py index 8488f472f03..0df9f44b486 100644 --- a/lms/djangoapps/survey/tests/test_utils.py +++ b/lms/djangoapps/survey/tests/test_utils.py @@ -5,7 +5,7 @@ Python tests for the Survey models from collections import OrderedDict -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.test.client import Client from lms.djangoapps.survey.models import SurveyForm @@ -23,7 +23,7 @@ class SurveyModelsTests(ModuleStoreTestCase): """ Set up the test data used in the specific tests """ - super(SurveyModelsTests, self).setUp() + super(SurveyModelsTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = Client() diff --git a/lms/djangoapps/survey/tests/test_views.py b/lms/djangoapps/survey/tests/test_views.py index dd928d92ee9..c659db1d9b6 100644 --- a/lms/djangoapps/survey/tests/test_views.py +++ b/lms/djangoapps/survey/tests/test_views.py @@ -25,7 +25,7 @@ class SurveyViewsTests(ModuleStoreTestCase): """ Set up the test data used in the specific tests """ - super(SurveyViewsTests, self).setUp() + super(SurveyViewsTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = Client() diff --git a/lms/djangoapps/survey/utils.py b/lms/djangoapps/survey/utils.py index eca7c713ab2..246c573d690 100644 --- a/lms/djangoapps/survey/utils.py +++ b/lms/djangoapps/survey/utils.py @@ -18,7 +18,7 @@ class SurveyRequiredAccessError(AccessError): error_code = "survey_required" developer_message = u"User must complete a survey" user_message = _(u"You must complete a survey") - super(SurveyRequiredAccessError, self).__init__(error_code, developer_message, user_message) + super(SurveyRequiredAccessError, self).__init__(error_code, developer_message, user_message) # lint-amnesty, pylint: disable=super-with-arguments def is_survey_required_for_course(course_descriptor): diff --git a/lms/djangoapps/survey/views.py b/lms/djangoapps/survey/views.py index 779a05ed78a..b0362ce5403 100644 --- a/lms/djangoapps/survey/views.py +++ b/lms/djangoapps/survey/views.py @@ -99,7 +99,7 @@ def submit_answers(request, survey_name): # scrub the answers to make sure nothing malicious from the user gets stored in # our database, e.g. JavaScript filtered_answers = {} - for answer_key in answers.keys(): + for answer_key in answers.keys(): # lint-amnesty, pylint: disable=consider-iterating-dictionary # only allow known input fields if answer_key in allowed_field_names: filtered_answers[answer_key] = escape(answers[answer_key]) diff --git a/lms/djangoapps/teams/__init__.py b/lms/djangoapps/teams/__init__.py index f2600b66dbc..4259abf7f6a 100644 --- a/lms/djangoapps/teams/__init__.py +++ b/lms/djangoapps/teams/__init__.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured Defines common methods shared by Teams classes """ diff --git a/lms/djangoapps/teams/api.py b/lms/djangoapps/teams/api.py index 143f3548a61..4e91892b9c7 100644 --- a/lms/djangoapps/teams/api.py +++ b/lms/djangoapps/teams/api.py @@ -185,7 +185,7 @@ def user_organization_protection_status(user, course_key): else: return OrganizationProtectionStatus.unprotected else: - raise ValueError( + raise ValueError( # lint-amnesty, pylint: disable=raising-format-tuple 'Cannot check the org_protection status on a student [%s] not enrolled in course [%s]', user.id, course_key @@ -349,7 +349,7 @@ def get_team_for_user_course_topic(user, course_id, topic_id): try: course_key = CourseKey.from_string(course_id) except InvalidKeyError: - raise ValueError(u"The supplied course id {course_id} is not valid.".format( + raise ValueError(u"The supplied course id {course_id} is not valid.".format( # lint-amnesty, pylint: disable=raise-missing-from course_id=course_id )) try: diff --git a/lms/djangoapps/teams/csv.py b/lms/djangoapps/teams/csv.py index f3690f0bbb3..e6c672d2e4e 100644 --- a/lms/djangoapps/teams/csv.py +++ b/lms/djangoapps/teams/csv.py @@ -5,7 +5,7 @@ CSV processing and generation utilities for Teams LMS app. import csv from collections import Counter -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db.models import Prefetch from lms.djangoapps.teams.api import ( diff --git a/lms/djangoapps/teams/errors.py b/lms/djangoapps/teams/errors.py index acf7df915f6..9222254e855 100644 --- a/lms/djangoapps/teams/errors.py +++ b/lms/djangoapps/teams/errors.py @@ -5,17 +5,17 @@ Errors thrown in the Team API. class TeamAPIRequestError(Exception): """There was a problem with a request to the Team API.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class NotEnrolledInCourseForTeam(TeamAPIRequestError): """User is not enrolled in the course for the team they are trying to join.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AlreadyOnTeamInTeamset(TeamAPIRequestError): """User is already a member of another team in the same teamset.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AddToIncompatibleTeamError(TeamAPIRequestError): @@ -23,14 +23,14 @@ class AddToIncompatibleTeamError(TeamAPIRequestError): User is enrolled in a mode that is incompatible with this team type. e.g. Masters learners cannot be placed in a team with audit learners """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class ElasticSearchConnectionError(TeamAPIRequestError): """The system was unable to connect to the configured elasticsearch instance.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class ImmutableMembershipFieldException(Exception): """An attempt was made to change an immutable field on a CourseTeamMembership model.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass diff --git a/lms/djangoapps/teams/management/commands/reindex_course_team.py b/lms/djangoapps/teams/management/commands/reindex_course_team.py index 6ea33749190..6f047877df0 100644 --- a/lms/djangoapps/teams/management/commands/reindex_course_team.py +++ b/lms/djangoapps/teams/management/commands/reindex_course_team.py @@ -38,7 +38,7 @@ class Command(BaseCommand): try: result = CourseTeam.objects.get(team_id=team_id) except ObjectDoesNotExist: - raise CommandError('Argument {} is not a course_team team_id'.format(team_id)) + raise CommandError('Argument {} is not a course_team team_id'.format(team_id)) # lint-amnesty, pylint: disable=raise-missing-from return result diff --git a/lms/djangoapps/teams/management/commands/tests/test_reindex_course_team.py b/lms/djangoapps/teams/management/commands/tests/test_reindex_course_team.py index 43bb4f470b5..10b289d0394 100644 --- a/lms/djangoapps/teams/management/commands/tests/test_reindex_course_team.py +++ b/lms/djangoapps/teams/management/commands/tests/test_reindex_course_team.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=cyclic-import Tests for course_team reindex command. """ @@ -27,7 +27,7 @@ class ReindexCourseTeamTest(SharedModuleStoreTestCase): """ Set up tests. """ - super(ReindexCourseTeamTest, self).setUp() + super(ReindexCourseTeamTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.team1 = CourseTeamFactory(course_id=COURSE_KEY1, team_id='team1') self.team2 = CourseTeamFactory(course_id=COURSE_KEY1, team_id='team2') diff --git a/lms/djangoapps/teams/models.py b/lms/djangoapps/teams/models.py index 7f362e5806a..24fde748d86 100644 --- a/lms/djangoapps/teams/models.py +++ b/lms/djangoapps/teams/models.py @@ -7,7 +7,7 @@ from datetime import datetime from uuid import uuid4 import pytz -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ObjectDoesNotExist from django.db import models from django.dispatch import receiver @@ -115,7 +115,7 @@ class CourseTeam(models.Model): return "{} in {}".format(self.name, self.course_id) def __repr__(self): - return ( + return ( # lint-amnesty, pylint: disable=missing-format-attribute "<CourseTeam" " id={0.id}" " team_id={0.team_id}" @@ -236,7 +236,7 @@ class CourseTeamMembership(models.Model): return "{} is member of {}".format(self.user.username, self.team) def __repr__(self): - return ( + return ( # lint-amnesty, pylint: disable=missing-format-attribute "<CourseTeamMembership" " id={0.id}" " user_id={0.user.id}" @@ -277,9 +277,9 @@ class CourseTeamMembership(models.Model): raise ImmutableMembershipFieldException( u"Field %r shouldn't change from %r to %r" % (name, current_value, value) ) - super(CourseTeamMembership, self).__setattr__(name, value) + super(CourseTeamMembership, self).__setattr__(name, value) # lint-amnesty, pylint: disable=super-with-arguments - def save(self, *args, **kwargs): # pylint: disable=arguments-differ + def save(self, *args, **kwargs): # lint-amnesty, pylint: disable=arguments-differ, signature-differs """Customize save method to set the last_activity_at if it does not currently exist. Also resets the team's size if this model is being created. @@ -289,13 +289,13 @@ class CourseTeamMembership(models.Model): should_reset_team_size = True if not self.last_activity_at: self.last_activity_at = datetime.utcnow().replace(tzinfo=pytz.utc) - super(CourseTeamMembership, self).save(*args, **kwargs) + super(CourseTeamMembership, self).save(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments if should_reset_team_size: self.team.reset_team_size() - def delete(self, *args, **kwargs): # pylint: disable=arguments-differ + def delete(self, *args, **kwargs): # lint-amnesty, pylint: disable=arguments-differ, signature-differs """Recompute the related team's team_size after deleting a membership""" - super(CourseTeamMembership, self).delete(*args, **kwargs) + super(CourseTeamMembership, self).delete(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.team.reset_team_size() @classmethod diff --git a/lms/djangoapps/teams/search_indexes.py b/lms/djangoapps/teams/search_indexes.py index 32da8d5ae12..048a3071942 100644 --- a/lms/djangoapps/teams/search_indexes.py +++ b/lms/djangoapps/teams/search_indexes.py @@ -10,7 +10,7 @@ from django.conf import settings from django.db.models.signals import post_delete, post_save from django.dispatch import receiver from django.utils import translation -from elasticsearch.exceptions import ConnectionError +from elasticsearch.exceptions import ConnectionError # lint-amnesty, pylint: disable=redefined-builtin from search.search_engine_base import SearchEngine from lms.djangoapps.teams.models import CourseTeam @@ -124,7 +124,7 @@ class CourseTeamIndexer(object): return SearchEngine.get_search_engine(index=cls.INDEX_NAME) except ConnectionError as err: logging.error(u'Error connecting to elasticsearch: %s', err) - raise ElasticSearchConnectionError + raise ElasticSearchConnectionError # lint-amnesty, pylint: disable=raise-missing-from @classmethod def search_is_enabled(cls): diff --git a/lms/djangoapps/teams/serializers.py b/lms/djangoapps/teams/serializers.py index 37d1f40f6b5..9aab17694ac 100644 --- a/lms/djangoapps/teams/serializers.py +++ b/lms/djangoapps/teams/serializers.py @@ -7,7 +7,7 @@ from copy import deepcopy import six from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django_countries import countries from rest_framework import serializers @@ -135,7 +135,7 @@ class CourseTeamSerializerWithoutMembership(CourseTeamSerializer): """ def __init__(self, *args, **kwargs): - super(CourseTeamSerializerWithoutMembership, self).__init__(*args, **kwargs) + super(CourseTeamSerializerWithoutMembership, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments del self.fields['membership'] @@ -209,7 +209,7 @@ class BulkTeamCountTopicListSerializer(serializers.ListSerializer): # pylint: d def to_representation(self, obj): # pylint: disable=arguments-differ """Adds team_count to each topic. """ - data = super(BulkTeamCountTopicListSerializer, self).to_representation(obj) + data = super(BulkTeamCountTopicListSerializer, self).to_representation(obj) # lint-amnesty, pylint: disable=super-with-arguments add_team_count( self.context['request'].user, data, diff --git a/lms/djangoapps/teams/tests/test_csv.py b/lms/djangoapps/teams/tests/test_csv.py index cdb80bbb4f7..371d09bf960 100644 --- a/lms/djangoapps/teams/tests/test_csv.py +++ b/lms/djangoapps/teams/tests/test_csv.py @@ -2,7 +2,7 @@ from csv import DictWriter, DictReader from io import BytesIO, StringIO, TextIOWrapper -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user, unused-import from lms.djangoapps.program_enrollments.tests.factories import ProgramEnrollmentFactory, ProgramCourseEnrollmentFactory from lms.djangoapps.teams import csv @@ -252,7 +252,7 @@ class TeamMembershipImportManagerTests(TeamMembershipEventTestMixin, SharedModul def setUp(self): """ Initialize import manager """ - super(TeamMembershipImportManagerTests, self).setUp() + super(TeamMembershipImportManagerTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.import_manager = csv.TeamMembershipImportManager(self.course) self.import_manager.teamset_ids = {ts.teamset_id for ts in self.course.teamsets} @@ -261,10 +261,10 @@ class TeamMembershipImportManagerTests(TeamMembershipEventTestMixin, SharedModul Lodaing course teams shold get the users by team with only 2 queries 1 for teams, 1 for user count """ - team1 = CourseTeamFactory.create(course_id=self.course.id) - team2 = CourseTeamFactory.create(course_id=self.course.id) - team3 = CourseTeamFactory.create(course_id=self.course.id) - team4 = CourseTeamFactory.create(course_id=self.course.id) + team1 = CourseTeamFactory.create(course_id=self.course.id) # lint-amnesty, pylint: disable=unused-variable + team2 = CourseTeamFactory.create(course_id=self.course.id) # lint-amnesty, pylint: disable=unused-variable + team3 = CourseTeamFactory.create(course_id=self.course.id) # lint-amnesty, pylint: disable=unused-variable + team4 = CourseTeamFactory.create(course_id=self.course.id) # lint-amnesty, pylint: disable=unused-variable with self.assertNumQueries(2): self.import_manager.load_course_teams() @@ -405,7 +405,7 @@ class TeamMembershipImportManagerTests(TeamMembershipEventTestMixin, SharedModul ['user', 'mode', 'teamset_1'], [user.username, mode, ''], ]) - result = self.import_manager.set_team_memberships(csv_data) + result = self.import_manager.set_team_memberships(csv_data) # lint-amnesty, pylint: disable=unused-variable # Then they are removed from the team and the correct events are issued self.assertFalse(CourseTeamMembership.is_user_on_team(user, team)) @@ -458,7 +458,7 @@ class TeamMembershipImportManagerTests(TeamMembershipEventTestMixin, SharedModul ['user', 'mode', 'teamset_1'], [user.username, mode, 'new_exciting_team'], ]) - result = self.import_manager.set_team_memberships(csv_data) + result = self.import_manager.set_team_memberships(csv_data) # lint-amnesty, pylint: disable=unused-variable # Then a new team is created self.assertEqual(CourseTeam.objects.all().count(), 1) diff --git a/lms/djangoapps/teams/tests/test_models.py b/lms/djangoapps/teams/tests/test_models.py index 50fa17b8a44..eac072b988b 100644 --- a/lms/djangoapps/teams/tests/test_models.py +++ b/lms/djangoapps/teams/tests/test_models.py @@ -11,7 +11,7 @@ from datetime import datetime import ddt import pytz import six -from mock import Mock, patch +from mock import Mock, patch # lint-amnesty, pylint: disable=unused-import from opaque_keys.edx.keys import CourseKey from common.djangoapps.course_modes.models import CourseMode @@ -161,7 +161,7 @@ class TeamMembershipTest(SharedModuleStoreTestCase): """ Set up tests. """ - super(TeamMembershipTest, self).setUp() + super(TeamMembershipTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user1 = UserFactory.create(username='user1') self.user2 = UserFactory.create(username='user2') @@ -266,7 +266,7 @@ class TeamSignalsTest(EventTestMixin, SharedModuleStoreTestCase): def setUp(self): # pylint: disable=arguments-differ """Create a user with a team to test signals.""" - super(TeamSignalsTest, self).setUp('lms.djangoapps.teams.utils.tracker') + super(TeamSignalsTest, self).setUp('lms.djangoapps.teams.utils.tracker') # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username="user") self.moderator = UserFactory.create(username="moderator") self.team = CourseTeamFactory(discussion_topic_id=self.DISCUSSION_TOPIC_ID) diff --git a/lms/djangoapps/teams/tests/test_serializers.py b/lms/djangoapps/teams/tests/test_serializers.py index 809da1c7853..517146e6585 100644 --- a/lms/djangoapps/teams/tests/test_serializers.py +++ b/lms/djangoapps/teams/tests/test_serializers.py @@ -24,7 +24,7 @@ class SerializerTestCase(SharedModuleStoreTestCase): """ Set up a course with a teams configuration. """ - super(SerializerTestCase, self).setUp() + super(SerializerTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create( teams_configuration=TeamsConfig({ "max_team_size": 10, @@ -39,7 +39,7 @@ class MembershipSerializerTestCase(SerializerTestCase): """ def setUp(self): - super(MembershipSerializerTestCase, self).setUp() + super(MembershipSerializerTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.team = CourseTeamFactory.create( course_id=self.course.id, topic_id=self.course.teamsets[0].teamset_id, diff --git a/lms/djangoapps/teams/tests/test_services.py b/lms/djangoapps/teams/tests/test_services.py index 5172ab84a57..7423da77b83 100644 --- a/lms/djangoapps/teams/tests/test_services.py +++ b/lms/djangoapps/teams/tests/test_services.py @@ -16,7 +16,7 @@ class TeamsServiceTests(ModuleStoreTestCase): """ Tests for the TeamsService """ def setUp(self): - super(TeamsServiceTests, self).setUp() + super(TeamsServiceTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course_run = CourseRunFactory.create() self.course_key = self.course_run['key'] self.team = CourseTeamFactory.create(course_id=self.course_key) diff --git a/lms/djangoapps/teams/tests/test_views.py b/lms/djangoapps/teams/tests/test_views.py index 2728e32faf0..d63c24b68e1 100644 --- a/lms/djangoapps/teams/tests/test_views.py +++ b/lms/djangoapps/teams/tests/test_views.py @@ -17,7 +17,7 @@ from django.db.models.signals import post_save from django.core.files.uploadedfile import SimpleUploadedFile from django.urls import reverse from django.utils import translation -from elasticsearch.exceptions import ConnectionError +from elasticsearch.exceptions import ConnectionError # lint-amnesty, pylint: disable=redefined-builtin from mock import patch from rest_framework.test import APIClient, APITestCase from search.search_engine_base import SearchEngine @@ -69,7 +69,7 @@ class TestDashboard(SharedModuleStoreTestCase): """ Set up tests """ - super(TestDashboard, self).setUp() + super(TestDashboard, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # will be assigned to self.client by default self.user = UserFactory.create(password=self.test_password) self.teams_url = reverse('teams_dashboard', args=[self.course.id]) @@ -779,7 +779,7 @@ class TestListTeamsAPI(EventTestMixin, TeamAPITestCase): """Test cases for the team listing API endpoint.""" def setUp(self): # pylint: disable=arguments-differ - super(TestListTeamsAPI, self).setUp('lms.djangoapps.teams.utils.tracker') + super(TestListTeamsAPI, self).setUp('lms.djangoapps.teams.utils.tracker') # lint-amnesty, pylint: disable=super-with-arguments @ddt.data( (None, 401), @@ -1084,7 +1084,7 @@ class TestCreateTeamAPI(EventTestMixin, TeamAPITestCase): """Test cases for the team creation endpoint.""" def setUp(self): # pylint: disable=arguments-differ - super(TestCreateTeamAPI, self).setUp('lms.djangoapps.teams.utils.tracker') + super(TestCreateTeamAPI, self).setUp('lms.djangoapps.teams.utils.tracker') # lint-amnesty, pylint: disable=super-with-arguments @ddt.data( (None, 401), @@ -1402,7 +1402,7 @@ class TestDeleteTeamAPI(EventTestMixin, TeamAPITestCase): """Test cases for the team delete endpoint.""" def setUp(self): # pylint: disable=arguments-differ - super(TestDeleteTeamAPI, self).setUp('lms.djangoapps.teams.utils.tracker') + super(TestDeleteTeamAPI, self).setUp('lms.djangoapps.teams.utils.tracker') # lint-amnesty, pylint: disable=super-with-arguments @ddt.data( ('staff', 204), @@ -1518,7 +1518,7 @@ class TestUpdateTeamAPI(EventTestMixin, TeamAPITestCase): """Test cases for the team update endpoint.""" def setUp(self): # pylint: disable=arguments-differ - super(TestUpdateTeamAPI, self).setUp('lms.djangoapps.teams.utils.tracker') + super(TestUpdateTeamAPI, self).setUp('lms.djangoapps.teams.utils.tracker') # lint-amnesty, pylint: disable=super-with-arguments @ddt.data( (None, 401), @@ -2312,7 +2312,7 @@ class TestCreateMembershipAPI(EventTestMixin, TeamAPITestCase): """Test cases for the membership creation endpoint.""" def setUp(self): # pylint: disable=arguments-differ - super(TestCreateMembershipAPI, self).setUp('lms.djangoapps.teams.utils.tracker') + super(TestCreateMembershipAPI, self).setUp('lms.djangoapps.teams.utils.tracker') # lint-amnesty, pylint: disable=super-with-arguments @ddt.data( (None, 401), @@ -2601,7 +2601,7 @@ class TestDeleteMembershipAPI(EventTestMixin, TeamAPITestCase): """Test cases for the membership deletion endpoint.""" def setUp(self): # pylint: disable=arguments-differ - super(TestDeleteMembershipAPI, self).setUp('lms.djangoapps.teams.utils.tracker') + super(TestDeleteMembershipAPI, self).setUp('lms.djangoapps.teams.utils.tracker') # lint-amnesty, pylint: disable=super-with-arguments @ddt.data( (None, 401), diff --git a/lms/djangoapps/teams/views.py b/lms/djangoapps/teams/views.py index e273e7ccfba..73dd836bc6f 100644 --- a/lms/djangoapps/teams/views.py +++ b/lms/djangoapps/teams/views.py @@ -8,7 +8,7 @@ from collections import Counter import six from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import PermissionDenied from django.db.models.signals import post_save from django.dispatch import receiver @@ -676,7 +676,7 @@ class IsStaffOrPrivilegedOrReadOnly(IsStaffOrReadOnly): return ( has_discussion_privileges(request.user, obj.course_id) or IsCourseStaffInstructor.has_object_permission(self, request, view, obj) or - super(IsStaffOrPrivilegedOrReadOnly, self).has_object_permission(request, view, obj) + super(IsStaffOrPrivilegedOrReadOnly, self).has_object_permission(request, view, obj) # lint-amnesty, pylint: disable=super-with-arguments ) @@ -1302,7 +1302,7 @@ class MembershipListView(ExpandableFieldViewMixin, GenericAPIView): permission_classes = (permissions.IsAuthenticated,) serializer_class = MembershipSerializer - def get(self, request): + def get(self, request): # lint-amnesty, pylint: disable=too-many-statements """GET /api/team/v0/team_membership""" specified_username_or_team = False username = None @@ -1564,14 +1564,14 @@ class MembershipDetailView(ExpandableFieldViewMixin, GenericAPIView): try: return CourseTeam.objects.get(team_id=team_id) except CourseTeam.DoesNotExist: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from def get_membership(self, username, team): """Returns the membership for the given user and team, or throws Http404 if it does not exist.""" try: return CourseTeamMembership.objects.get(user__username=username, team=team) except CourseTeamMembership.DoesNotExist: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from def get(self, request, team_id, username): """GET /api/team/v0/team_membership/{team_id},{username}""" @@ -1681,7 +1681,7 @@ class MembershipBulkManagementView(GenericAPIView): try: course_id = CourseKey.from_string(course_id_string) except InvalidKeyError: - raise Http404('Invalid course key: {}'.format(course_id_string)) + raise Http404('Invalid course key: {}'.format(course_id_string)) # lint-amnesty, pylint: disable=raise-missing-from course_module = modulestore().get_course(course_id) if not course_module: raise Http404('Course not found: {}'.format(course_id)) diff --git a/lms/djangoapps/tests/test_utils.py b/lms/djangoapps/tests/test_utils.py index 0d809a9eb71..509028a98d6 100644 --- a/lms/djangoapps/tests/test_utils.py +++ b/lms/djangoapps/tests/test_utils.py @@ -12,7 +12,7 @@ from lms.djangoapps.utils import _get_key @ddt.ddt -class UtilsTests(TestCase): +class UtilsTests(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring @ddt.data( ['edX/DemoX/Demo_Course', CourseKey.from_string('edX/DemoX/Demo_Course'), CourseKey], diff --git a/lms/djangoapps/verify_student/__init__.py b/lms/djangoapps/verify_student/__init__.py index cf9ef2ad158..f099a835f8c 100644 --- a/lms/djangoapps/verify_student/__init__.py +++ b/lms/djangoapps/verify_student/__init__.py @@ -1,3 +1,3 @@ -""" +""" # lint-amnesty, pylint: disable=django-not-configured Student Identity Verification App """ diff --git a/lms/djangoapps/verify_student/admin.py b/lms/djangoapps/verify_student/admin.py index 9541a1ebd06..b4ea2aae1bb 100644 --- a/lms/djangoapps/verify_student/admin.py +++ b/lms/djangoapps/verify_student/admin.py @@ -47,4 +47,4 @@ class SSPVerificationRetryAdmin(admin.ModelAdmin): """ Admin for the SSPVerificationRetryConfig table. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass diff --git a/lms/djangoapps/verify_student/image.py b/lms/djangoapps/verify_student/image.py index 3209b2a3958..597c74b915a 100644 --- a/lms/djangoapps/verify_student/image.py +++ b/lms/djangoapps/verify_student/image.py @@ -13,7 +13,7 @@ class InvalidImageData(Exception): """ The provided image data could not be decoded. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def decode_image_data(data): @@ -34,4 +34,4 @@ def decode_image_data(data): return base64.b64decode(data.split(",")[1]) except (IndexError, UnicodeEncodeError): log.exception("Could not decode image data") - raise InvalidImageData + raise InvalidImageData # lint-amnesty, pylint: disable=raise-missing-from diff --git a/lms/djangoapps/verify_student/management/commands/backfill_sso_verifications_for_old_account_links.py b/lms/djangoapps/verify_student/management/commands/backfill_sso_verifications_for_old_account_links.py index 4126bacc6cf..16e6fc7aaeb 100644 --- a/lms/djangoapps/verify_student/management/commands/backfill_sso_verifications_for_old_account_links.py +++ b/lms/djangoapps/verify_student/management/commands/backfill_sso_verifications_for_old_account_links.py @@ -49,8 +49,8 @@ class Command(BaseCommand): try: provider = Registry.get(provider_slug) - except ValueError as e: - raise CommandError('provider slug {slug} does not exist'.format(slug=provider_slug)) + except ValueError as e: # lint-amnesty, pylint: disable=unused-variable + raise CommandError('provider slug {slug} does not exist'.format(slug=provider_slug)) # lint-amnesty, pylint: disable=raise-missing-from query_set = UserSocialAuth.objects.select_related('user__profile') query_set = filter_user_social_auth_queryset_by_provider(query_set, provider) diff --git a/lms/djangoapps/verify_student/management/commands/manual_verifications.py b/lms/djangoapps/verify_student/management/commands/manual_verifications.py index 47a98699794..4205fc1f179 100644 --- a/lms/djangoapps/verify_student/management/commands/manual_verifications.py +++ b/lms/djangoapps/verify_student/management/commands/manual_verifications.py @@ -7,7 +7,7 @@ import logging import os from pprint import pformat -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.management.base import BaseCommand, CommandError from lms.djangoapps.verify_student.models import ManualVerification diff --git a/lms/djangoapps/verify_student/management/commands/populate_expiration_date.py b/lms/djangoapps/verify_student/management/commands/populate_expiration_date.py index f44bae74046..6932ef2d3b6 100644 --- a/lms/djangoapps/verify_student/management/commands/populate_expiration_date.py +++ b/lms/djangoapps/verify_student/management/commands/populate_expiration_date.py @@ -5,9 +5,9 @@ Django admin command to populate expiration_date for approved verifications in S import logging import time -from datetime import timedelta +from datetime import timedelta # lint-amnesty, pylint: disable=unused-import -from django.conf import settings +from django.conf import settings # lint-amnesty, pylint: disable=unused-import from django.core.management.base import BaseCommand from django.db.models import F diff --git a/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py b/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py index 7b900f9a819..352b23cb153 100644 --- a/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py +++ b/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py @@ -5,7 +5,7 @@ Django admin commands related to verify_student import logging from django.core.management.base import BaseCommand -from django.core.management.base import CommandError +from django.core.management.base import CommandError # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification, SSPVerificationRetryConfig diff --git a/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py b/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py index 9ae840a2c96..89fbe3782bf 100644 --- a/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py +++ b/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py @@ -8,21 +8,21 @@ import time from datetime import timedelta from common.djangoapps.course_modes.models import CourseMode -from django.conf import settings -from django.contrib.auth.models import User -from django.contrib.sites.models import Site -from django.core.management.base import BaseCommand, CommandError -from django.db.models import Q -from django.urls import reverse -from django.utils.timezone import now -from edx_ace import ace -from edx_ace.recipient import Recipient +from django.conf import settings # lint-amnesty, pylint: disable=wrong-import-order +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user, wrong-import-order +from django.contrib.sites.models import Site # lint-amnesty, pylint: disable=wrong-import-order +from django.core.management.base import BaseCommand, CommandError # lint-amnesty, pylint: disable=wrong-import-order +from django.db.models import Q # lint-amnesty, pylint: disable=wrong-import-order +from django.urls import reverse # lint-amnesty, pylint: disable=unused-import, wrong-import-order +from django.utils.timezone import now # lint-amnesty, pylint: disable=wrong-import-order +from edx_ace import ace # lint-amnesty, pylint: disable=wrong-import-order +from edx_ace.recipient import Recipient # lint-amnesty, pylint: disable=wrong-import-order from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.util.query import use_read_replica_if_available from lms.djangoapps.verify_student.message_types import VerificationExpiry from lms.djangoapps.verify_student.models import ManualVerification, SoftwareSecurePhotoVerification, SSOVerification -from lms.djangoapps.verify_student.services import IDVerificationService +from lms.djangoapps.verify_student.services import IDVerificationService # lint-amnesty, pylint: disable=unused-import from openedx.core.djangoapps.ace_common.template_context import get_base_template_context from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY from openedx.core.djangoapps.user_api.preferences.api import get_user_preference diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_backfill_sso_verifications_for_old_account_links.py b/lms/djangoapps/verify_student/management/commands/tests/test_backfill_sso_verifications_for_old_account_links.py index b0181efaa30..f84ad100dea 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_backfill_sso_verifications_for_old_account_links.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_backfill_sso_verifications_for_old_account_links.py @@ -20,7 +20,7 @@ class TestBackfillSSOVerificationsCommand(TestCase): slug = 'test' def setUp(self): - super(TestBackfillSSOVerificationsCommand, self).setUp() + super(TestBackfillSSOVerificationsCommand, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.enable_saml() self.provider = self.configure_saml_provider( name="Test", @@ -41,9 +41,9 @@ class TestBackfillSSOVerificationsCommand(TestCase): call_command('backfill_sso_verifications_for_old_account_links', '--provider-slug', 'gatech') def test_sso_updated_single_user(self): - self.assertTrue(SSOVerification.objects.count() == 0) + self.assertTrue(SSOVerification.objects.count() == 0) # lint-amnesty, pylint: disable=wrong-assert-type call_command('backfill_sso_verifications_for_old_account_links', '--provider-slug', self.provider.provider_id) - self.assertTrue(SSOVerification.objects.count() > 0) + self.assertTrue(SSOVerification.objects.count() > 0) # lint-amnesty, pylint: disable=wrong-assert-type self.assertEqual(SSOVerification.objects.get().user.id, self.user1.id) def test_performance(self): @@ -54,7 +54,7 @@ class TestBackfillSSOVerificationsCommand(TestCase): def test_signal_called(self): with patch('openedx.core.djangoapps.signals.signals.LEARNER_NOW_VERIFIED.send_robust') as mock_signal: - call_command('backfill_sso_verifications_for_old_account_links', '--provider-slug', self.provider.provider_id) + call_command('backfill_sso_verifications_for_old_account_links', '--provider-slug', self.provider.provider_id) # lint-amnesty, pylint: disable=line-too-long self.assertEqual(mock_signal.call_count, 1) def test_fine_with_multiple_verification_records(self): diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_manual_verify_student.py b/lms/djangoapps/verify_student/management/commands/tests/test_manual_verify_student.py index cd2ac26bdfb..d178b78f8f2 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_manual_verify_student.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_manual_verify_student.py @@ -1,4 +1,4 @@ -""" +""" # lint-amnesty, pylint: disable=cyclic-import Tests for django admin commands in the verify_student module """ @@ -27,7 +27,7 @@ class TestVerifyStudentCommand(TestCase): tmp_file_path = os.path.join(tempfile.gettempdir(), 'tmp-emails.txt') def setUp(self): - super(TestVerifyStudentCommand, self).setUp() + super(TestVerifyStudentCommand, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user1 = UserFactory.create() self.user2 = UserFactory.create() self.user3 = UserFactory.create() diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py b/lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py index d01e44c4bcc..7f0e3772216 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py @@ -14,7 +14,7 @@ from django.test.utils import override_settings from django.utils.timezone import now from mock import patch from common.djangoapps.student.tests.factories import UserFactory -from testfixtures import LogCapture +from testfixtures import LogCapture # lint-amnesty, pylint: disable=wrong-import-order from common.test.utils import MockS3BotoMixin from lms.djangoapps.verify_student.models import ManualVerification, SoftwareSecurePhotoVerification, SSOVerification @@ -30,7 +30,7 @@ class TestSendVerificationExpiryEmail(MockS3BotoMixin, TestCase): def setUp(self): """ Initial set up for tests """ - super(TestSendVerificationExpiryEmail, self).setUp() + super(TestSendVerificationExpiryEmail, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments Site.objects.create(domain='edx.org', name='edx.org') self.resend_days = settings.VERIFICATION_EXPIRY_EMAIL['RESEND_DAYS'] self.days = settings.VERIFICATION_EXPIRY_EMAIL['DAYS_RANGE'] diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py b/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py index c88dc6758c1..84a902118c9 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py @@ -17,7 +17,7 @@ from lms.djangoapps.verify_student.tests.test_models import ( mock_software_secure_post, mock_software_secure_post_error ) -from common.djangoapps.student.tests.factories import UserFactory # pylint: disable=import-error, useless-suppression +from common.djangoapps.student.tests.factories import UserFactory # lint-amnesty, pylint: disable=import-error, unused-import, useless-suppression LOGGER_NAME = 'retry_photo_verification' diff --git a/lms/djangoapps/verify_student/message_types.py b/lms/djangoapps/verify_student/message_types.py index ccad5b30e97..7d4b80dee78 100644 --- a/lms/djangoapps/verify_student/message_types.py +++ b/lms/djangoapps/verify_student/message_types.py @@ -4,12 +4,12 @@ ACE message types for the verify_student module. from openedx.core.djangoapps.ace_common.message import BaseMessageType -class VerificationExpiry(BaseMessageType): +class VerificationExpiry(BaseMessageType): # lint-amnesty, pylint: disable=missing-class-docstring APP_LABEL = 'verify_student' Name = 'verificationexpiry' def __init__(self, *args, **kwargs): - super(VerificationExpiry, self).__init__(*args, **kwargs) + super(VerificationExpiry, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.options['transactional'] = True @@ -22,7 +22,7 @@ class VerificationApproved(BaseMessageType): Name = 'verificationapproved' def __init__(self, *args, **kwargs): - super(VerificationApproved, self).__init__(*args, **kwargs) + super(VerificationApproved, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.options['transactional'] = True @@ -34,5 +34,5 @@ class VerificationSubmitted(BaseMessageType): Name = 'verificationsubmitted' def __init__(self, *args, **kwargs): - super(VerificationSubmitted, self).__init__(*args, **kwargs) + super(VerificationSubmitted, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.options['transactional'] = True diff --git a/lms/djangoapps/verify_student/models.py b/lms/djangoapps/verify_student/models.py index 0a542839eb4..9c9d035b7ed 100644 --- a/lms/djangoapps/verify_student/models.py +++ b/lms/djangoapps/verify_student/models.py @@ -23,7 +23,7 @@ import requests import six from config_models.models import ConfigurationModel from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.files.base import ContentFile from django.db import models, transaction from django.urls import reverse @@ -119,7 +119,7 @@ class IDVerificationAttempt(StatusModel): created_at = models.DateTimeField(auto_now_add=True, db_index=True) updated_at = models.DateTimeField(auto_now=True, db_index=True) - def expiration_default(): + def expiration_default(): # lint-amnesty, pylint: disable=no-method-argument return now() + timedelta(days=settings.VERIFY_STUDENT["DAYS_GOOD_FOR"]) # Datetime that the verification will expire. @@ -658,7 +658,7 @@ class SoftwareSecurePhotoVerification(PhotoVerification): """Use expiry_date for older entries if it still exists.""" if self.expiry_date: return self.expiry_date - return super(SoftwareSecurePhotoVerification, self).expiration_datetime + return super(SoftwareSecurePhotoVerification, self).expiration_datetime # lint-amnesty, pylint: disable=super-with-arguments @classmethod def get_initial_verification(cls, user, earliest_allowed_date=None): @@ -1083,7 +1083,7 @@ class SoftwareSecurePhotoVerification(PhotoVerification): verification = SoftwareSecurePhotoVerification.get_recent_verification(user) - if verification and verification.expiration_datetime < recently_expired_date and not verification.expiry_email_date: + if verification and verification.expiration_datetime < recently_expired_date and not verification.expiry_email_date: # lint-amnesty, pylint: disable=line-too-long expiry_email_date = today - timedelta(days=email_config['RESEND_DAYS']) SoftwareSecurePhotoVerification.objects.filter(pk=verification.pk).update( expiry_email_date=expiry_email_date) diff --git a/lms/djangoapps/verify_student/services.py b/lms/djangoapps/verify_student/services.py index 1a1bab483c1..3f97ce89638 100644 --- a/lms/djangoapps/verify_student/services.py +++ b/lms/djangoapps/verify_student/services.py @@ -8,7 +8,7 @@ from itertools import chain from urllib.parse import quote from django.conf import settings -from django.urls import reverse +from django.urls import reverse # lint-amnesty, pylint: disable=unused-import from django.utils.timezone import now from django.utils.translation import ugettext as _ @@ -18,7 +18,7 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_ from common.djangoapps.student.models import User from .models import ManualVerification, SoftwareSecurePhotoVerification, SSOVerification -from .utils import earliest_allowed_verification_date, most_recent_verification, active_verifications +from .utils import earliest_allowed_verification_date, most_recent_verification, active_verifications # lint-amnesty, pylint: disable=unused-import log = logging.getLogger(__name__) diff --git a/lms/djangoapps/verify_student/tasks.py b/lms/djangoapps/verify_student/tasks.py index 806c6295d9c..e2987a25483 100644 --- a/lms/djangoapps/verify_student/tasks.py +++ b/lms/djangoapps/verify_student/tasks.py @@ -19,7 +19,7 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_ log = logging.getLogger(__name__) -class BaseSoftwareSecureTask(Task): +class BaseSoftwareSecureTask(Task): # lint-amnesty, pylint: disable=abstract-method """ Base task class for use with Software Secure request. diff --git a/lms/djangoapps/verify_student/tests/__init__.py b/lms/djangoapps/verify_student/tests/__init__.py index 130bdd94086..0ab3ce6c2fa 100644 --- a/lms/djangoapps/verify_student/tests/__init__.py +++ b/lms/djangoapps/verify_student/tests/__init__.py @@ -1,3 +1,4 @@ +# lint-amnesty, pylint: disable=missing-module-docstring from contextlib import contextmanager from datetime import timedelta from unittest import mock diff --git a/lms/djangoapps/verify_student/tests/factories.py b/lms/djangoapps/verify_student/tests/factories.py index e1984a43849..94bf798d5af 100644 --- a/lms/djangoapps/verify_student/tests/factories.py +++ b/lms/djangoapps/verify_student/tests/factories.py @@ -3,10 +3,10 @@ Factories related to student verification. """ -from datetime import timedelta +from datetime import timedelta # lint-amnesty, pylint: disable=unused-import -from django.conf import settings -from django.utils.timezone import now +from django.conf import settings # lint-amnesty, pylint: disable=unused-import +from django.utils.timezone import now # lint-amnesty, pylint: disable=unused-import from factory.django import DjangoModelFactory from lms.djangoapps.verify_student.models import SSOVerification, SoftwareSecurePhotoVerification diff --git a/lms/djangoapps/verify_student/tests/test_fake_software_secure.py b/lms/djangoapps/verify_student/tests/test_fake_software_secure.py index ae4ffec876f..54a61c4f73d 100644 --- a/lms/djangoapps/verify_student/tests/test_fake_software_secure.py +++ b/lms/djangoapps/verify_student/tests/test_fake_software_secure.py @@ -21,7 +21,7 @@ class SoftwareSecureFakeViewTest(UrlResetMixin, TestCase): def setUp(self, **kwargs): enable_software_secure_fake = kwargs.get('enable_software_secure_fake', False) with patch.dict('django.conf.settings.FEATURES', {'ENABLE_SOFTWARE_SECURE_FAKE': enable_software_secure_fake}): - super(SoftwareSecureFakeViewTest, self).setUp() + super(SoftwareSecureFakeViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username="test", password="test") self.attempt = SoftwareSecurePhotoVerification.objects.create(user=self.user) @@ -34,8 +34,8 @@ class SoftwareSecureFakeViewDisabledTest(SoftwareSecureFakeViewTest): 'ENABLE_SOFTWARE_SECURE_FAKE' is not enabled. """ - def setUp(self): - super(SoftwareSecureFakeViewDisabledTest, self).setUp(enable_software_secure_fake=False) + def setUp(self): # lint-amnesty, pylint: disable=arguments-differ + super(SoftwareSecureFakeViewDisabledTest, self).setUp(enable_software_secure_fake=False) # lint-amnesty, pylint: disable=super-with-arguments def test_get_method_without_enable_feature_flag(self): """ @@ -55,8 +55,8 @@ class SoftwareSecureFakeViewEnabledTest(SoftwareSecureFakeViewTest): 'ENABLE_SOFTWARE_SECURE_FAKE' is enabled. """ - def setUp(self): - super(SoftwareSecureFakeViewEnabledTest, self).setUp(enable_software_secure_fake=True) + def setUp(self): # lint-amnesty, pylint: disable=arguments-differ + super(SoftwareSecureFakeViewEnabledTest, self).setUp(enable_software_secure_fake=True) # lint-amnesty, pylint: disable=super-with-arguments def test_get_method_without_logged_in_user(self): """ diff --git a/lms/djangoapps/verify_student/tests/test_integration.py b/lms/djangoapps/verify_student/tests/test_integration.py index 332350ff412..50ed59696b2 100644 --- a/lms/djangoapps/verify_student/tests/test_integration.py +++ b/lms/djangoapps/verify_student/tests/test_integration.py @@ -23,7 +23,7 @@ class TestProfEdVerification(ModuleStoreTestCase): MIN_PRICE = 1438 def setUp(self): - super(TestProfEdVerification, self).setUp() + super(TestProfEdVerification, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username="rusty", password="test") self.client.login(username="rusty", password="test") diff --git a/lms/djangoapps/verify_student/tests/test_models.py b/lms/djangoapps/verify_student/tests/test_models.py index a6b1484ac41..62e7432fe8a 100644 --- a/lms/djangoapps/verify_student/tests/test_models.py +++ b/lms/djangoapps/verify_student/tests/test_models.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# lint-amnesty, pylint: disable=missing-module-docstring import base64 from datetime import datetime, timedelta @@ -49,7 +49,7 @@ iwIDAQAB } -def mock_software_secure_post(url, headers=None, data=None, **kwargs): +def mock_software_secure_post(url, headers=None, data=None, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Mocks our interface when we post to Software Secure. Does basic assertions on the fields we send over to make sure we're not missing headers or giving @@ -75,7 +75,7 @@ def mock_software_secure_post(url, headers=None, data=None, **kwargs): return response -def mock_software_secure_post_error(url, headers=None, data=None, **kwargs): +def mock_software_secure_post_error(url, headers=None, data=None, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Simulates what happens if our post to Software Secure is rejected, for whatever reason. @@ -94,7 +94,7 @@ def mock_software_secure_post_unavailable(url, headers=None, data=None, **kwargs @patch.dict(settings.VERIFY_STUDENT, FAKE_SETTINGS) @patch('lms.djangoapps.verify_student.models.requests.post', new=mock_software_secure_post) @ddt.ddt -class TestPhotoVerification(TestVerificationBase, MockS3BotoMixin, ModuleStoreTestCase): +class TestPhotoVerification(TestVerificationBase, MockS3BotoMixin, ModuleStoreTestCase): # lint-amnesty, pylint: disable=missing-class-docstring def test_state_transitions(self): """ diff --git a/lms/djangoapps/verify_student/tests/test_services.py b/lms/djangoapps/verify_student/tests/test_services.py index 6232e93320c..8223032c408 100644 --- a/lms/djangoapps/verify_student/tests/test_services.py +++ b/lms/djangoapps/verify_student/tests/test_services.py @@ -152,7 +152,7 @@ class TestIDVerificationServiceUserStatus(TestCase): we just put everything inside of a frozen time """ def setUp(self): - super(TestIDVerificationServiceUserStatus, self).setUp() + super(TestIDVerificationServiceUserStatus, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() def test_no_verification(self): diff --git a/lms/djangoapps/verify_student/tests/test_signals.py b/lms/djangoapps/verify_student/tests/test_signals.py index 2d9bc09f144..516c6a363b1 100644 --- a/lms/djangoapps/verify_student/tests/test_signals.py +++ b/lms/djangoapps/verify_student/tests/test_signals.py @@ -22,7 +22,7 @@ class VerificationDeadlineSignalTest(ModuleStoreTestCase): """ def setUp(self): - super(VerificationDeadlineSignalTest, self).setUp() + super(VerificationDeadlineSignalTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.end = now().replace(microsecond=0) + timedelta(days=7) self.course = CourseFactory.create(end=self.end) VerificationDeadline.objects.all().delete() diff --git a/lms/djangoapps/verify_student/tests/test_tasks.py b/lms/djangoapps/verify_student/tests/test_tasks.py index faa6c0fc135..c3ea1777cd5 100644 --- a/lms/djangoapps/verify_student/tests/test_tasks.py +++ b/lms/djangoapps/verify_student/tests/test_tasks.py @@ -1,3 +1,4 @@ +# lint-amnesty, pylint: disable=missing-module-docstring # Lots of patching to stub in our own settings, and HTTP posting import ddt import mock @@ -14,7 +15,7 @@ LOGGER_NAME = 'lms.djangoapps.verify_student.tasks' @patch.dict(settings.VERIFY_STUDENT, FAKE_SETTINGS) @ddt.ddt -class TestPhotoVerificationTasks(TestVerificationBase, MockS3BotoMixin, ModuleStoreTestCase): +class TestPhotoVerificationTasks(TestVerificationBase, MockS3BotoMixin, ModuleStoreTestCase): # lint-amnesty, pylint: disable=missing-class-docstring @mock.patch('lms.djangoapps.verify_student.tasks.log') def test_logs_for_retry_until_failure(self, mock_log): diff --git a/lms/djangoapps/verify_student/tests/test_utils.py b/lms/djangoapps/verify_student/tests/test_utils.py index f9f237ddc90..6b0a342b7d7 100644 --- a/lms/djangoapps/verify_student/tests/test_utils.py +++ b/lms/djangoapps/verify_student/tests/test_utils.py @@ -151,7 +151,7 @@ class TestVerifyStudentUtils(unittest.TestCase): @mock.patch('lms.djangoapps.verify_student.utils.log') @mock.patch( - 'lms.djangoapps.verify_student.tasks.send_request_to_ss_for_user.delay', mock.Mock(side_effect=Exception('error')) + 'lms.djangoapps.verify_student.tasks.send_request_to_ss_for_user.delay', mock.Mock(side_effect=Exception('error')) # lint-amnesty, pylint: disable=line-too-long ) def test_submit_request_to_ss(self, mock_log): """Tests that we log appropriate information when celery task creation fails.""" diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index 2b7e9df8b2f..bd0435d54d7 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -128,7 +128,7 @@ class StartView(TestCase): self.client.login(username="rusty", password="test") def must_be_logged_in(self): - self.assertHttpForbidden(self.client.get(self.start_url())) + self.assertHttpForbidden(self.client.get(self.start_url())) # lint-amnesty, pylint: disable=no-member @ddt.ddt @@ -151,7 +151,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin, Tes @mock.patch.dict(settings.FEATURES, {'EMBARGO': True}) def setUp(self): - super(TestPayAndVerifyView, self).setUp() + super(TestPayAndVerifyView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username=self.USERNAME, password=self.PASSWORD) result = self.client.login(username=self.USERNAME, password=self.PASSWORD) self.assertTrue(result, msg="Could not log in") @@ -855,7 +855,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin, Tes attempt.system_error("Error!") if status == "expired": - days_good_for = settings.VERIFY_STUDENT["DAYS_GOOD_FOR"] + days_good_for = settings.VERIFY_STUDENT["DAYS_GOOD_FOR"] # lint-amnesty, pylint: disable=unused-variable attempt.expiration_date = now() - timedelta(days=1) attempt.save() @@ -1060,7 +1060,7 @@ class CheckoutTestMixin(object): def setUp(self): """ Create a user and course. """ - super(CheckoutTestMixin, self).setUp() + super(CheckoutTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username="test", password="test") self.course = CourseFactory.create() @@ -1247,7 +1247,7 @@ class TestSubmitPhotosForVerification(MockS3BotoMixin, TestVerificationBase): FULL_NAME = u"Ḟüḷḷ Ṅäá¹Ã«" def setUp(self): - super(TestSubmitPhotosForVerification, self).setUp() + super(TestSubmitPhotosForVerification, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username=self.USERNAME, password=self.PASSWORD) result = self.client.login(username=self.USERNAME, password=self.PASSWORD) self.assertTrue(result, msg="Could not log in") @@ -1460,7 +1460,7 @@ class TestPhotoVerificationResultsCallback(ModuleStoreTestCase, TestVerification """ def setUp(self): - super(TestPhotoVerificationResultsCallback, self).setUp() + super(TestPhotoVerificationResultsCallback, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create(org='Robot', number='999', display_name='Test Course') self.course_id = self.course.id @@ -1737,7 +1737,7 @@ class TestReverifyView(TestVerificationBase): PASSWORD = "detachment-2702" def setUp(self): - super(TestReverifyView, self).setUp() + super(TestReverifyView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username=self.USERNAME, password=self.PASSWORD) success = self.client.login(username=self.USERNAME, password=self.PASSWORD) self.assertTrue(success, msg="Could not log in") @@ -1835,7 +1835,7 @@ class TestPhotoURLView(TestVerificationBase): """ def setUp(self): - super(TestPhotoURLView, self).setUp() + super(TestPhotoURLView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = AdminFactory() login_success = self.client.login(username=self.user.username, password='test') @@ -1868,7 +1868,7 @@ class TestPhotoURLView(TestVerificationBase): ) def test_photo_url_view_returns_404_if_invalid_receipt_id(self): - url = reverse('verification_photo_urls', kwargs={'receipt_id': six.text_type('00000000-0000-0000-0000-000000000000')}) + url = reverse('verification_photo_urls', kwargs={'receipt_id': six.text_type('00000000-0000-0000-0000-000000000000')}) # lint-amnesty, pylint: disable=line-too-long response = self.client.get(url) self.assertEqual(response.status_code, 404) diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 3138e4205f9..0ed1bb8e298 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -199,7 +199,7 @@ class PayAndVerifyView(View): return user.is_active or is_account_activation_requirement_disabled() @method_decorator(login_required) - def get( + def get( # lint-amnesty, pylint: disable=too-many-statements self, request, course_id, always_show_payment=False, current_step=None, @@ -427,7 +427,7 @@ class PayAndVerifyView(View): return render_to_response("verify_student/pay_and_verify.html", context) - def add_utm_params_to_url(self, url): + def add_utm_params_to_url(self, url): # lint-amnesty, pylint: disable=missing-function-docstring # utm_params is [(u'utm_content', u'course-v1:IDBx IDB20.1x 1T2017'),... utm_params = [item for item in self.request.GET.items() if 'utm_' in item[0]] # utm_params is utm_content=course-v1%3AIDBx+IDB20.1x+1T2017&... @@ -814,7 +814,7 @@ class SubmitPhotosView(View): @method_decorator(transaction.non_atomic_requests) def dispatch(self, request, *args, **kwargs): - return super(SubmitPhotosView, self).dispatch(request, *args, **kwargs) + return super(SubmitPhotosView, self).dispatch(request, *args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments @method_decorator(login_required) @method_decorator(outer_atomic(read_committed=True)) @@ -1043,7 +1043,7 @@ class SubmitPhotosView(View): @require_POST @csrf_exempt # SS does its own message signing, and their API won't have a cookie value -def results_callback(request): +def results_callback(request): # lint-amnesty, pylint: disable=too-many-statements """ Software Secure will call this callback to tell us whether a user is verified to be who they said they are. @@ -1100,13 +1100,13 @@ def results_callback(request): 'platform_name': settings.PLATFORM_NAME, } if result == "PASS": - # If this verification is not an outdated version then make expiry email date of previous approved verification NULL + # If this verification is not an outdated version then make expiry email date of previous approved verification NULL # lint-amnesty, pylint: disable=line-too-long # Setting expiry email date to NULL is important so that it does not get filtered in the management command # that sends email when verification expires : verify_student/send_verification_expiry_email if attempt.status != 'approved': verification = SoftwareSecurePhotoVerification.objects.filter(status='approved', user_id=attempt.user_id) if verification: - log.info(u'Making expiry email date of previous approved verification NULL for {}'.format(attempt.user_id)) + log.info(u'Making expiry email date of previous approved verification NULL for {}'.format(attempt.user_id)) # lint-amnesty, pylint: disable=line-too-long # The updated_at field in sspv model has auto_now set to True, which means any time save() is called on # the model instance, `updated_at` will change. Some of the existing functionality of verification # (showing your verification has expired on dashboard) relies on updated_at. diff --git a/lms/lib/xblock/test/test_mixin.py b/lms/lib/xblock/test/test_mixin.py index c1bd13392f1..856eaf1f52c 100644 --- a/lms/lib/xblock/test/test_mixin.py +++ b/lms/lib/xblock/test/test_mixin.py @@ -1,7 +1,7 @@ """ Tests of the LMS XBlock Mixin """ - +# pylint: disable=cyclic-import import ddt from xblock.validation import ValidationMessage -- GitLab