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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions lms/djangoapps/dashboard/git_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class GitImportError(Exception):
def __init__(self, message=None):
if message is None:
message = self.MESSAGE
super(GitImportError, self).__init__(message)
super(GitImportError, self).__init__(message) # lint-amnesty, pylint: disable=super-with-arguments


class GitImportErrorNoDir(GitImportError):
"""
GitImportError when no directory exists at the specified path.
"""
def __init__(self, repo_dir):
super(GitImportErrorNoDir, self).__init__(
super(GitImportErrorNoDir, self).__init__( # lint-amnesty, pylint: disable=super-with-arguments
_(
u"Path {0} doesn't exist, please create it, "
u"or configure a different path with "
Expand Down Expand Up @@ -136,15 +136,15 @@ def switch_branch(branch, rdir):
cmd_log(['git', 'fetch', ], rdir)
except subprocess.CalledProcessError as ex:
log.exception(u'Unable to fetch remote: %r', ex.output)
raise GitImportErrorCannotBranch()
raise GitImportErrorCannotBranch() # lint-amnesty, pylint: disable=raise-missing-from

# Check if the branch is available from the remote.
cmd = ['git', 'ls-remote', 'origin', '-h', 'refs/heads/{0}'.format(branch), ]
try:
output = cmd_log(cmd, rdir)
except subprocess.CalledProcessError as ex:
log.exception(u'Getting a list of remote branches failed: %r', ex.output)
raise GitImportErrorCannotBranch()
raise GitImportErrorCannotBranch() # lint-amnesty, pylint: disable=raise-missing-from
if branch not in output:
raise GitImportErrorRemoteBranchMissing()
# Check it the remote branch has already been made locally
Expand All @@ -153,7 +153,7 @@ def switch_branch(branch, rdir):
output = cmd_log(cmd, rdir)
except subprocess.CalledProcessError as ex:
log.exception(u'Getting a list of local branches failed: %r', ex.output)
raise GitImportErrorCannotBranch()
raise GitImportErrorCannotBranch() # lint-amnesty, pylint: disable=raise-missing-from
branches = []
for line in output.split('\n'):
branches.append(line.replace('*', '').strip())
Expand All @@ -166,14 +166,14 @@ def switch_branch(branch, rdir):
cmd_log(cmd, rdir)
except subprocess.CalledProcessError as ex:
log.exception(u'Unable to checkout remote branch: %r', ex.output)
raise GitImportErrorCannotBranch()
raise GitImportErrorCannotBranch() # lint-amnesty, pylint: disable=raise-missing-from
# Go ahead and reset hard to the newest version of the branch now that we know
# it is local.
try:
cmd_log(['git', 'reset', '--hard', 'origin/{0}'.format(branch), ], rdir)
except subprocess.CalledProcessError as ex:
log.exception(u'Unable to reset to branch: %r', ex.output)
raise GitImportErrorCannotBranch()
raise GitImportErrorCannotBranch() # lint-amnesty, pylint: disable=raise-missing-from


def add_repo(repo, rdir_in, branch=None):
Expand Down Expand Up @@ -232,7 +232,7 @@ def add_repo(repo, rdir_in, branch=None):
ret_git = cmd_log(cmd, cwd=cwd)
except subprocess.CalledProcessError as ex:
log.exception(u'Error running git pull: %r', ex.output)
raise GitImportErrorCannotPull()
raise GitImportErrorCannotPull() # lint-amnesty, pylint: disable=raise-missing-from

if branch:
switch_branch(branch, rdirp)
Expand All @@ -243,7 +243,7 @@ def add_repo(repo, rdir_in, branch=None):
commit_id = cmd_log(cmd, cwd=rdirp)
except subprocess.CalledProcessError as ex:
log.exception(u'Unable to get git log: %r', ex.output)
raise GitImportErrorBadRepo()
raise GitImportErrorBadRepo() # lint-amnesty, pylint: disable=raise-missing-from

ret_git += u'\nCommit ID: {0}'.format(commit_id)

Expand All @@ -255,7 +255,7 @@ def add_repo(repo, rdir_in, branch=None):
# I can't discover a way to excercise this, but git is complex
# so still logging and raising here in case.
log.exception(u'Unable to determine branch: %r', ex.output)
raise GitImportErrorBadRepo()
raise GitImportErrorBadRepo() # lint-amnesty, pylint: disable=raise-missing-from

ret_git += u'{0}Branch: {1}'.format(' \n', branch)

Expand All @@ -281,9 +281,9 @@ def add_repo(repo, rdir_in, branch=None):
python_lib_filename=python_lib_filename
)
except CommandError:
raise GitImportErrorXmlImportFailed()
raise GitImportErrorXmlImportFailed() # lint-amnesty, pylint: disable=raise-missing-from
except NotImplementedError:
raise GitImportErrorUnsupportedStore()
raise GitImportErrorUnsupportedStore() # lint-amnesty, pylint: disable=raise-missing-from

ret_import = output.getvalue()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ def handle(self, *args, **options):
try:
git_import.add_repo(options['repository_url'], rdir_arg, branch)
except git_import.GitImportError as ex:
raise CommandError(str(ex))
raise CommandError(str(ex)) # lint-amnesty, pylint: disable=raise-missing-from
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestGitAddCourse(SharedModuleStoreTestCase):
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']

def setUp(self):
super(TestGitAddCourse, self).setUp()
super(TestGitAddCourse, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.git_repo_dir = settings.GIT_REPO_DIR

def assertCommandFailureRegexp(self, regex, *args):
Expand Down
16 changes: 8 additions & 8 deletions lms/djangoapps/dashboard/sysadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import mongoengine
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db import IntegrityError
from django.http import Http404
Expand Down Expand Up @@ -58,15 +58,15 @@ def __init__(self, **kwargs):
self.def_ms = modulestore()
self.msg = u''
self.datatable = []
super(SysadminDashboardView, self).__init__(**kwargs)
super(SysadminDashboardView, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments

@method_decorator(ensure_csrf_cookie)
@method_decorator(login_required)
@method_decorator(cache_control(no_cache=True, no_store=True,
must_revalidate=True))
@method_decorator(condition(etag_func=None))
def dispatch(self, *args, **kwargs):
return super(SysadminDashboardView, self).dispatch(*args, **kwargs)
return super(SysadminDashboardView, self).dispatch(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments

def get_courses(self):
""" Get an iterable list of courses."""
Expand Down Expand Up @@ -162,7 +162,7 @@ def make_datatable(self):
}
return datatable

def get(self, request):
def get(self, request): # lint-amnesty, pylint: disable=arguments-differ
if not request.user.is_staff:
raise Http404
context = {
Expand Down Expand Up @@ -314,7 +314,7 @@ def make_datatable(self, courses=None):
title=_('Information about all courses'),
data=data)

def get(self, request):
def get(self, request): # lint-amnesty, pylint: disable=arguments-differ
"""Displays forms and course information"""

if not request.user.is_staff:
Expand Down Expand Up @@ -356,7 +356,7 @@ def post(self, request):
course = get_course_by_id(course_key)
course_found = True
except Exception as err: # pylint: disable=broad-except
self.msg += _(
self.msg += _( # lint-amnesty, pylint: disable=translation-of-non-string
HTML(u'Error - cannot get course with ID {0}<br/><pre>{1}</pre>')
).format(
course_key,
Expand Down Expand Up @@ -386,7 +386,7 @@ class Staffing(SysadminDashboardView):
courses.
"""

def get(self, request):
def get(self, request): # lint-amnesty, pylint: disable=arguments-differ
"""Displays course Enrollment and staffing course statistics"""

if not request.user.is_staff:
Expand Down Expand Up @@ -458,7 +458,7 @@ def get(self, request, *args, **kwargs):
mdb = mongoengine.connect(mongo_db['db'], host=mongouri)
else:
mdb = mongoengine.connect(mongo_db['db'], host=mongo_db['host'])
except mongoengine.connection.ConnectionError:
except mongoengine.connection.ConnectionError: # lint-amnesty, pylint: disable=no-member
log.exception('Unable to connect to mongodb to save log, '
'please check MONGODB_LOG settings.')

Expand Down
6 changes: 3 additions & 3 deletions lms/djangoapps/dashboard/tests/test_sysadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SysadminBaseTestCase(SharedModuleStoreTestCase):

def setUp(self):
"""Setup test case by adding primary user."""
super(SysadminBaseTestCase, self).setUp()
super(SysadminBaseTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create(username='test_user',
email='test_user+sysadmin@edx.org',
password='foo')
Expand Down Expand Up @@ -99,7 +99,7 @@ def _rm_glob(self, path):
Create a shell expansion of passed in parameter and iteratively
remove them. Must only expand to directories.
"""
for path in glob.glob(path):
for path in glob.glob(path): # lint-amnesty, pylint: disable=redefined-argument-from-local
shutil.rmtree(path)

def _mkdir(self, path):
Expand Down Expand Up @@ -243,7 +243,7 @@ def test_gitlog_date(self):
date = CourseImportLog.objects.first().created.replace(tzinfo=UTC)

for timezone in tz_names:
with (override_settings(TIME_ZONE=timezone)):
with (override_settings(TIME_ZONE=timezone)): # lint-amnesty, pylint: disable=superfluous-parens
date_text = get_time_display(date, tz_format, settings.TIME_ZONE)
response = self.client.get(reverse('gitlogs'))
self.assertContains(response, date_text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# lint-amnesty, pylint: disable=missing-module-docstring
# This import registers the ForumThreadViewedEventTransformer

from . import event_transformers
14 changes: 7 additions & 7 deletions lms/djangoapps/discussion/django_comment_client/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import eventtracking
import six
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.core import exceptions
from django.http import Http404, HttpResponse, HttpResponseServerError
from django.utils.translation import ugettext as _
Expand Down Expand Up @@ -693,7 +693,7 @@ def un_pin_thread(request, course_id, thread_id):
@require_POST
@login_required
@permitted
def follow_thread(request, course_id, thread_id):
def follow_thread(request, course_id, thread_id): # lint-amnesty, pylint: disable=missing-function-docstring, unused-argument
user = cc.User.from_django_user(request.user)
thread = cc.Thread.find(thread_id)
user.follow(thread)
Expand All @@ -704,7 +704,7 @@ def follow_thread(request, course_id, thread_id):
@require_POST
@login_required
@permitted
def follow_commentable(request, course_id, commentable_id):
def follow_commentable(request, course_id, commentable_id): # lint-amnesty, pylint: disable=unused-argument
"""
given a course_id and commentable id, follow this commentable
ajax only
Expand All @@ -718,7 +718,7 @@ def follow_commentable(request, course_id, commentable_id):
@require_POST
@login_required
@permitted
def unfollow_thread(request, course_id, thread_id):
def unfollow_thread(request, course_id, thread_id): # lint-amnesty, pylint: disable=unused-argument
"""
given a course id and thread id, stop following this thread
ajax only
Expand All @@ -733,7 +733,7 @@ def unfollow_thread(request, course_id, thread_id):
@require_POST
@login_required
@permitted
def unfollow_commentable(request, course_id, commentable_id):
def unfollow_commentable(request, course_id, commentable_id): # lint-amnesty, pylint: disable=unused-argument
"""
given a course id and commentable id stop following commentable
ajax only
Expand All @@ -748,7 +748,7 @@ def unfollow_commentable(request, course_id, commentable_id):
@login_required
@csrf.csrf_exempt
@xframe_options_exempt
def upload(request, course_id): # ajax upload file to a question or answer
def upload(request, course_id): # ajax upload file to a question or answer # lint-amnesty, pylint: disable=unused-argument
"""view that handles file upload via Ajax
"""

Expand Down Expand Up @@ -796,7 +796,7 @@ def upload(request, course_id): # ajax upload file to a question or answer
# Using content-type of text/plain here instead of JSON because
# IE doesn't know how to handle the JSON response and prompts the
# user to save the JSON as a file instead of passing it to the callback.
return HttpResponse(json.dumps({
return HttpResponse(json.dumps({ # lint-amnesty, pylint: disable=http-response-with-json-dumps
'result': {
'msg': result,
'error': error,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# lint-amnesty, pylint: disable=missing-module-docstring
import json
import logging

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from openedx.core.lib.cache_utils import request_cached


def has_permission(user, permission, course_id=None):
def has_permission(user, permission, course_id=None): # lint-amnesty, pylint: disable=missing-function-docstring
assert isinstance(course_id, (type(None), CourseKey))
request_cache_dict = DEFAULT_REQUEST_CACHE.data
cache_key = "django_comment_client.permissions.has_permission.all_permissions.{}.{}".format(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# lint-amnesty, pylint: disable=missing-module-docstring
from factory.django import DjangoModelFactory

from openedx.core.djangoapps.django_comment_common.models import Permission, Role


class RoleFactory(DjangoModelFactory):
class RoleFactory(DjangoModelFactory): # lint-amnesty, pylint: disable=missing-class-docstring
class Meta(object):
model = Role

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def call_view(self, mock_request, commentable_id, user, group_id, pass_group_id=
Call the view for the implementing test class, constructing a request
from the parameters.
"""
pass
pass # lint-amnesty, pylint: disable=unnecessary-pass

def test_cohorted_topic_student_without_group_id(self, mock_request):
self.call_view(mock_request, "cohorted_topic", self.student, '', pass_group_id=False)
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_cohorted_topic_moderator_with_other_group_id(self, mock_request):

def test_cohorted_topic_moderator_with_invalid_group_id(self, mock_request):
invalid_id = self.student_cohort.id + self.moderator_cohort.id
response = self.call_view(mock_request, "cohorted_topic", self.moderator, invalid_id)
response = self.call_view(mock_request, "cohorted_topic", self.moderator, invalid_id) # lint-amnesty, pylint: disable=assignment-from-no-return
self.assertEqual(response.status_code, 500)

def test_cohorted_topic_enrollment_track_invalid_group_id(self, mock_request):
Expand All @@ -116,7 +116,7 @@ def test_cohorted_topic_enrollment_track_invalid_group_id(self, mock_request):
)

invalid_id = -1000
response = self.call_view(mock_request, "cohorted_topic", self.moderator, invalid_id)
response = self.call_view(mock_request, "cohorted_topic", self.moderator, invalid_id) # lint-amnesty, pylint: disable=assignment-from-no-return
self.assertEqual(response.status_code, 500)


Expand All @@ -130,7 +130,7 @@ def call_view(self, mock_request, commentable_id, user, group_id, pass_group_id=
Call the view for the implementing test class, constructing a request
from the parameters.
"""
pass
pass # lint-amnesty, pylint: disable=unnecessary-pass

def test_non_cohorted_topic_student_without_group_id(self, mock_request):
self.call_view(mock_request, "non_cohorted_topic", self.student, '', pass_group_id=False)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# lint-amnesty, pylint: disable=missing-module-docstring
import json
import threading
import unittest
Expand All @@ -14,7 +15,7 @@ class MockCommentServiceServerTest(unittest.TestCase):
'''

def setUp(self):
super(MockCommentServiceServerTest, self).setUp()
super(MockCommentServiceServerTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments

# This is a test of the test setup,
# so it does not need to run as part of the unit test suite
Expand Down Expand Up @@ -47,10 +48,10 @@ def test_new_user_request(self):
'external_id': '4', 'email': u'user100@edx.org'}
data = json.dumps(values)
headers = {'Content-Type': 'application/json', 'Content-Length': len(data), 'X-Edx-Api-Key': 'TEST_API_KEY'}
req = six.moves.urllib.request.Request(self.server_url + '/api/v1/users/4', data, headers)
req = six.moves.urllib.request.Request(self.server_url + '/api/v1/users/4', data, headers) # lint-amnesty, pylint: disable=undefined-variable

# Send the request to the mock cs server
response = six.moves.urllib.request.urlopen(req)
response = six.moves.urllib.request.urlopen(req) # lint-amnesty, pylint: disable=undefined-variable

# Receive the reply from the mock cs server
response_dict = json.loads(response.read())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# lint-amnesty, pylint: disable=missing-module-docstring
import json

import django.http
Expand All @@ -8,10 +9,10 @@
import openedx.core.djangoapps.django_comment_common.comment_client as comment_client


class AjaxExceptionTestCase(TestCase):
class AjaxExceptionTestCase(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring

def setUp(self):
super(AjaxExceptionTestCase, self).setUp()
super(AjaxExceptionTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.a = middleware.AjaxExceptionMiddleware()
self.request1 = django.http.HttpRequest()
self.request0 = django.http.HttpRequest()
Expand Down
Loading