Skip to content
4 changes: 3 additions & 1 deletion cms/djangoapps/contentstore/git_export_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ def export_to_git(course_id, repo, user='', rdir=None):
ident = GIT_EXPORT_DEFAULT_IDENT
time_stamp = timezone.now()
cwd = os.path.abspath(rdirp)
commit_msg = 'Export from Studio at {1}'.format(user, time_stamp)
commit_msg = "Export from Studio at {time_stamp}".format(
time_stamp=time_stamp,
)
try:
cmd_log(['git', 'config', 'user.email', ident['email']], cwd)
cmd_log(['git', 'config', 'user.name', ident['name']], cwd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def parse_args(self, *args):
try:
user = user_from_str(args[1])
except User.DoesNotExist:
raise CommandError("No user {} found: expected args are ".format(args[1], self.args))
raise CommandError(
"No user {user} found: expected args are {args}".format(
user=args[1],
args=self.args,
),
)

org = args[2]
course = args[3]
Expand Down
5 changes: 4 additions & 1 deletion cms/djangoapps/contentstore/tests/test_core_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from django.test import TestCase


class Content:
class Content(object):
"""
Mock cached content
"""
def __init__(self, location, content):
self.location = location
self.content = content
Expand Down
3 changes: 0 additions & 3 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@
# Prerequisite courses feature flag
'ENABLE_PREREQUISITE_COURSES': False,

# Toggle course milestones app/feature
'MILESTONES_APP': False,

# Toggle course entrance exams feature
'ENTRANCE_EXAMS': False,

Expand Down
2 changes: 1 addition & 1 deletion common/lib/capa/capa/safe_exec/lazymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ def __getattr__(self, name):
submod = getattr(mod, name)
except ImportError:
raise AttributeError("'module' object has no attribute %r" % name)
self.__dict__[name] = LazyModule(subname, submod)
self.__dict__[name] = LazyModule(subname)
return self.__dict__[name]
4 changes: 2 additions & 2 deletions common/lib/xmodule/xmodule/capa_base_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


class SHOWANSWER:
class SHOWANSWER(object):
"""
Constants for when to show answer
"""
Expand All @@ -18,7 +18,7 @@ class SHOWANSWER:
NEVER = "never"


class RANDOMIZATION:
class RANDOMIZATION(object):
"""
Constants for problem randomization
"""
Expand Down
7 changes: 5 additions & 2 deletions common/lib/xmodule/xmodule/modulestore/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ def __str__(self, *args, **kwargs):
"""
Print info about what's duplicated
"""
return '{0.store}[{0.collection}] already has {0.element_id}'.format(
self, Exception.__str__(self, *args, **kwargs)
return "{store}[{collection}] already has {element_id} ({exception})".format(
store=self.store,
collection=self.collection,
element_id=self.element_id,
exception=Exception.__str__(self, *args, **kwargs),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why this code is Exception.__str__(self, *args, **kwargs) instead of just self? The string formatting should automatically coerce the self argument to a string.

If you don't want to make this change, that's fine with me -- I'm in favor of keeping this pull request small and focused as much as possible. This just caught my eye, and I was confused.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sure either, so I think I'll opt to pass for now :)

)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
SKIP_BASIC_CHECKS = False


class CombinedOpenEndedV1Module():
class CombinedOpenEndedV1Module(object):
"""
This is a module that encapsulates all open ended grading (self assessment, peer assessment, etc).
It transitions between problems, and support arbitrary ordering.
Expand Down Expand Up @@ -1185,7 +1185,7 @@ def service_declaration(cls, service_name):
return declaration


class CombinedOpenEndedV1Descriptor():
class CombinedOpenEndedV1Descriptor(object):
"""
Module for adding combined open ended questions
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def score_for_attempt(self, index):
return score


class OpenEndedDescriptor():
class OpenEndedDescriptor(object):
"""
Module for adding open ended response questions to courses
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def latest_post_assessment(self, system):
return [rubric_scores]


class SelfAssessmentDescriptor():
class SelfAssessmentDescriptor(object):
"""
Module for adding self assessment questions to courses
"""
Expand Down
2 changes: 1 addition & 1 deletion common/lib/xmodule/xmodule/peer_grading_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def peer_grading_problem(self, data=None):
elif data.get('location') is not None:
problem_location = self.course_id.make_usage_key_from_deprecated_string(data.get('location'))

module = self._find_corresponding_module_for_location(problem_location) # pylint: disable-unused-variable
self._find_corresponding_module_for_location(problem_location)

ajax_url = self.ajax_url
html = self.system.render_template('peer_grading/peer_grading_problem.html', {
Expand Down
7 changes: 5 additions & 2 deletions common/lib/xmodule/xmodule/tests/test_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@
"""


class Content:
class Content(object):
"""
A class with location and content_type members
"""
def __init__(self, location, content_type):
self.location = location
self.content_type = content_type


class FakeGridFsItem:
class FakeGridFsItem(object):
"""
This class provides the basic methods to get data from a GridFS item
"""
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/bulk_email/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CourseEmailTemplateForm(forms.ModelForm):

name = forms.CharField(required=False)

class Meta: # pylint: disable=missing-docstring
class Meta(object): # pylint: disable=missing-docstring
model = CourseEmailTemplate
fields = ('html_template', 'plain_template', 'name')

Expand Down Expand Up @@ -76,7 +76,7 @@ def clean_name(self):
class CourseAuthorizationAdminForm(forms.ModelForm):
"""Input form for email enabling, allowing us to verify data."""

class Meta: # pylint: disable=missing-docstring
class Meta(object): # pylint: disable=missing-docstring
model = CourseAuthorization

def clean_course_id(self):
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/bulk_email/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Email(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)

class Meta: # pylint: disable=missing-docstring
class Meta(object): # pylint: disable=missing-docstring
abstract = True


Expand Down Expand Up @@ -142,7 +142,7 @@ class Optout(models.Model):
user = models.ForeignKey(User, db_index=True, null=True)
course_id = CourseKeyField(max_length=255, db_index=True)

class Meta: # pylint: disable=missing-docstring
class Meta(object): # pylint: disable=missing-docstring
unique_together = ('user', 'course_id')


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def handle(self, *args, **options):
else:
user = User.objects.get(username=user_str)

cert_whitelist, created = \
cert_whitelist, _created = \
CertificateWhitelist.objects.get_or_create(
user=user, course_id=course)
if options['add']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def handle(self, *args, **options):
diff = datetime.datetime.now(UTC) - start
timeleft = diff * (total - count) / STATUS_INTERVAL
hours, remainder = divmod(timeleft.seconds, 3600)
minutes, seconds = divmod(remainder, 60)
minutes, _seconds = divmod(remainder, 60)
print "{0}/{1} completed ~{2:02}:{3:02}m remaining".format(
count, total, hours, minutes)
start = datetime.datetime.now(UTC)
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/certificates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class GeneratedCertificate(models.Model):
auto_now=True, default=datetime.now)
error_reason = models.CharField(max_length=512, blank=True, default='')

