Remove needless 'disable=no-member' pragmas

This commit is contained in:
Ned Batchelder
2015-08-03 16:59:57 -04:00
parent ee0f4b2594
commit f54fe787c6
73 changed files with 144 additions and 186 deletions

View File

@@ -16,8 +16,8 @@ new_contract('CourseKey', CourseKey)
new_contract('datetime', datetime)
new_contract('basestring', basestring)
new_contract('long', long)
new_contract('AssetElement', lambda x: isinstance(x, etree._Element) and x.tag == "asset") # pylint: disable=protected-access, no-member
new_contract('AssetsElement', lambda x: isinstance(x, etree._Element) and x.tag == "assets") # pylint: disable=protected-access, no-member
new_contract('AssetElement', lambda x: isinstance(x, etree._Element) and x.tag == "asset") # pylint: disable=protected-access
new_contract('AssetsElement', lambda x: isinstance(x, etree._Element) and x.tag == "assets") # pylint: disable=protected-access
class AssetMetadata(object):

View File

@@ -1049,8 +1049,6 @@ class CapaMixin(CapaFields):
# Wait time between resets: check if is too soon for submission.
if self.last_submission_time is not None and self.submission_wait_seconds != 0:
# pylint: disable=maybe-no-member
# pylint is unable to verify that .total_seconds() exists
if (current_time - self.last_submission_time).total_seconds() < self.submission_wait_seconds:
remaining_secs = int(self.submission_wait_seconds - (current_time - self.last_submission_time).total_seconds())
msg = _(u'You must wait at least {wait_secs} between submissions. {remaining_secs} remaining.').format(

View File

@@ -185,7 +185,7 @@ class CapaDescriptor(CapaFields, RawDescriptor):
@property
def problem_types(self):
""" Low-level problem type introspection for content libraries filtering by problem type """
tree = etree.XML(self.data) # pylint: disable=no-member
tree = etree.XML(self.data)
registered_tags = responsetypes.registry.registered_tags()
return set([node.tag for node in tree.iter() if node.tag in registered_tags])

View File

@@ -377,7 +377,6 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe
# exactly the same children-- someone may be duplicating an out of date block, after all.
user_id = self.get_user_id()
user_perms = self.runtime.service(self, 'studio_user_permissions')
# pylint: disable=no-member
if not self.tools:
raise RuntimeError("Library tools unavailable, duplication will not be sane!")
self.tools.update_children(self, user_id, user_perms, version=self.source_library_version)

View File

@@ -78,7 +78,7 @@ class LibraryRoot(XBlock):
force_render = context.get('force_render', None)
for child_key in children_to_show: # pylint: disable=E1101
for child_key in children_to_show:
# Children must have a separate context from the library itself. Make a copy.
child_context = context.copy()
child_context['show_preview'] = self.show_children_previews

View File

@@ -2282,8 +2282,6 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
Returns the new set of BlockKeys that are the new descendants of the block with key 'block_key'
"""
# pylint: disable=no-member
# ^-- Until pylint gets namedtuple support, it will give warnings about BlockKey attributes
new_blocks = set()
new_children = list() # ordered list of the new children of new_parent_block_key

View File

@@ -1,4 +1,3 @@
# pylint: disable=no-member
"""
Unit tests for the Mixed Modulestore, with DDT for the various stores (Split, Draft, XML)
"""
@@ -283,7 +282,7 @@ class CommonMixedModuleStoreSetup(CourseComparisonTest):
# and then to the root UsageKey
self.course_locations = {
course_id: course_key.make_usage_key('course', course_key.run)
for course_id, course_key in self.course_locations.iteritems() # pylint: disable=maybe-no-member
for course_id, course_key in self.course_locations.iteritems()
}
mongo_course_key = self.course_locations[self.MONGO_COURSEID].course_key

View File

@@ -1,7 +1,6 @@
"""
Unit tests for the Mongo modulestore
"""
# pylint: disable=no-member
# pylint: disable=protected-access
# pylint: disable=no-name-in-module
# pylint: disable=bad-continuation

View File

@@ -270,7 +270,7 @@ class ImportManager(object):
all_assets = []
try:
xml_data = etree.parse(asset_xml_file).getroot() # pylint: disable=no-member
xml_data = etree.parse(asset_xml_file).getroot()
assert xml_data.tag == AssetMetadata.ALL_ASSETS_XML_TAG
for asset in xml_data.iterchildren():
if asset.tag == AssetMetadata.ASSET_XML_TAG:

View File

@@ -49,7 +49,6 @@ class Group(namedtuple("Group", "id name")):
Returns:
a dictionary with keys for the properties of the group.
"""
# pylint: disable=no-member
return {
"id": self.id,
"name": self.name,
@@ -133,7 +132,6 @@ class UserPartition(namedtuple("UserPartition", "id name description groups sche
Returns:
a dictionary with keys for the properties of the partition.
"""
# pylint: disable=no-member
return {
"id": self.id,
"name": self.name,
@@ -187,8 +185,6 @@ class UserPartition(namedtuple("UserPartition", "id name description groups sche
"""
Returns the group with the specified id. Raises NoSuchUserPartitionGroupError if not found.
"""
# pylint: disable=no-member
for group in self.groups:
if group.id == group_id:
return group

View File

@@ -20,14 +20,14 @@ class TestGroup(TestCase):
test_id = 10
name = "Grendel"
group = Group(test_id, name)
self.assertEqual(group.id, test_id) # pylint: disable=no-member
self.assertEqual(group.id, test_id)
self.assertEqual(group.name, name)
def test_string_id(self):
test_id = "10"
name = "Grendel"
group = Group(test_id, name)
self.assertEqual(group.id, 10) # pylint: disable=no-member
self.assertEqual(group.id, 10)
def test_to_json(self):
test_id = 10
@@ -50,7 +50,7 @@ class TestGroup(TestCase):
"version": Group.VERSION
}
group = Group.from_json(jsonified)
self.assertEqual(group.id, test_id) # pylint: disable=no-member
self.assertEqual(group.id, test_id)
self.assertEqual(group.name, name)
def test_from_json_broken(self):
@@ -151,17 +151,17 @@ class TestUserPartition(PartitionTestCase):
user_partition = UserPartition(
self.TEST_ID, self.TEST_NAME, self.TEST_DESCRIPTION, self.TEST_GROUPS, MockUserPartitionScheme()
)
self.assertEqual(user_partition.id, self.TEST_ID) # pylint: disable=no-member
self.assertEqual(user_partition.id, self.TEST_ID)
self.assertEqual(user_partition.name, self.TEST_NAME)
self.assertEqual(user_partition.description, self.TEST_DESCRIPTION) # pylint: disable=no-member
self.assertEqual(user_partition.groups, self.TEST_GROUPS) # pylint: disable=no-member
self.assertEquals(user_partition.scheme.name, self.TEST_SCHEME_NAME) # pylint: disable=no-member
self.assertEqual(user_partition.description, self.TEST_DESCRIPTION)
self.assertEqual(user_partition.groups, self.TEST_GROUPS)
self.assertEquals(user_partition.scheme.name, self.TEST_SCHEME_NAME)
def test_string_id(self):
user_partition = UserPartition(
"70", self.TEST_NAME, self.TEST_DESCRIPTION, self.TEST_GROUPS
)
self.assertEqual(user_partition.id, 70) # pylint: disable=no-member
self.assertEqual(user_partition.id, 70)
def test_to_json(self):
jsonified = self.user_partition.to_json()
@@ -185,10 +185,10 @@ class TestUserPartition(PartitionTestCase):
"scheme": "mock",
}
user_partition = UserPartition.from_json(jsonified)
self.assertEqual(user_partition.id, self.TEST_ID) # pylint: disable=no-member
self.assertEqual(user_partition.name, self.TEST_NAME) # pylint: disable=no-member
self.assertEqual(user_partition.description, self.TEST_DESCRIPTION) # pylint: disable=no-member
for act_group in user_partition.groups: # pylint: disable=no-member
self.assertEqual(user_partition.id, self.TEST_ID)
self.assertEqual(user_partition.name, self.TEST_NAME)
self.assertEqual(user_partition.description, self.TEST_DESCRIPTION)
for act_group in user_partition.groups:
self.assertIn(act_group.id, [0, 1])
exp_group = self.TEST_GROUPS[act_group.id]
self.assertEqual(exp_group.id, act_group.id)
@@ -204,7 +204,7 @@ class TestUserPartition(PartitionTestCase):
"version": 1,
}
user_partition = UserPartition.from_json(jsonified)
self.assertEqual(user_partition.scheme.name, "random") # pylint: disable=no-member
self.assertEqual(user_partition.scheme.name, "random")
def test_from_json_broken(self):
# Missing field
@@ -274,11 +274,11 @@ class TestUserPartition(PartitionTestCase):
the lookup fails.
"""
self.assertEqual(
self.user_partition.get_group(self.TEST_GROUPS[0].id), # pylint: disable=no-member
self.user_partition.get_group(self.TEST_GROUPS[0].id),
self.TEST_GROUPS[0]
)
self.assertEqual(
self.user_partition.get_group(self.TEST_GROUPS[1].id), # pylint: disable=no-member
self.user_partition.get_group(self.TEST_GROUPS[1].id),
self.TEST_GROUPS[1]
)
with self.assertRaises(NoSuchUserPartitionGroupError):
@@ -326,22 +326,22 @@ class TestPartitionService(PartitionTestCase):
def test_get_user_group_id_for_partition(self):
# assign the first group to be returned
user_partition_id = self.user_partition.id # pylint: disable=no-member
groups = self.user_partition.groups # pylint: disable=no-member
self.user_partition.scheme.current_group = groups[0] # pylint: disable=no-member
user_partition_id = self.user_partition.id
groups = self.user_partition.groups
self.user_partition.scheme.current_group = groups[0]
# get a group assigned to the user
group1_id = self.partition_service.get_user_group_id_for_partition(user_partition_id)
self.assertEqual(group1_id, groups[0].id) # pylint: disable=no-member
self.assertEqual(group1_id, groups[0].id)
# switch to the second group and verify that it is returned for the user
self.user_partition.scheme.current_group = groups[1] # pylint: disable=no-member
self.user_partition.scheme.current_group = groups[1]
group2_id = self.partition_service.get_user_group_id_for_partition(user_partition_id)
self.assertEqual(group2_id, groups[1].id) # pylint: disable=no-member
self.assertEqual(group2_id, groups[1].id)
def test_caching(self):
username = "psvc_cache_user"
user_partition_id = self.user_partition.id # pylint: disable=no-member
user_partition_id = self.user_partition.id
shared_cache = {}
# Two StaticPartitionService objects that share the same cache:
@@ -356,7 +356,7 @@ class TestPartitionService(PartitionTestCase):
# Set the group we expect users to be placed into
first_group = self.user_partition.groups[0]
self.user_partition.scheme.current_group = first_group # pylint: disable=no-member
self.user_partition.scheme.current_group = first_group
# Make sure our partition services all return the right thing, but skip
# ps_shared_cache_2 so we can see if its cache got updated anyway.
@@ -396,14 +396,14 @@ class TestPartitionService(PartitionTestCase):
"""
Test that a partition group is assigned to a user.
"""
groups = self.user_partition.groups # pylint: disable=no-member
groups = self.user_partition.groups
# assign first group and verify that it is returned for the user
self.user_partition.scheme.current_group = groups[0] # pylint: disable=no-member
self.user_partition.scheme.current_group = groups[0]
group1 = self.partition_service.get_group(self.user_partition)
self.assertEqual(group1, groups[0]) # pylint: disable=no-member
self.assertEqual(group1, groups[0])
# switch to the second group and verify that it is returned for the user
self.user_partition.scheme.current_group = groups[1] # pylint: disable=no-member
self.user_partition.scheme.current_group = groups[1]
group2 = self.partition_service.get_group(self.user_partition)
self.assertEqual(group2, groups[1]) # pylint: disable=no-member
self.assertEqual(group2, groups[1])

View File

@@ -95,7 +95,7 @@ class DateTest(unittest.TestCase):
now = datetime.datetime.now(UTC())
delta = now - datetime.datetime.fromtimestamp(0, UTC())
self.assertEqual(
DateTest.date.from_json(delta.total_seconds() * 1000), # pylint: disable=maybe-no-member
DateTest.date.from_json(delta.total_seconds() * 1000),
now
)
yesterday = datetime.datetime.now(UTC()) - datetime.timedelta(days=-1)

View File

@@ -113,13 +113,13 @@ class SplitTestModuleLMSTest(SplitTestModuleTest):
@ddt.data((0, 'split_test_cond0'), (1, 'split_test_cond1'))
@ddt.unpack
def test_child(self, user_tag, child_url_name):
self.user_partition.scheme.current_group = self.user_partition.groups[user_tag] # pylint: disable=no-member
self.user_partition.scheme.current_group = self.user_partition.groups[user_tag]
self.assertEquals(self.split_test_module.child_descriptor.url_name, child_url_name)
@ddt.data((0, 'HTML FOR GROUP 0'), (1, 'HTML FOR GROUP 1'))
@ddt.unpack
def test_get_html(self, user_tag, child_content):
self.user_partition.scheme.current_group = self.user_partition.groups[user_tag] # pylint: disable=no-member
self.user_partition.scheme.current_group = self.user_partition.groups[user_tag]
self.assertIn(
child_content,
self.module_system.render(self.split_test_module, STUDENT_VIEW).content

View File

@@ -77,7 +77,7 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
Returns the progress on this block and all children.
"""
# TODO: Cache progress or children array?
children = self.get_children() # pylint: disable=no-member
children = self.get_children()
progresses = [child.get_progress() for child in children]
progress = reduce(Progress.add_counts, progresses, None)
return progress
@@ -86,7 +86,7 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
"""
Returns the highest priority icon class.
"""
child_classes = set(child.get_icon_class() for child in self.get_children()) # pylint: disable=no-member
child_classes = set(child.get_icon_class() for child in self.get_children())
new_class = 'other'
for higher_class in CLASS_PRIORITY:
if higher_class in child_classes:
@@ -109,7 +109,7 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse
def definition_to_xml(self, resource_fs):
xml_object = etree.Element('vertical') # pylint: disable=no-member
for child in self.get_children(): # pylint: disable=no-member
for child in self.get_children():
self.runtime.add_block_as_child_node(child, xml_object)
return xml_object

View File

@@ -99,7 +99,6 @@ def youtube_video_transcript_name(youtube_text_api):
Get the transcript name from available transcripts of video
with respect to language from youtube server
"""
# pylint: disable=no-member
utf8_parser = etree.XMLParser(encoding='utf-8')
transcripts_param = {'type': 'list', 'v': youtube_text_api['params']['v']}
@@ -109,7 +108,6 @@ def youtube_video_transcript_name(youtube_text_api):
# http://video.google.com/timedtext?type=list&v={VideoId}
youtube_response = requests.get('http://' + youtube_text_api['url'], params=transcripts_param)
if youtube_response.status_code == 200 and youtube_response.text:
# pylint: disable=no-member
youtube_data = etree.fromstring(youtube_response.content, parser=utf8_parser)
# iterate all transcripts information from youtube server
for element in youtube_data:

View File

@@ -184,7 +184,7 @@ class XmlParserMixin(object):
Returns an lxml Element
"""
return etree.parse(file_object, parser=EDX_XML_PARSER).getroot() # pylint: disable=no-member
return etree.parse(file_object, parser=EDX_XML_PARSER).getroot()
@classmethod
def load_file(cls, filepath, fs, def_id): # pylint: disable=invalid-name
@@ -499,7 +499,7 @@ class XmlDescriptor(XmlParserMixin, XModuleDescriptor): # pylint: disable=abstr
# a) define from_xml themselves
# b) call super(..).from_xml(..)
return super(XmlDescriptor, cls).parse_xml(
etree.fromstring(xml_data), # pylint: disable=no-member
etree.fromstring(xml_data),
system,
None, # This is ignored by XmlParserMixin
id_generator,