fix: fix new pylint warnings (#28725)
This commit is contained in:
@@ -369,7 +369,7 @@ class formula(object):
|
||||
if (
|
||||
tag == 'msup' and
|
||||
len(k) == 2 and gettag(k[1]) == 'mrow' and
|
||||
gettag(k[1][0]) == 'mo' and k[1][0].text == u'\u200b' # whew
|
||||
gettag(k[1][0]) == 'mo' and k[1][0].text == '\u200b' # whew
|
||||
):
|
||||
|
||||
# replace the msup with 'X__Y'
|
||||
@@ -384,7 +384,7 @@ class formula(object):
|
||||
if (
|
||||
tag == 'msubsup' and
|
||||
len(k) == 3 and gettag(k[2]) == 'mrow' and
|
||||
gettag(k[2][0]) == 'mo' and k[2][0].text == u'\u200b' # whew
|
||||
gettag(k[2][0]) == 'mo' and k[2][0].text == '\u200b' # whew
|
||||
):
|
||||
|
||||
# replace the msubsup with 'X_Y__Z'
|
||||
|
||||
@@ -354,7 +354,7 @@ class CourseFixture(XBlockContainerFixture):
|
||||
'children': None,
|
||||
'data': handouts_html,
|
||||
'id': self._handouts_loc,
|
||||
'metadata': dict(),
|
||||
'metadata': {},
|
||||
})
|
||||
|
||||
response = self.session.post(url, data=payload, headers=self.headers)
|
||||
|
||||
@@ -269,7 +269,7 @@ class VideoComponentPage(VideoPage):
|
||||
"""
|
||||
Download handout at `url`
|
||||
"""
|
||||
kwargs = dict()
|
||||
kwargs = {}
|
||||
session_id = [{i['name']: i['value']} for i in self.browser.get_cookies() if i['name'] == 'sessionid']
|
||||
if session_id:
|
||||
kwargs.update({
|
||||
|
||||
@@ -302,7 +302,7 @@ class BadgrBackend(BadgeBackend):
|
||||
Headers to send along with the request-- used for authentication.
|
||||
"""
|
||||
access_token = self._get_access_token()
|
||||
return {'Authorization': u'Bearer {}'.format(access_token)}
|
||||
return {'Authorization': 'Bearer {}'.format(access_token)}
|
||||
|
||||
def _ensure_badge_created(self, badge_class):
|
||||
"""
|
||||
|
||||
@@ -585,7 +585,7 @@ def get_certificate_footer_context():
|
||||
Return data to be used in Certificate Footer,
|
||||
data returned should be customized according to the site configuration.
|
||||
"""
|
||||
data = dict()
|
||||
data = {}
|
||||
|
||||
# get Terms of Service and Honor Code page url
|
||||
terms_of_service_and_honor_code = branding_api.get_tos_and_honor_code_url()
|
||||
|
||||
@@ -71,7 +71,7 @@ class CourseListGetForm(UsernameValidatorMixin, Form):
|
||||
cleaned_data = super().clean()
|
||||
|
||||
# create a filter for all supported filter fields
|
||||
filter_ = dict()
|
||||
filter_ = {}
|
||||
for supported_filter in self.supported_filters:
|
||||
if cleaned_data.get(supported_filter.param_name) is not None:
|
||||
filter_[supported_filter.field_name] = cleaned_data[supported_filter.param_name]
|
||||
|
||||
@@ -173,7 +173,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, field_
|
||||
if course_module is None:
|
||||
return None, None, None
|
||||
|
||||
toc_chapters = list()
|
||||
toc_chapters = []
|
||||
chapters = course_module.get_display_items()
|
||||
|
||||
# Check for content which needs to be completed
|
||||
@@ -201,7 +201,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, field_
|
||||
if chapter.hide_from_toc or local_hide_from_toc:
|
||||
continue
|
||||
|
||||
sections = list()
|
||||
sections = []
|
||||
for section in chapter.get_display_items():
|
||||
# skip the section if it is hidden from the user
|
||||
if section.hide_from_toc:
|
||||
|
||||
@@ -311,7 +311,7 @@ class SingleTextbookTab(CourseTab):
|
||||
""" Constructs a link for textbooks from a view name, a course, and an index. """
|
||||
return reverse_func(view_name, args=[str(course.id), index])
|
||||
|
||||
tab_dict = dict()
|
||||
tab_dict = {}
|
||||
tab_dict['name'] = name
|
||||
tab_dict['tab_id'] = tab_id
|
||||
tab_dict['link_func'] = link_func
|
||||
@@ -393,10 +393,10 @@ def _get_dynamic_tabs(course, user):
|
||||
Note: dynamic tabs are those that are not persisted in the course, but are
|
||||
instead added dynamically based upon the user's role.
|
||||
"""
|
||||
dynamic_tabs = list()
|
||||
dynamic_tabs = []
|
||||
for tab_type in CourseTabPluginManager.get_tab_types():
|
||||
if getattr(tab_type, "is_dynamic", False):
|
||||
tab = tab_type(dict())
|
||||
tab = tab_type({})
|
||||
if tab.is_enabled(course, user=user):
|
||||
dynamic_tabs.append(tab)
|
||||
dynamic_tabs.sort(key=lambda dynamic_tab: dynamic_tab.name)
|
||||
|
||||
@@ -238,7 +238,7 @@ class CourseInfoTitleTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
|
||||
@ddt.data(
|
||||
# Default site configuration shows course number, org, and display name as subtitle.
|
||||
(dict(),
|
||||
({},
|
||||
"Welcome to HogwartsX's Potions101!", "Introduction to Potions"),
|
||||
|
||||
# Show org in title
|
||||
|
||||
@@ -162,7 +162,7 @@ def preprocess_collection(user, course, collection):
|
||||
# pylint: disable=too-many-statements
|
||||
|
||||
store = modulestore()
|
||||
filtered_collection = list()
|
||||
filtered_collection = []
|
||||
cache = {}
|
||||
include_path_info = ('course_structure' not in settings.NOTES_DISABLED_TABS)
|
||||
with store.bulk_operations(course.id):
|
||||
|
||||
@@ -1383,7 +1383,7 @@ class GradebookViewTest(GradebookViewTestBase):
|
||||
def test_filter_course_roles(self, excluded_course_roles):
|
||||
""" Test that excluded_course_roles=all filters out any user with a course role """
|
||||
# Create test users, enroll them in the course, and give them roles.
|
||||
role_user_usernames = dict()
|
||||
role_user_usernames = {}
|
||||
course_roles_to_create = [
|
||||
CourseInstructorRole,
|
||||
CourseStaffRole,
|
||||
|
||||
@@ -542,7 +542,7 @@ def create_and_enroll_user(email, username, name, country, password, course_id,
|
||||
|
||||
:return: list of errors
|
||||
"""
|
||||
errors = list()
|
||||
errors = []
|
||||
try:
|
||||
with transaction.atomic():
|
||||
# Create a new user
|
||||
|
||||
@@ -219,7 +219,7 @@ class TestRescoringTask(TestIntegrationTask):
|
||||
)
|
||||
|
||||
@ddt.data(
|
||||
RescoreTestData(edit=dict(), new_expected_scores=(2, 1, 1, 0), new_expected_max=2),
|
||||
RescoreTestData(edit={}, new_expected_scores=(2, 1, 1, 0), new_expected_max=2),
|
||||
RescoreTestData(edit=dict(correct_answer=OPTION_2), new_expected_scores=(2, 1, 1, 2), new_expected_max=2),
|
||||
)
|
||||
@ddt.unpack
|
||||
|
||||
@@ -1778,7 +1778,7 @@ class TestGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
|
||||
metadata={'graded': True, 'format': 'Homework', 'start': in_the_future},
|
||||
display_name='Unreleased'
|
||||
)
|
||||
self.define_option_problem(u'Unreleased', parent=self.unreleased_section)
|
||||
self.define_option_problem('Unreleased', parent=self.unreleased_section)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'DISABLE_START_DATES': False})
|
||||
@ddt.data(True, False)
|
||||
|
||||
@@ -407,7 +407,7 @@ def get_users_by_external_keys_and_org_key(external_user_keys, org_key):
|
||||
ProviderDoesNotExistsException
|
||||
"""
|
||||
saml_providers = get_saml_providers_by_org_key(org_key)
|
||||
found_users_by_external_keys = dict()
|
||||
found_users_by_external_keys = {}
|
||||
# if the same external id exists in multiple providers (for this organization)
|
||||
# it is expected both providers return the same user
|
||||
for saml_provider in saml_providers:
|
||||
|
||||
@@ -72,7 +72,7 @@ def _lookup_team_membership_data(course):
|
||||
team_membership_data = []
|
||||
for course_enrollment in course_enrollments:
|
||||
# This dict contains all the user's team memberships keyed by teamset
|
||||
student_row = teamset_memberships_by_user.get(course_enrollment.user, dict())
|
||||
student_row = teamset_memberships_by_user.get(course_enrollment.user, {})
|
||||
student_row['user'] = _get_displayed_user_identifier(course_enrollment)
|
||||
student_row['mode'] = course_enrollment.mode
|
||||
team_membership_data.append(student_row)
|
||||
@@ -131,11 +131,11 @@ def _group_teamset_memberships_by_user(course_team_memberships):
|
||||
per user represented in input
|
||||
}
|
||||
"""
|
||||
teamset_memberships_by_user = dict()
|
||||
teamset_memberships_by_user = {}
|
||||
for team_membership in course_team_memberships:
|
||||
user = team_membership.user
|
||||
if user not in teamset_memberships_by_user:
|
||||
teamset_memberships_by_user[user] = dict()
|
||||
teamset_memberships_by_user[user] = {}
|
||||
topic_id = team_membership.team.topic_id
|
||||
team_name = team_membership.team.name
|
||||
teamset_memberships_by_user[user][topic_id] = team_name
|
||||
|
||||
@@ -808,7 +808,7 @@ class TeamsDetailView(ExpandableFieldViewMixin, RetrievePatchAPIView):
|
||||
"""DELETE /api/team/v0/teams/{team_id}"""
|
||||
team = get_object_or_404(CourseTeam, team_id=team_id)
|
||||
self.check_object_permissions(request, team)
|
||||
# Note: list() forces the queryset to be evualuated before delete()
|
||||
# Note: [] forces the queryset to be evualuated before delete()
|
||||
memberships = list(CourseTeamMembership.get_memberships(team_ids=[team_id]))
|
||||
|
||||
# Note: also deletes all team memberships associated with this team
|
||||
|
||||
Reference in New Issue
Block a user