class Meta:
class Meta(object): # pylint: disable=missing-docstring
unique_together = (('user', 'course_id'),)

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/course_wiki/editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_admin_widget(self, instance=None):
def get_widget(self, instance=None):
return CodeMirrorWidget()

class AdminMedia:
class AdminMedia(object): # pylint: disable=missing-docstring
css = {
'all': ("wiki/markitup/skins/simple/style.css",
"wiki/markitup/sets/admin/style.css",)
Expand All @@ -52,7 +52,7 @@ class AdminMedia:
"wiki/markitup/sets/admin/set.js",
)

class Media:
class Media(object): # pylint: disable=missing-docstring
css = {
'all': ("js/vendor/CodeMirror/codemirror.css",)
}
Expand Down
1 change: 0 additions & 1 deletion lms/djangoapps/course_wiki/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def create_course_page(self, course):
course_wiki_page = referer.replace('progress', 'wiki/' + self.toy.wiki_slug + "/")

ending_location = resp.redirect_chain[-1][0]
ending_status = resp.redirect_chain[-1][1]

self.assertEquals(ending_location, 'http://testserver' + course_wiki_page)
self.assertEquals(resp.status_code, 200)
Expand Down
16 changes: 8 additions & 8 deletions lms/djangoapps/courseware/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StudentModule(models.Model):

course_id = CourseKeyField(max_length=255, db_index=True)

class Meta:
class Meta(object): # pylint: disable=missing-docstring
unique_together = (('student', 'module_state_key', 'course_id'),)

## Internal state of the object
Expand Down Expand Up @@ -102,7 +102,7 @@ class StudentModuleHistory(models.Model):

HISTORY_SAVING_TYPES = {'problem'}

class Meta:
class Meta(object): # pylint: disable=missing-docstring
get_latest_by = "created"

student_module = models.ForeignKey(StudentModule, db_index=True)
Expand Down Expand Up @@ -135,7 +135,7 @@ class XBlockFieldBase(models.Model):
"""
Base class for all XBlock field storage.
"""
class Meta:
class Meta(object): # pylint: disable=missing-docstring
abstract = True

