Skip to content

Commit

Permalink
fix: bump pylint version (openedx#31084)
Browse files Browse the repository at this point in the history
  • Loading branch information
UsamaSadiq authored Oct 27, 2022
1 parent ce9abc9 commit 4734f9f
Show file tree
Hide file tree
Showing 30 changed files with 99 additions and 80 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/pylint-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ jobs:
matrix:
include:
- module-name: lms-1
path: "lms/djangoapps/badges/ lms/djangoapps/branding/ lms/djangoapps/bulk_email/ lms/djangoapps/bulk_enroll/ lms/djangoapps/bulk_user_retirement/ lms/djangoapps/ccx/ lms/djangoapps/certificates/ lms/djangoapps/commerce/ lms/djangoapps/course_api/ lms/djangoapps/course_blocks/ lms/djangoapps/course_home_api/ lms/djangoapps/course_wiki/ lms/djangoapps/coursewarehistoryextended/ lms/djangoapps/debug/ lms/djangoapps/courseware/ lms/djangoapps/course_goals/ lms/djangoapps/rss_proxy/ lms/djangoapps/save_for_later/"
path: "--django-settings-module=lms.envs.test lms/djangoapps/badges/ lms/djangoapps/branding/ lms/djangoapps/bulk_email/ lms/djangoapps/bulk_enroll/ lms/djangoapps/bulk_user_retirement/ lms/djangoapps/ccx/ lms/djangoapps/certificates/ lms/djangoapps/commerce/ lms/djangoapps/course_api/ lms/djangoapps/course_blocks/ lms/djangoapps/course_home_api/ lms/djangoapps/course_wiki/ lms/djangoapps/coursewarehistoryextended/ lms/djangoapps/debug/ lms/djangoapps/courseware/ lms/djangoapps/course_goals/ lms/djangoapps/rss_proxy/ lms/djangoapps/save_for_later/"
- module-name: lms-2
path: "lms/djangoapps/gating/ lms/djangoapps/grades/ lms/djangoapps/instructor/ lms/djangoapps/instructor_analytics/ lms/djangoapps/discussion/ lms/djangoapps/edxnotes/ lms/djangoapps/email_marketing/ lms/djangoapps/experiments/ lms/djangoapps/instructor_task/ lms/djangoapps/learner_dashboard/ lms/djangoapps/learner_home/ lms/djangoapps/lms_initialization/ lms/djangoapps/lms_xblock/ lms/djangoapps/lti_provider/ lms/djangoapps/mailing/ lms/djangoapps/mobile_api/ lms/djangoapps/monitoring/ lms/djangoapps/ora_staff_grader/ lms/djangoapps/program_enrollments/ lms/djangoapps/rss_proxy lms/djangoapps/static_template_view/ lms/djangoapps/staticbook/ lms/djangoapps/support/ lms/djangoapps/survey/ lms/djangoapps/teams/ lms/djangoapps/tests/ lms/djangoapps/user_tours/ lms/djangoapps/verify_student/ lms/djangoapps/mfe_config_api/ lms/envs/ lms/lib/ lms/tests.py"
path: "--django-settings-module=lms.envs.test lms/djangoapps/gating/ lms/djangoapps/grades/ lms/djangoapps/instructor/ lms/djangoapps/instructor_analytics/ lms/djangoapps/discussion/ lms/djangoapps/edxnotes/ lms/djangoapps/email_marketing/ lms/djangoapps/experiments/ lms/djangoapps/instructor_task/ lms/djangoapps/learner_dashboard/ lms/djangoapps/learner_home/ lms/djangoapps/lms_initialization/ lms/djangoapps/lms_xblock/ lms/djangoapps/lti_provider/ lms/djangoapps/mailing/ lms/djangoapps/mobile_api/ lms/djangoapps/monitoring/ lms/djangoapps/ora_staff_grader/ lms/djangoapps/program_enrollments/ lms/djangoapps/rss_proxy lms/djangoapps/static_template_view/ lms/djangoapps/staticbook/ lms/djangoapps/support/ lms/djangoapps/survey/ lms/djangoapps/teams/ lms/djangoapps/tests/ lms/djangoapps/user_tours/ lms/djangoapps/verify_student/ lms/djangoapps/mfe_config_api/ lms/envs/ lms/lib/ lms/tests.py"
- module-name: openedx-1
path: "openedx/core/types/ openedx/core/djangoapps/ace_common/ openedx/core/djangoapps/agreements/ openedx/core/djangoapps/api_admin/ openedx/core/djangoapps/auth_exchange/ openedx/core/djangoapps/bookmarks/ openedx/core/djangoapps/cache_toolbox/ openedx/core/djangoapps/catalog/ openedx/core/djangoapps/ccxcon/ openedx/core/djangoapps/commerce/ openedx/core/djangoapps/common_initialization/ openedx/core/djangoapps/common_views/ openedx/core/djangoapps/config_model_utils/ openedx/core/djangoapps/content/ openedx/core/djangoapps/content_libraries/ openedx/core/djangoapps/contentserver/ openedx/core/djangoapps/cookie_metadata/ openedx/core/djangoapps/cors_csrf/ openedx/core/djangoapps/course_apps/ openedx/core/djangoapps/course_date_signals/ openedx/core/djangoapps/course_groups/ openedx/core/djangoapps/courseware_api/ openedx/core/djangoapps/crawlers/ openedx/core/djangoapps/credentials/ openedx/core/djangoapps/credit/ openedx/core/djangoapps/dark_lang/ openedx/core/djangoapps/debug/ openedx/core/djangoapps/demographics/ openedx/core/djangoapps/discussions/ openedx/core/djangoapps/django_comment_common/ openedx/core/djangoapps/embargo/ openedx/core/djangoapps/enrollments/ openedx/core/djangoapps/external_user_ids/ openedx/core/djangoapps/zendesk_proxy/ openedx/core/djangolib/ openedx/core/lib/ openedx/core/tests/ openedx/core/djangoapps/course_live/"
path: "--django-settings-module=lms.envs.test openedx/core/types/ openedx/core/djangoapps/ace_common/ openedx/core/djangoapps/agreements/ openedx/core/djangoapps/api_admin/ openedx/core/djangoapps/auth_exchange/ openedx/core/djangoapps/bookmarks/ openedx/core/djangoapps/cache_toolbox/ openedx/core/djangoapps/catalog/ openedx/core/djangoapps/ccxcon/ openedx/core/djangoapps/commerce/ openedx/core/djangoapps/common_initialization/ openedx/core/djangoapps/common_views/ openedx/core/djangoapps/config_model_utils/ openedx/core/djangoapps/content/ openedx/core/djangoapps/content_libraries/ openedx/core/djangoapps/contentserver/ openedx/core/djangoapps/cookie_metadata/ openedx/core/djangoapps/cors_csrf/ openedx/core/djangoapps/course_apps/ openedx/core/djangoapps/course_date_signals/ openedx/core/djangoapps/course_groups/ openedx/core/djangoapps/courseware_api/ openedx/core/djangoapps/crawlers/ openedx/core/djangoapps/credentials/ openedx/core/djangoapps/credit/ openedx/core/djangoapps/dark_lang/ openedx/core/djangoapps/debug/ openedx/core/djangoapps/demographics/ openedx/core/djangoapps/discussions/ openedx/core/djangoapps/django_comment_common/ openedx/core/djangoapps/embargo/ openedx/core/djangoapps/enrollments/ openedx/core/djangoapps/external_user_ids/ openedx/core/djangoapps/zendesk_proxy/ openedx/core/djangolib/ openedx/core/lib/ openedx/core/tests/ openedx/core/djangoapps/course_live/"
- module-name: openedx-2
path: "openedx/core/djangoapps/geoinfo/ openedx/core/djangoapps/header_control/ openedx/core/djangoapps/heartbeat/ openedx/core/djangoapps/lang_pref/ openedx/core/djangoapps/models/ openedx/core/djangoapps/monkey_patch/ openedx/core/djangoapps/oauth_dispatch/ openedx/core/djangoapps/olx_rest_api/ openedx/core/djangoapps/password_policy/ openedx/core/djangoapps/plugin_api/ openedx/core/djangoapps/plugins/ openedx/core/djangoapps/profile_images/ openedx/core/djangoapps/programs/ openedx/core/djangoapps/safe_sessions/ openedx/core/djangoapps/schedules/ openedx/core/djangoapps/service_status/ openedx/core/djangoapps/session_inactivity_timeout/ openedx/core/djangoapps/signals/ openedx/core/djangoapps/site_configuration/ openedx/core/djangoapps/system_wide_roles/ openedx/core/djangoapps/theming/ openedx/core/djangoapps/user_api/ openedx/core/djangoapps/user_authn/ openedx/core/djangoapps/util/ openedx/core/djangoapps/verified_track_content/ openedx/core/djangoapps/video_config/ openedx/core/djangoapps/video_pipeline/ openedx/core/djangoapps/waffle_utils/ openedx/core/djangoapps/xblock/ openedx/core/djangoapps/xmodule_django/ openedx/core/tests/ openedx/features/ openedx/testing/ openedx/tests/ openedx/core/djangoapps/learner_pathway/"
path: "--django-settings-module=lms.envs.test openedx/core/djangoapps/geoinfo/ openedx/core/djangoapps/header_control/ openedx/core/djangoapps/heartbeat/ openedx/core/djangoapps/lang_pref/ openedx/core/djangoapps/models/ openedx/core/djangoapps/monkey_patch/ openedx/core/djangoapps/oauth_dispatch/ openedx/core/djangoapps/olx_rest_api/ openedx/core/djangoapps/password_policy/ openedx/core/djangoapps/plugin_api/ openedx/core/djangoapps/plugins/ openedx/core/djangoapps/profile_images/ openedx/core/djangoapps/programs/ openedx/core/djangoapps/safe_sessions/ openedx/core/djangoapps/schedules/ openedx/core/djangoapps/service_status/ openedx/core/djangoapps/session_inactivity_timeout/ openedx/core/djangoapps/signals/ openedx/core/djangoapps/site_configuration/ openedx/core/djangoapps/system_wide_roles/ openedx/core/djangoapps/theming/ openedx/core/djangoapps/user_api/ openedx/core/djangoapps/user_authn/ openedx/core/djangoapps/util/ openedx/core/djangoapps/verified_track_content/ openedx/core/djangoapps/video_config/ openedx/core/djangoapps/video_pipeline/ openedx/core/djangoapps/waffle_utils/ openedx/core/djangoapps/xblock/ openedx/core/djangoapps/xmodule_django/ openedx/core/tests/ openedx/features/ openedx/testing/ openedx/tests/ openedx/core/djangoapps/learner_pathway/"
- module-name: common
path: "common"
path: "--django-settings-module=lms.envs.test common"
- module-name: cms
path: "cms"
path: "--django-settings-module=cms.envs.test cms"
- module-name: xmodule
path: "xmodule"

path: "--django-settings-module=lms.envs.test xmodule"

name: pylint ${{ matrix.module-name }}
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def tearDown(self):
Reverse the setup
"""
self.client.logout()
ModuleStoreTestCase.tearDown(self)
ModuleStoreTestCase.tearDown(self) # pylint: disable=non-parent-method-called

def test_rerun(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/tests/test_course_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def tearDown(self):
Reverse the setup
"""
self.client.logout()
ModuleStoreTestCase.tearDown(self)
ModuleStoreTestCase.tearDown(self) # pylint: disable=non-parent-method-called

def test_empty_course_listing(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def tearDown(self):
Reverse the setup
"""
self.client.logout()
ModuleStoreTestCase.tearDown(self)
ModuleStoreTestCase.tearDown(self) # pylint: disable=non-parent-method-called

def test_get_all_users(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,10 +1206,10 @@ def settings_handler(request, course_key_string): # lint-amnesty, pylint: disab
if is_prerequisite_courses_enabled():
courses, in_process_course_actions = get_courses_accessible_to_user(request)
# exclude current course from the list of available courses
courses = (course for course in courses if course.id != course_key)
courses = [course for course in courses if course.id != course_key]
if courses:
courses, __ = _process_courses_list(courses, in_process_course_actions)
settings_context.update({'possible_pre_requisite_courses': list(courses)})
settings_context.update({'possible_pre_requisite_courses': courses})

if credit_eligibility_enabled:
if is_credit_course(course_key):
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def setUp(self):
self.course = None
self.user = UserFactory()

@ddt.data('course_run_1', 'matt''s course', 'matt's run')
@ddt.data('course_run_1', 'matt\'s course', 'matt's run')
def test_send_proctoring_requirements_email(self, course_run_name):
self.course = CourseFactory(
display_name=course_run_name,
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/course_api/blocks/transformers/block_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def transform(self, usage_info, block_structure):

for block_key in block_structure.post_order_traversal():
for block_type in self.block_types_to_count:
descendants_type_count = sum([
descendants_type_count = sum(
block_structure.get_transformer_block_field(child_key, self, block_type, 0)
for child_key in block_structure.get_children(block_key)
])
)
block_structure.set_transformer_block_field(
block_key,
self,
Expand Down
19 changes: 10 additions & 9 deletions lms/djangoapps/course_blocks/transformers/start_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ def transform_block_filters(self, usage_info, block_structure):

now = datetime.now(UTC)

removal_condition = lambda block_key: not check_start_date(
usage_info.user,
block_structure.get_xblock_field(block_key, 'days_early_for_beta'),
self._get_merged_start_date(block_structure, block_key),
usage_info.course_key,
now=now,
)
def _removal_condition(block_key):
return not check_start_date(
usage_info.user,
block_structure.get_xblock_field(block_key, 'days_early_for_beta'),
self._get_merged_start_date(block_structure, block_key),
usage_info.course_key,
now=now
)

if usage_info.include_has_scheduled_content:
self._check_has_scheduled_content(block_structure, removal_condition)
self._check_has_scheduled_content(block_structure, _removal_condition)

return [block_structure.create_removal_filter(removal_condition)]
return [block_structure.create_removal_filter(_removal_condition)]
5 changes: 3 additions & 2 deletions lms/djangoapps/courseware/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,9 @@ def sort_by_announcement(courses):
"""

# Sort courses by how far are they from they start day
key = lambda course: course.sorting_score
courses = sorted(courses, key=key)
def _key(course):
return course.sorting_score
courses = sorted(courses, key=_key)

return courses

Expand Down
7 changes: 5 additions & 2 deletions lms/djangoapps/courseware/tests/test_module_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,8 +2067,11 @@ def test_library_source_information(self, mock_tracker):
"""
original_usage_key = UsageKey.from_string('block-v1:A+B+C+type@problem+block@abcd1234')
original_usage_version = ObjectId()
mock_get_original_usage = lambda _, key: (original_usage_key, original_usage_version)
with patch('xmodule.modulestore.mixed.MixedModuleStore.get_block_original_usage', mock_get_original_usage):

def _mock_get_original_usage(_, __):
return original_usage_key, original_usage_version

with patch('xmodule.modulestore.mixed.MixedModuleStore.get_block_original_usage', _mock_get_original_usage):
module_info = self.handle_callback_and_get_module_info(mock_tracker)
assert 'original_usage_key' in module_info
assert module_info['original_usage_key'] == str(original_usage_key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ def test_tasks_fired(self, estimate_first_attempted, mock_task):
if not estimate_first_attempted:
command.append('--no_estimate_first_attempted')
call_command(*(command + courses))
_kwargs = lambda course_key, offset: {
'course_key': course_key,
'batch_size': 2,
'offset': offset,
'estimate_first_attempted': estimate_first_attempted,
'seq_id': ANY,
}

def _kwargs(course_key, offset):
return {
'course_key': course_key,
'batch_size': 2,
'offset': offset,
'estimate_first_attempted': estimate_first_attempted,
'seq_id': ANY
}

actual = mock_task.apply_async.call_args_list
# Order doesn't matter, but can't use a set because dicts aren't hashable
expected = [
Expand Down
6 changes: 4 additions & 2 deletions lms/djangoapps/instructor/tests/test_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,10 @@ def test_reset_student_attempts(self):
module_state_key=msk,
state=original_state
)
# lambda to reload the module state from the database
module = lambda: StudentModule.objects.get(student=self.user, course_id=self.course_key, module_state_key=msk)

def module():
return StudentModule.objects.get(student=self.user, course_id=self.course_key, module_state_key=msk)

assert json.loads(module().state)['attempts'] == 32
reset_student_attempts(self.course_key, self.user, msk, requesting_user=self.user)
assert json.loads(module().state)['attempts'] == 0
Expand Down
4 changes: 2 additions & 2 deletions openedx/core/djangoapps/content_libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def get_metadata_from_index(queryset, text_search=None):
type=lib.type,
description=metadata[i]['description'],
version=metadata[i]['version'],
allow_public_learning=queryset[i].allow_public_learning,
allow_public_read=queryset[i].allow_public_read,
allow_public_learning=lib.allow_public_learning,
allow_public_read=lib.allow_public_read,
num_blocks=metadata[i].get('num_blocks'),
last_published=metadata[i].get('last_published'),
has_unpublished_changes=metadata[i].get('has_unpublished_changes'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def retrieve_all(cls, params=None):
def _update_from_response(self, response_data):
for k, v in response_data.items():
if k in self.accessible_fields:
self.__setattr__(k, v)
setattr(self, k, v)
else:
log.warning(
"Unexpected field {field_name} in model {model_name}".format(
Expand Down
4 changes: 2 additions & 2 deletions openedx/core/djangoapps/programs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,15 @@ def _available_date_for_program(self, program_data, certificates):
certificate
)
earliest_course_run_date = min(
[date for date in [available_date, earliest_course_run_date] if date]
date for date in [available_date, earliest_course_run_date] if date
)

# If we're missing a cert for a course, the program isn't completed and we should just bail now
if earliest_course_run_date is None:
return None

# Keep the catalog course date if it's the latest one
program_available_date = max([date for date in [earliest_course_run_date, program_available_date] if date])
program_available_date = max(date for date in [earliest_course_run_date, program_available_date] if date)

return program_available_date

Expand Down
4 changes: 2 additions & 2 deletions openedx/core/djangoapps/user_authn/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def get_response(self):
""" Returns a dict representation of the error. """
resp = {'success': False}
for attr in ('value', 'redirect', 'redirect_url', 'error_code', 'context'):
if self.__getattribute__(attr):
resp[attr] = self.__getattribute__(attr)
if getattr(self, attr):
resp[attr] = getattr(self, attr)

return resp

Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangolib/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def start_cache_isolation(cls):

cls.__old_settings.append(copy.deepcopy(settings.CACHES))
override = override_settings(CACHES=cache_settings)
override.__enter__()
override.__enter__() # pylint: disable=unnecessary-dunder-call
cls.__settings_overrides.append(override)

assert settings.CACHES == cache_settings
Expand Down
4 changes: 2 additions & 2 deletions openedx/features/effort_estimation/block_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ def _is_on_mobile(self):

def _gather_child_values(self, block_structure, block_key, field, default=0):
"""Collects and sums all child values for field."""
return sum([
return sum(
block_structure.get_xblock_field(child_key, field, default=default)
for child_key in block_structure.get_children(block_key)
])
)

def _estimate_children_effort(self, _usage_info, block_structure, block_key):
"""Collects time and activity counts for children."""
Expand Down
3 changes: 2 additions & 1 deletion pylint_django_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def open(self):
cms_module = False
lms_module = False
common_module = False
for arg in self.linter.cmdline_parser.largs:
arguments = self.linter.cmdline_parser.parse_args()[1]
for arg in arguments:
if arg.startswith('cms'):
cms_module = True
elif arg.startswith('lms'):
Expand Down
13 changes: 8 additions & 5 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
[MASTER]
ignore = ,.git,.tox,migrations,node_modules,.pycharm_helpers
persistent = yes
load-plugins = edx_lint.pylint,pylint_django_settings,pylint_django,pylint_celery,pylint_pytest
load-plugins = edx_lint.pylint,pylint_django,pylint_celery,pylint_pytest

[MESSAGES CONTROL]
enable =
Expand Down Expand Up @@ -286,7 +286,6 @@ disable =
illegal-waffle-usage,

logging-fstring-interpolation,
native-string,
import-outside-toplevel,
inconsistent-return-statements,
no-else-break,
Expand All @@ -308,8 +307,12 @@ disable =
unused-argument,
unsubscriptable-object,
abstract-method,
wrong-import-order,
no-self-use,
not-callable,
unsupported-binary-operation,
missing-timeout,
c-extension-no-member,
no-name-in-module,
unnecessary-lambda-assignment,

[REPORTS]
output-format = text
Expand Down Expand Up @@ -406,4 +409,4 @@ int-import-graph =
[EXCEPTIONS]
overgeneral-exceptions = Exception

# 976a7bc58c47b2957e91b1632c6ea16e0112bc3b
# 567bf30b121db79bc07a7028651f7efa0724e8a4
Loading

0 comments on commit 4734f9f

Please sign in to comment.