Merge pull request #26375 from edx/jawayria/bom-2330-pylint-amnesty
BOM-2330: Applied pylint-amnesty to util, verified_track_content, vid…
This commit is contained in:
@@ -18,4 +18,4 @@ class UtilConfig(AppConfig):
|
||||
"""
|
||||
Registers signal handlers at startup.
|
||||
"""
|
||||
import openedx.core.djangoapps.util.signals # pylint: disable=unused-variable
|
||||
import openedx.core.djangoapps.util.signals # lint-amnesty, pylint: disable=unused-import, unused-variable
|
||||
|
||||
@@ -22,11 +22,11 @@ class MultiValueField(Field):
|
||||
"""
|
||||
widget = MultipleHiddenInput
|
||||
|
||||
def to_python(self, list_of_string_values):
|
||||
def to_python(self, list_of_string_values): # lint-amnesty, pylint: disable=arguments-differ
|
||||
"""
|
||||
Convert the form input to a list of strings
|
||||
"""
|
||||
values = super(MultiValueField, self).to_python(list_of_string_values) or set()
|
||||
values = super(MultiValueField, self).to_python(list_of_string_values) or set() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
if values:
|
||||
# combine all values if there were multiple specified individually
|
||||
@@ -37,7 +37,7 @@ class MultiValueField(Field):
|
||||
|
||||
return values
|
||||
|
||||
def validate(self, values):
|
||||
def validate(self, values): # lint-amnesty, pylint: disable=arguments-differ
|
||||
"""
|
||||
Ensure no empty values were passed
|
||||
"""
|
||||
|
||||
@@ -22,7 +22,7 @@ from django.core.management.base import BaseCommand, CommandError
|
||||
from six.moves import configparser
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
class Command(BaseCommand): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
help = "Resets the database for this project."
|
||||
|
||||
def add_arguments(self, parser):
|
||||
@@ -30,7 +30,7 @@ class Command(BaseCommand):
|
||||
'-R', '--router', action='store', dest='router', default='default',
|
||||
help='Use this router-database other than defined in settings.py')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
def handle(self, *args, **options): # lint-amnesty, pylint: disable=too-many-statements
|
||||
"""
|
||||
Resets the database for this project.
|
||||
|
||||
@@ -87,16 +87,16 @@ class Command(BaseCommand):
|
||||
drop_query = u'DROP DATABASE IF EXISTS `%s`' % database_name
|
||||
utf8_support = 'CHARACTER SET utf8'
|
||||
create_query = u'CREATE DATABASE `%s` %s' % (database_name, utf8_support)
|
||||
logging.info('Executing... "' + drop_query + '"')
|
||||
logging.info('Executing... "' + drop_query + '"') # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
connection.query(drop_query)
|
||||
logging.info('Executing... "' + create_query + '"')
|
||||
logging.info('Executing... "' + create_query + '"') # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
connection.query(create_query)
|
||||
|
||||
elif engine in ('postgresql', 'postgresql_psycopg2', 'postgis'):
|
||||
if engine == 'postgresql' and django.VERSION < (1, 9):
|
||||
import psycopg as Database # NOQA
|
||||
import psycopg as Database # NOQA # lint-amnesty, pylint: disable=import-error
|
||||
elif engine in ('postgresql', 'postgresql_psycopg2', 'postgis'):
|
||||
import psycopg2 as Database # NOQA
|
||||
import psycopg2 as Database # NOQA # lint-amnesty, pylint: disable=import-error
|
||||
|
||||
conn_params = {'database': 'template1'}
|
||||
if user:
|
||||
@@ -113,7 +113,7 @@ class Command(BaseCommand):
|
||||
cursor = connection.cursor()
|
||||
|
||||
drop_query = u"DROP DATABASE \"%s\";" % database_name
|
||||
logging.info('Executing... "' + drop_query + '"')
|
||||
logging.info('Executing... "' + drop_query + '"') # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
try:
|
||||
cursor.execute(drop_query)
|
||||
except Database.ProgrammingError as e:
|
||||
@@ -127,7 +127,7 @@ class Command(BaseCommand):
|
||||
if engine == 'postgis' and django.VERSION < (1, 9):
|
||||
# For PostGIS 1.5, fetch template name if it exists
|
||||
from django.contrib.gis.db.backends.postgis.base import DatabaseWrapper
|
||||
postgis_template = DatabaseWrapper(dbinfo).template_postgis
|
||||
postgis_template = DatabaseWrapper(dbinfo).template_postgis # lint-amnesty, pylint: disable=no-member
|
||||
if postgis_template is not None:
|
||||
create_query += u' TEMPLATE = %s' % postgis_template
|
||||
|
||||
@@ -136,7 +136,7 @@ class Command(BaseCommand):
|
||||
else:
|
||||
create_query += u';'
|
||||
|
||||
logging.info('Executing... "' + create_query + '"')
|
||||
logging.info('Executing... "' + create_query + '"') # lint-amnesty, pylint: disable=logging-not-lazy
|
||||
cursor.execute(create_query)
|
||||
|
||||
else:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
class Creator(object):
|
||||
"""
|
||||
A placeholder class that provides a way to set the attribute on the model.
|
||||
@@ -5,7 +6,7 @@ class Creator(object):
|
||||
def __init__(self, field):
|
||||
self.field = field
|
||||
|
||||
def __get__(self, obj, type=None):
|
||||
def __get__(self, obj, type=None): # lint-amnesty, pylint: disable=redefined-builtin
|
||||
if obj is None:
|
||||
return self
|
||||
return obj.__dict__[self.field.name]
|
||||
@@ -20,8 +21,8 @@ class CreatorMixin(object):
|
||||
See: https://docs.djangoproject.com/en/1.11/releases/1.8/#subfieldbase
|
||||
"""
|
||||
def contribute_to_class(self, cls, name, *args, **kwargs):
|
||||
super(CreatorMixin, self).contribute_to_class(cls, name, *args, **kwargs)
|
||||
super(CreatorMixin, self).contribute_to_class(cls, name, *args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
setattr(cls, name, Creator(self))
|
||||
|
||||
def from_db_value(self, value, expression, connection):
|
||||
def from_db_value(self, value, expression, connection): # lint-amnesty, pylint: disable=unused-argument
|
||||
return self.to_python(value)
|
||||
|
||||
@@ -6,5 +6,5 @@ Code to get ip from request.
|
||||
from ipware.ip import get_ip
|
||||
|
||||
|
||||
def real_ip(group, request):
|
||||
def real_ip(group, request): # lint-amnesty, pylint: disable=unused-argument
|
||||
return get_ip(request)
|
||||
|
||||
@@ -62,7 +62,7 @@ def delete_rows(model_mgr,
|
||||
# The "as id" below fools Django raw query into thinking the primary key is being queried.
|
||||
# It's necessary because Django will throw an exception if the raw SQL does not query the primary key.
|
||||
min_max_ids = model_mgr.raw(
|
||||
u'SELECT MIN({}) as id, MAX({}) as max_id FROM {}'.format(primary_id_name, primary_id_name, table_name)
|
||||
u'SELECT MIN({}) as id, MAX({}) as max_id FROM {}'.format(primary_id_name, primary_id_name, table_name) # lint-amnesty, pylint: disable=duplicate-string-formatting-argument
|
||||
)[0]
|
||||
min_id = min_max_ids.id
|
||||
max_id = min_max_ids.max_id
|
||||
@@ -81,7 +81,7 @@ def delete_rows(model_mgr,
|
||||
log.info(u"Deleting around %s rows between ids %s and %s...", deletions_now, lower_id, upper_id)
|
||||
with transaction.atomic():
|
||||
# xss-lint: disable=python-wrap-html
|
||||
delete_sql = u'DELETE FROM {} WHERE {} >= {} AND {} < {}'.format(
|
||||
delete_sql = u'DELETE FROM {} WHERE {} >= {} AND {} < {}'.format( # lint-amnesty, pylint: disable=duplicate-string-formatting-argument
|
||||
table_name, primary_id_name, lower_id, primary_id_name, upper_id
|
||||
)
|
||||
log.info(delete_sql)
|
||||
@@ -113,7 +113,7 @@ class BaseDeletionCommand(BaseCommand):
|
||||
'--chunk_size',
|
||||
default=self.DEFAULT_CHUNK_SIZE,
|
||||
type=int,
|
||||
help='Maximum number of rows to delete in each DB transaction. Choose this value carefully to avoid DB outages!'
|
||||
help='Maximum number of rows to delete in each DB transaction. Choose this value carefully to avoid DB outages!' # lint-amnesty, pylint: disable=line-too-long
|
||||
)
|
||||
parser.add_argument(
|
||||
'--sleep_between',
|
||||
|
||||
@@ -25,7 +25,7 @@ class ContentGroupTestCase(ModuleStoreTestCase):
|
||||
and a non-cohorted user with no special access.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(ContentGroupTestCase, self).setUp()
|
||||
super(ContentGroupTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course = CourseFactory.create(
|
||||
org='org', number='number', run='run',
|
||||
@@ -144,7 +144,7 @@ class TestConditionalContent(ModuleStoreTestCase):
|
||||
-> vertical (Group B)
|
||||
-> problem
|
||||
"""
|
||||
super(TestConditionalContent, self).setUp()
|
||||
super(TestConditionalContent, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# Create user partitions
|
||||
self.user_partition_group_a = 0
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*- # lint-amnesty, pylint: disable=missing-module-docstring
|
||||
|
||||
|
||||
import pytest
|
||||
from django.core.management import CommandError, call_command
|
||||
|
||||
|
||||
def test_without_args(capsys):
|
||||
def test_without_args(capsys): # lint-amnesty, pylint: disable=unused-argument
|
||||
with pytest.raises(CommandError, match='Error: the following arguments are required: setting'):
|
||||
call_command('print_setting')
|
||||
|
||||
@@ -13,6 +13,6 @@ def test_without_args(capsys):
|
||||
def test_with_setting_args(capsys):
|
||||
call_command('print_setting', 'DEBUG')
|
||||
|
||||
out, err = capsys.readouterr()
|
||||
out, err = capsys.readouterr() # lint-amnesty, pylint: disable=unused-variable
|
||||
assert 'False' in out
|
||||
assert 'INSTALLED_APPS' not in out
|
||||
|
||||
@@ -22,7 +22,7 @@ class UserMessagesTestCase(TestCase):
|
||||
Unit tests for page level user messages.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(UserMessagesTestCase, self).setUp()
|
||||
super(UserMessagesTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.student = UserFactory.create()
|
||||
self.request = RequestFactory().request()
|
||||
self.request.session = {}
|
||||
|
||||
@@ -12,7 +12,7 @@ from ..user_utils import SystemUser
|
||||
class SystemUserTestCase(unittest.TestCase):
|
||||
""" Tests for response-related utility functions """
|
||||
def setUp(self):
|
||||
super(SystemUserTestCase, self).setUp()
|
||||
super(SystemUserTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.sysuser = SystemUser()
|
||||
|
||||
def test_system_user_is_anonymous(self):
|
||||
|
||||
@@ -54,7 +54,7 @@ class UserMessage():
|
||||
"""
|
||||
Representation of a message to be shown to a user.
|
||||
"""
|
||||
def __init__(self, type, message_html):
|
||||
def __init__(self, type, message_html): # lint-amnesty, pylint: disable=redefined-builtin
|
||||
assert isinstance(type, UserMessageType)
|
||||
self.type = type
|
||||
self.message_html = message_html
|
||||
@@ -80,7 +80,7 @@ class UserMessageCollection():
|
||||
"""
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def get_namespace(self):
|
||||
def get_namespace(self): # lint-amnesty, pylint: disable=bad-classmethod-argument
|
||||
"""
|
||||
Returns the namespace of the message collection.
|
||||
|
||||
@@ -125,35 +125,35 @@ class UserMessageCollection():
|
||||
messages.add_message(request, message_type.value, Text(message), extra_tags=cls.get_namespace())
|
||||
|
||||
@classmethod
|
||||
def register_info_message(self, request, message, **kwargs):
|
||||
def register_info_message(self, request, message, **kwargs): # lint-amnesty, pylint: disable=bad-classmethod-argument
|
||||
"""
|
||||
Registers an information message to be shown to the user.
|
||||
"""
|
||||
self.register_user_message(request, UserMessageType.INFO, message, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def register_success_message(self, request, message, **kwargs):
|
||||
def register_success_message(self, request, message, **kwargs): # lint-amnesty, pylint: disable=bad-classmethod-argument
|
||||
"""
|
||||
Registers a success message to be shown to the user.
|
||||
"""
|
||||
self.register_user_message(request, UserMessageType.SUCCESS, message, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def register_warning_message(self, request, message, **kwargs):
|
||||
def register_warning_message(self, request, message, **kwargs): # lint-amnesty, pylint: disable=bad-classmethod-argument
|
||||
"""
|
||||
Registers a warning message to be shown to the user.
|
||||
"""
|
||||
self.register_user_message(request, UserMessageType.WARNING, message, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def register_error_message(self, request, message, **kwargs):
|
||||
def register_error_message(self, request, message, **kwargs): # lint-amnesty, pylint: disable=bad-classmethod-argument
|
||||
"""
|
||||
Registers an error message to be shown to the user.
|
||||
"""
|
||||
self.register_user_message(request, UserMessageType.ERROR, message, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def user_messages(self, request):
|
||||
def user_messages(self, request): # lint-amnesty, pylint: disable=bad-classmethod-argument
|
||||
"""
|
||||
Returns any outstanding user messages.
|
||||
|
||||
@@ -164,7 +164,7 @@ class UserMessageCollection():
|
||||
"""
|
||||
Returns the user message type associated with a level.
|
||||
"""
|
||||
for __, type in UserMessageType.__members__.items():
|
||||
for __, type in UserMessageType.__members__.items(): # lint-amnesty, pylint: disable=redefined-builtin
|
||||
if type.value is level:
|
||||
return type
|
||||
raise Exception(u'Unable to find UserMessageType for level {level}'.format(level=level))
|
||||
@@ -222,7 +222,7 @@ class PageLevelMessages(UserMessageCollection):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_namespace(self):
|
||||
def get_namespace(self): # lint-amnesty, pylint: disable=bad-classmethod-argument
|
||||
"""
|
||||
Returns the namespace of the message collection.
|
||||
"""
|
||||
|
||||
@@ -46,7 +46,7 @@ class VerifiedTrackCourseForm(forms.ModelForm):
|
||||
try:
|
||||
course_key = CourseKey.from_string(cleaned_id)
|
||||
except InvalidKeyError:
|
||||
raise forms.ValidationError(error_msg)
|
||||
raise forms.ValidationError(error_msg) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not modulestore().has_course(course_key):
|
||||
raise forms.ValidationError(error_msg)
|
||||
|
||||
@@ -26,7 +26,7 @@ class Command(BaseCommand):
|
||||
"""
|
||||
help = dedent(__doc__).strip()
|
||||
|
||||
def handle(self, *args, **options):
|
||||
def handle(self, *args, **options): # lint-amnesty, pylint: disable=too-many-statements
|
||||
|
||||
errors = []
|
||||
|
||||
@@ -103,7 +103,7 @@ class Command(BaseCommand):
|
||||
try:
|
||||
verified_track_cohorted_course = VerifiedTrackCohortedCourse.objects.get(course_key=old_course_key)
|
||||
except VerifiedTrackCohortedCourse.DoesNotExist:
|
||||
raise CommandError(u"No VerifiedTrackCohortedCourse found for course: '%s'" % old_course_key)
|
||||
raise CommandError(u"No VerifiedTrackCohortedCourse found for course: '%s'" % old_course_key) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
if not verified_track_cohorted_course.enabled:
|
||||
raise CommandError(u"VerifiedTrackCohortedCourse not enabled for course: '%s'" % old_course_key)
|
||||
@@ -117,7 +117,7 @@ class Command(BaseCommand):
|
||||
name=verified_track_cohorted_course.verified_cohort_name
|
||||
)
|
||||
except CourseUserGroup.DoesNotExist:
|
||||
raise CommandError(
|
||||
raise CommandError( # lint-amnesty, pylint: disable=raise-missing-from
|
||||
u"No Verified CourseUserGroup found for course_id='%s' with group_type='%s' for names='%s'"
|
||||
% (old_course_key, CourseUserGroup.COHORT, verified_track_cohorted_course.verified_cohort_name)
|
||||
)
|
||||
@@ -127,7 +127,7 @@ class Command(BaseCommand):
|
||||
course_user_group_id=verified_course_user_group.id
|
||||
)
|
||||
except CourseUserGroupPartitionGroup.DoesNotExist:
|
||||
raise CommandError(
|
||||
raise CommandError( # lint-amnesty, pylint: disable=raise-missing-from
|
||||
u"No Verified CourseUserGroupPartitionGroup found for course_user_group_ids='%s'"
|
||||
% random_audit_course_user_group_ids
|
||||
)
|
||||
@@ -139,7 +139,7 @@ class Command(BaseCommand):
|
||||
mode_slug=CourseMode.AUDIT
|
||||
)
|
||||
except CourseMode.DoesNotExist:
|
||||
raise CommandError(u"Audit CourseMode is not defined for course: '%s'" % rerun_course_key)
|
||||
raise CommandError(u"Audit CourseMode is not defined for course: '%s'" % rerun_course_key) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
try:
|
||||
CourseMode.objects.get(
|
||||
@@ -147,7 +147,7 @@ class Command(BaseCommand):
|
||||
mode_slug=CourseMode.VERIFIED
|
||||
)
|
||||
except CourseMode.DoesNotExist:
|
||||
raise CommandError(u"Verified CourseMode is not defined for course: '%s'" % rerun_course_key)
|
||||
raise CommandError(u"Verified CourseMode is not defined for course: '%s'" % rerun_course_key) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
items = module_store.get_items(rerun_course_key)
|
||||
if not items:
|
||||
@@ -233,7 +233,7 @@ class Command(BaseCommand):
|
||||
# Check if we should delete any partition groups if there are no errors.
|
||||
# If there are errors, none of the xblock items will have been updated,
|
||||
# so this section will throw errors for each partition in use
|
||||
if partitions_to_delete and not errors:
|
||||
if partitions_to_delete and not errors: # lint-amnesty, pylint: disable=too-many-nested-blocks
|
||||
partition_service = PartitionService(rerun_course_key)
|
||||
course = partition_service.get_course()
|
||||
for partition_to_delete in partitions_to_delete:
|
||||
|
||||
@@ -7,7 +7,7 @@ import six
|
||||
|
||||
from celery.task import task
|
||||
from celery.utils.log import get_task_logger
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from edx_django_utils.monitoring import set_code_owner_attribute
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class TestMoveToVerified(SharedModuleStoreTestCase):
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
super(TestMoveToVerified, self).setUp()
|
||||
super(TestMoveToVerified, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.user = UserFactory()
|
||||
# Spy on number of calls to celery task.
|
||||
celery_task_patcher = mock.patch.object(
|
||||
|
||||
@@ -1 +1 @@
|
||||
# TODO Move this Application to video codebase when Video XModule becomes an XBlock. Reference: TNL-6867.
|
||||
# TODO Move this Application to video codebase when Video XModule becomes an XBlock. Reference: TNL-6867. # lint-amnesty, pylint: disable=django-not-configured
|
||||
|
||||
@@ -3,9 +3,9 @@ Tests for the models that configures HLS Playback feature.
|
||||
"""
|
||||
|
||||
import ddt
|
||||
import itertools
|
||||
import itertools # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
from contextlib import contextmanager
|
||||
from contextlib import contextmanager # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class TestAPIUtils(VideoPipelineMixin, TestCase):
|
||||
"""
|
||||
Tests for API Utils.
|
||||
"""
|
||||
def setUp(self):
|
||||
def setUp(self): # lint-amnesty, pylint: disable=super-method-not-called
|
||||
"""
|
||||
Setup VEM oauth client.
|
||||
"""
|
||||
|
||||
@@ -3,7 +3,7 @@ Tests for the models that configures 'VideoUploadsEnabledByDefault' feature.
|
||||
"""
|
||||
|
||||
import ddt
|
||||
import itertools
|
||||
import itertools # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
from django.test import TestCase
|
||||
from openedx.core.djangoapps.video_config.tests.test_models import FeatureFlagTestMixin
|
||||
|
||||
Reference in New Issue
Block a user