pylint amnesty in heartbeat,header_control and lang_pref (#26369)

This commit is contained in:
M. Zulqarnain
2021-02-04 15:32:10 +05:00
committed by GitHub
parent b6b6489b96
commit 99c169c444
15 changed files with 21 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
"""
""" # lint-amnesty, pylint: disable=django-not-configured
This middleware is used for adjusting the headers in a response before it is sent to the end user.
This middleware is intended to sit as close as possible to the top of the middleare list as possible,

View File

@@ -11,7 +11,7 @@ from openedx.core.djangoapps.header_control.middleware import HeaderControlMiddl
class TestHeaderControlMiddlewareProcessResponse(TestCase):
"""Test the `header_control` middleware. """
def setUp(self):
super(TestHeaderControlMiddlewareProcessResponse, self).setUp()
super(TestHeaderControlMiddlewareProcessResponse, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.middleware = HeaderControlMiddleware()
def test_doesnt_barf_if_not_modifying_anything(self):

View File

@@ -77,7 +77,7 @@ def check_cache_set():
try:
cache.set(CACHE_KEY, CACHE_VALUE, 30)
return 'cache_set', True, u'OK'
except Exception as fail:
except Exception as fail: # lint-amnesty, pylint: disable=broad-except
return 'cache_set', False, six.text_type(fail)
@@ -95,7 +95,7 @@ def check_cache_get():
return 'cache_get', True, u'OK'
else:
return 'cache_get', False, u'value check failed'
except Exception as fail:
except Exception as fail: # lint-amnesty, pylint: disable=broad-except
return 'cache_get', False, six.text_type(fail)
@@ -120,5 +120,5 @@ def check_celery():
return 'celery', True, six.text_type({'time': finished})
sleep(0.25)
return 'celery', False, "expired"
except Exception as fail:
except Exception as fail: # lint-amnesty, pylint: disable=broad-except
return 'celery', False, six.text_type(fail)

View File

@@ -35,7 +35,7 @@ def runchecks(include_extended=False):
'message': message
}
except ImportError as e:
raise ImproperlyConfigured(u'Error importing module %s: "%s"' % (module, e))
raise ImproperlyConfigured(u'Error importing module %s: "%s"' % (module, e)) # lint-amnesty, pylint: disable=raise-missing-from
except AttributeError:
raise ImproperlyConfigured(u'Module "%s" does not define a "%s" callable' % (module, attr))
raise ImproperlyConfigured(u'Module "%s" does not define a "%s" callable' % (module, attr)) # lint-amnesty, pylint: disable=raise-missing-from
return response_dict

View File

@@ -22,7 +22,7 @@ class HeartbeatTestCase(ModuleStoreTestCase):
def setUp(self):
self.client = Client()
self.heartbeat_url = reverse('heartbeat')
return super(HeartbeatTestCase, self).setUp()
return super(HeartbeatTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
def test_success(self):
response = self.client.get(self.heartbeat_url + '?extended')

View File

@@ -28,7 +28,7 @@ def heartbeat(request):
for check in check_results:
if not check_results[check]['status']:
status_code = 503 # 503 on any failure
except Exception as e:
except Exception as e: # lint-amnesty, pylint: disable=broad-except
status_code = 503
check_results = {'error': six.text_type(e)}

View File

@@ -1,4 +1,4 @@
"""
""" # lint-amnesty, pylint: disable=django-not-configured
Useful information for setting the language preference
"""

View File

@@ -79,7 +79,7 @@ def all_languages():
alphabetically.
"""
languages = [(lang[0], _(lang[1])) for lang in settings.ALL_LANGUAGES]
languages = [(lang[0], _(lang[1])) for lang in settings.ALL_LANGUAGES] # lint-amnesty, pylint: disable=translation-of-non-string
return sorted(languages, key=lambda lang: lang[1])

View File

@@ -32,7 +32,7 @@ class LanguagePreferenceMiddleware(MiddlewareMixin):
if request.user.is_authenticated:
set_user_preference(request.user, LANGUAGE_KEY, cookie_lang)
else:
request._anonymous_user_cookie_lang = cookie_lang
request._anonymous_user_cookie_lang = cookie_lang # lint-amnesty, pylint: disable=protected-access
accept_header = request.META.get(LANGUAGE_HEADER, None)
if accept_header:
@@ -49,7 +49,7 @@ class LanguagePreferenceMiddleware(MiddlewareMixin):
if LANGUAGE_SESSION_KEY in request.session and request.session[LANGUAGE_SESSION_KEY] != cookie_lang:
del request.session[LANGUAGE_SESSION_KEY]
def process_response(self, request, response):
def process_response(self, request, response): # lint-amnesty, pylint: disable=missing-function-docstring
# If the user is logged in, check for their language preference. Also check for real user
# if current user is a masquerading user,
user_pref = None

View File

@@ -3,7 +3,7 @@
import ddt
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.test.utils import override_settings
from django.utils import translation
from mock import patch

View File

@@ -33,7 +33,7 @@ class TestUserPreferenceMiddleware(CacheIsolationTestCase):
"""
def setUp(self):
super(TestUserPreferenceMiddleware, self).setUp()
super(TestUserPreferenceMiddleware, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.middleware = LanguagePreferenceMiddleware()
self.session_middleware = SessionMiddleware()
self.user = UserFactory.create()

View File

@@ -19,7 +19,7 @@ class TestLangPrefView(TestCase):
"""
def setUp(self):
super(TestLangPrefView, self).setUp()
super(TestLangPrefView, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.session_middleware = SessionMiddleware()
self.user = UserFactory.create()
self.request = RequestFactory().get('/somewhere')

View File

@@ -13,7 +13,7 @@ from django.utils.translation import LANGUAGE_SESSION_KEY
from django.views.decorators.csrf import ensure_csrf_cookie
from openedx.core.djangoapps.lang_pref import COOKIE_DURATION, LANGUAGE_KEY
from openedx.core.lib.mobile_utils import is_request_from_mobile_app
from openedx.core.lib.mobile_utils import is_request_from_mobile_app # lint-amnesty, pylint: disable=unused-import
@ensure_csrf_cookie

View File

@@ -111,7 +111,7 @@ class CourseDetails(object):
course_details = cls(course_key.org, course_key.course, course_key.run)
course_details.start_date = course_descriptor.start
course_details.end_date = course_descriptor.end
course_details.certificate_available_date = course_descriptor.certificate_available_date
course_details.certificate_available_date = course_descriptor.certificate_available_date # lint-amnesty, pylint: disable=attribute-defined-outside-init
course_details.enrollment_start = course_descriptor.enrollment_start
course_details.enrollment_end = course_descriptor.enrollment_end
course_details.pre_requisite_courses = course_descriptor.pre_requisite_courses
@@ -325,7 +325,7 @@ class CourseDetails(object):
if keystring_matcher:
return keystring_matcher.group(0)
else:
logging.warn("ignoring the content because it doesn't not conform to expected pattern: " + raw_video)
logging.warn("ignoring the content because it doesn't not conform to expected pattern: " + raw_video) # lint-amnesty, pylint: disable=deprecated-method, logging-not-lazy
return None
@staticmethod

View File

@@ -21,7 +21,7 @@ class CourseDetailsTestCase(ModuleStoreTestCase):
"""
def setUp(self):
super(CourseDetailsTestCase, self).setUp()
super(CourseDetailsTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create()
def test_virgin_fetch(self):
@@ -116,7 +116,7 @@ class CourseDetailsTestCase(ModuleStoreTestCase):
)
jsondetails.video_thumbnail_image_name = "an_image.jpg"
self.assertEqual(
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).video_thumbnail_image_name,
CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).video_thumbnail_image_name, # lint-amnesty, pylint: disable=line-too-long
jsondetails.video_thumbnail_image_name
)
jsondetails.language = "hr"