# The name of the field
Expand Down Expand Up @@ -163,7 +163,7 @@ class XModuleUserStateSummaryField(XBlockFieldBase):
Stores data set in the Scope.user_state_summary scope by an xmodule field
"""

class Meta:
class Meta(object): # pylint: disable=missing-docstring
unique_together = (('usage_id', 'field_name'),)

# The definition id for the module
Expand All @@ -175,7 +175,7 @@ class XModuleStudentPrefsField(XBlockFieldBase):
Stores data set in the Scope.preferences scope by an xmodule field
"""

class Meta: # pylint: disable=missing-docstring
class Meta(object): # pylint: disable=missing-docstring
unique_together = (('student', 'module_type', 'field_name'),)

# The type of the module for these preferences
Expand All @@ -189,7 +189,7 @@ class XModuleStudentInfoField(XBlockFieldBase):
Stores data set in the Scope.preferences scope by an xmodule field
"""

class Meta:
class Meta(object): # pylint: disable=missing-docstring
unique_together = (('student', 'field_name'),)

student = models.ForeignKey(User, db_index=True)
Expand All @@ -207,7 +207,7 @@ class OfflineComputedGrade(models.Model):

gradeset = models.TextField(null=True, blank=True) # grades, stored as JSON

class Meta:
class Meta(object): # pylint: disable=missing-docstring
unique_together = (('user', 'course_id'), )

def __unicode__(self):
Expand All @@ -219,7 +219,7 @@ class OfflineComputedGradeLog(models.Model):
Log of when offline grades are computed.
Use this to be able to show instructor when the last computed grades were done.
"""
class Meta:
class Meta(object): # pylint: disable=missing-docstring
ordering = ["-created"]
get_latest_by = "created"

Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def setup_course(self):
# username = robot{0}, password = 'test'
self.users = [
UserFactory.create()
for i in range(self.USER_COUNT)
for dummy0 in range(self.USER_COUNT)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use _ or __ as a dummy variable name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pylint supports this syntax as a valid name for unused variables.

Using dummyN makes it clearer that it is a throwaway value:

  • _ shadows gettext
  • __ closely resembles the above

Often times, I'll prepend a _ to a signal an usused parameter, but
_i is too short and a bit more cryptic and unclear.

]

for user in self.users:
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/django_comment_client/forum/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ def test_404_profiled_user(self, mock_request):
request = RequestFactory().get("dummy_url")
request.user = self.student
with self.assertRaises(Http404):
response = views.user_profile(
views.user_profile(
request,
self.course.id.to_deprecated_string(),
-999
Expand All @@ -1095,7 +1095,7 @@ def test_404_course(self, mock_request):
request = RequestFactory().get("dummy_url")
request.user = self.student
with self.assertRaises(Http404):
response = views.user_profile(
views.user_profile(
request,
"non/existent/course",
self.profiled_user.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import threading
import json
import urllib2
from mock_cs_server import MockCommentServiceServer
from django_comment_client.tests.mock_cs_server.mock_cs_server import MockCommentServiceServer
from nose.plugins.skip import SkipTest


Expand Down
4 changes: 0 additions & 4 deletions lms/djangoapps/django_comment_client/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ def setUp(self):
self.TA_role_2 = models.Role.objects.get_or_create(name="Community TA",
course_id=self.course_id_2)[0]

class Dummy():
def render_template():
pass

def test_has_permission(self):
# Whenever you add a permission to student_role,
# Roles with the same FORUM_ROLE in same class also receives the same
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/foldit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PuzzleComplete(models.Model):
e.g. PuzzleID 1234, set 1, subset 3. (Sets and subsets correspond to levels
in the intro puzzles)
"""
class Meta:
class Meta(object): # pylint: disable=missing-docstring
# there should only be one puzzle complete entry for any particular
# puzzle for any user
unique_together = ('user', 'puzzle_id', 'puzzle_set', 'puzzle_subset')
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor/tests/test_legacy_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_get_and_clean_student_list(self):
"""

string = "abc@test.com, def@test.com ghi@test.com \n \n jkl@test.com \n mno@test.com "
cleaned_string, cleaned_string_lc = get_and_clean_student_list(string)
cleaned_string, _cleaned_string_lc = get_and_clean_student_list(string)
self.assertEqual(cleaned_string, ['abc@test.com', 'def@test.com', 'ghi@test.com', 'jkl@test.com', 'mno@test.com'])

@ddt.data('http', 'https')
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def setUp(self):
week1 = ItemFactory.create(due=due, parent=course)
week2 = ItemFactory.create(due=due, parent=course)

homework = ItemFactory.create(
ItemFactory.create(
parent=week1,
due=due
)
Expand Down
Loading