diff --git a/cms/djangoapps/contentstore/management/commands/import_content_library.py b/cms/djangoapps/contentstore/management/commands/import_content_library.py index 56e1eaa2b8fbb76da805fe4d00437c7a016bd912..9d33523cdb5d795e681764b8fd243568f90d173b 100644 --- a/cms/djangoapps/contentstore/management/commands/import_content_library.py +++ b/cms/djangoapps/contentstore/management/commands/import_content_library.py @@ -47,7 +47,7 @@ class Command(BaseCommand): course_dir = data_root / subdir # Extract library archive - tar_file = tarfile.open(archive_path) + tar_file = tarfile.open(archive_path) # lint-amnesty, pylint: disable=consider-using-with try: safetar_extractall(tar_file, course_dir.encode('utf-8')) except SuspiciousOperation as exc: diff --git a/cms/djangoapps/contentstore/tasks.py b/cms/djangoapps/contentstore/tasks.py index 21b8b02f9bc9597fe1176fa99654a8dd072f35ad..c19fd75c3591cca4df20dd18019a0a3fafdcb6c1 100644 --- a/cms/djangoapps/contentstore/tasks.py +++ b/cms/djangoapps/contentstore/tasks.py @@ -336,7 +336,7 @@ def create_export_tarball(course_module, course_key, context, status=None): Updates the context with any error information if applicable. """ name = course_module.url_name - export_file = NamedTemporaryFile(prefix=name + '.', suffix=".tar.gz") + export_file = NamedTemporaryFile(prefix=name + '.', suffix=".tar.gz") # lint-amnesty, pylint: disable=consider-using-with root_dir = path(mkdtemp()) try: @@ -595,7 +595,7 @@ def import_olx(self, user_id, course_key_string, archive_path, archive_name, lan # try-finally block for proper clean up after receiving file. try: - tar_file = tarfile.open(temp_filepath) + tar_file = tarfile.open(temp_filepath) # lint-amnesty, pylint: disable=consider-using-with try: safetar_extractall(tar_file, (course_dir + '/')) except SuspiciousOperation as exc: diff --git a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py index 57dcf3d93ebf82ecc7bcd0ba4401407f4a5672b6..d4d82776326dc02b2f3cb46c1770a6d99417b8e7 100644 --- a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py +++ b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py @@ -812,7 +812,7 @@ class TestGetTranscript(SharedModuleStoreTestCase): """ Create srt file. """ - srt_file = tempfile.NamedTemporaryFile(suffix=".srt") + srt_file = tempfile.NamedTemporaryFile(suffix=".srt") # lint-amnesty, pylint: disable=consider-using-with srt_file.content_type = transcripts_utils.Transcript.SRT srt_file.write(content) srt_file.seek(0) diff --git a/cms/djangoapps/contentstore/views/tests/test_import_export.py b/cms/djangoapps/contentstore/views/tests/test_import_export.py index aec9190c8282c65902ea21a7a51f8b3b9d67d291..ed1df9665c72d55eb05778c2349f2834276c4dec 100644 --- a/cms/djangoapps/contentstore/views/tests/test_import_export.py +++ b/cms/djangoapps/contentstore/views/tests/test_import_export.py @@ -720,7 +720,7 @@ class ExportTestCase(CourseTestCase): resp_content += item buff = BytesIO(resp_content) - return tarfile.open(fileobj=buff) + return tarfile.open(fileobj=buff) # lint-amnesty, pylint: disable=consider-using-with def _verify_export_succeeded(self, resp): """ Export success helper method. """ diff --git a/cms/djangoapps/contentstore/views/tests/test_transcripts.py b/cms/djangoapps/contentstore/views/tests/test_transcripts.py index dd99f170f1d0a941c50fa90a755c1a76aba46029..644dcc7250f66e4d214f4c689928ef5a455c1f3e 100644 --- a/cms/djangoapps/contentstore/views/tests/test_transcripts.py +++ b/cms/djangoapps/contentstore/views/tests/test_transcripts.py @@ -183,7 +183,7 @@ class TestUploadTranscripts(BaseTranscripts): """ Setup a transcript file with suffix and content. """ - transcript_file = tempfile.NamedTemporaryFile(suffix=suffix) + transcript_file = tempfile.NamedTemporaryFile(suffix=suffix) # lint-amnesty, pylint: disable=consider-using-with wrapped_content = textwrap.dedent(content) if include_bom: wrapped_content = wrapped_content.encode('utf-8-sig') diff --git a/common/djangoapps/edxmako/shortcuts.py b/common/djangoapps/edxmako/shortcuts.py index 012db3f6535c01af222fdfa690a8545a7ce8bbe1..2a9d8849cb3630622dde569bd56e2643485183fb 100644 --- a/common/djangoapps/edxmako/shortcuts.py +++ b/common/djangoapps/edxmako/shortcuts.py @@ -15,7 +15,6 @@ import logging -import six from django.conf import settings from django.http import HttpResponse # lint-amnesty, pylint: disable=unused-import from django.template import engines diff --git a/common/djangoapps/student/management/commands/assigngroups.py b/common/djangoapps/student/management/commands/assigngroups.py index 77b76a1f93fe52232ec916c0d57bd7bf9c3ec24c..52833974569ed76c2a4d4b33ab0ab77b5831fb20 100644 --- a/common/djangoapps/student/management/commands/assigngroups.py +++ b/common/djangoapps/student/management/commands/assigngroups.py @@ -68,7 +68,7 @@ class Command(BaseCommand): # lint-amnesty, pylint: disable=missing-class-docst group_objects = {} - f = open(options['log_name'], "a+") + f = open(options['log_name'], "a+") # lint-amnesty, pylint: disable=consider-using-with # Create groups for group in dict(groups): diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index fa5d7fc47a6e8370b2f6e241d3b317b22e185b48..b0546f14caced7d7ca214c0a209817c10cdba4db 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -3218,8 +3218,7 @@ class UserCelebration(TimeStampedModel): if last_day_of_streak != self.last_day_of_streak: self.last_day_of_streak = last_day_of_streak self.streak_length = streak_length - if self.longest_ever_streak < streak_length: - self.longest_ever_streak = streak_length + self.longest_ever_streak = max(self.longest_ever_streak, streak_length) self.save() diff --git a/common/djangoapps/terrain/stubs/tests/test_lti_stub.py b/common/djangoapps/terrain/stubs/tests/test_lti_stub.py index bf8e4d8c6a3150827baf902af2dec80c394d33de..1d04f47cd9df7298f4728952ed9c26bf9f777b49 100644 --- a/common/djangoapps/terrain/stubs/tests/test_lti_stub.py +++ b/common/djangoapps/terrain/stubs/tests/test_lti_stub.py @@ -74,7 +74,7 @@ class StubLtiServiceTest(unittest.TestCase): grade_uri = self.uri + 'grade' with patch('common.djangoapps.terrain.stubs.lti.requests.post') as mocked_post: mocked_post.return_value = Mock(content='Test response', status_code=200) - response = urlopen(grade_uri, data=b'') + response = urlopen(grade_uri, data=b'') # lint-amnesty, pylint: disable=consider-using-with assert b'Test response' in response.read() @patch('common.djangoapps.terrain.stubs.lti.signature.verify_hmac_sha1', return_value=True) @@ -84,7 +84,7 @@ class StubLtiServiceTest(unittest.TestCase): grade_uri = self.uri + 'lti2_outcome' with patch('common.djangoapps.terrain.stubs.lti.requests.put') as mocked_put: mocked_put.return_value = Mock(status_code=200) - response = urlopen(grade_uri, data=b'') + response = urlopen(grade_uri, data=b'') # lint-amnesty, pylint: disable=consider-using-with assert b'LTI consumer (edX) responded with HTTP 200' in response.read() @patch('common.djangoapps.terrain.stubs.lti.signature.verify_hmac_sha1', return_value=True) @@ -94,5 +94,5 @@ class StubLtiServiceTest(unittest.TestCase): grade_uri = self.uri + 'lti2_delete' with patch('common.djangoapps.terrain.stubs.lti.requests.put') as mocked_put: mocked_put.return_value = Mock(status_code=200) - response = urlopen(grade_uri, data=b'') + response = urlopen(grade_uri, data=b'') # lint-amnesty, pylint: disable=consider-using-with assert b'LTI consumer (edX) responded with HTTP 200' in response.read() diff --git a/common/djangoapps/track/contexts.py b/common/djangoapps/track/contexts.py index c4b09ebf93ec557f62ddd821ef7439e87b7b0283..6d4e9da3caf8272e6dead2b504a863c50a3cb6e0 100644 --- a/common/djangoapps/track/contexts.py +++ b/common/djangoapps/track/contexts.py @@ -5,7 +5,7 @@ import logging from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey, LearningContextKey -from six import text_type +from six import text_type # lint-amnesty, pylint: disable=unused-import from openedx.core.lib.request_utils import COURSE_REGEX diff --git a/common/djangoapps/track/middleware.py b/common/djangoapps/track/middleware.py index 01b1b0a771fe0f3efafffee5c983439f41fa9c1b..e3c384632a160b345ee4e53cff7be34e8d8fe032 100644 --- a/common/djangoapps/track/middleware.py +++ b/common/djangoapps/track/middleware.py @@ -12,7 +12,7 @@ import logging import re import sys -import six +import six # lint-amnesty, pylint: disable=unused-import from django.conf import settings from django.utils.deprecation import MiddlewareMixin from eventtracking import tracker diff --git a/common/djangoapps/track/tracker.py b/common/djangoapps/track/tracker.py index 9f8c7f00fc04061f4956930737f22e37ea821940..53ae9f238746d99e37012e3faec2e73e2c6e18fb 100644 --- a/common/djangoapps/track/tracker.py +++ b/common/djangoapps/track/tracker.py @@ -24,7 +24,7 @@ import inspect import warnings from importlib import import_module -import six +import six # lint-amnesty, pylint: disable=unused-import from django.conf import settings from common.djangoapps.track.backends import BaseBackend diff --git a/common/djangoapps/track/transformers.py b/common/djangoapps/track/transformers.py index 595b5028cc74a53ad3fdb85dd0a8660bc1c9f365..aa4a3d17a655db3b3882be59718de3ad3efaa9c3 100644 --- a/common/djangoapps/track/transformers.py +++ b/common/djangoapps/track/transformers.py @@ -9,7 +9,7 @@ apply them to the appropriate events. import json import logging -import six +import six # lint-amnesty, pylint: disable=unused-import from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import UsageKey diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 085c6f13cbac33aad5baaeb4f317372ca2b08ee3..107311800d4848158fe30cbf9ac4b7f0677f8bdb 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -2777,7 +2777,7 @@ class CodeResponse(LoncapaResponse): # matches if oldcmap.is_right_queuekey(self.answer_id, queuekey): # Sanity check on returned points - if points < 0: + if points < 0: # lint-amnesty, pylint: disable=consider-using-max-builtin points = 0 # Queuestate is consumed oldcmap.set( diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index bf1f9dcf31bd0dae8d6c63ac012a51dc76cad407..6ed360f8a22d262ebe27843a37ab2c144ca04344 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -2304,7 +2304,7 @@ class CustomResponseTest(ResponseTest): # pylint: disable=missing-class-docstri # Make a zipfile with one module in it with one function. zipstring = io.BytesIO() - zipf = zipfile.ZipFile(zipstring, "w") + zipf = zipfile.ZipFile(zipstring, "w") # lint-amnesty, pylint: disable=consider-using-with zipf.writestr("my_helper.py", textwrap.dedent("""\ def seventeen(): return 17 diff --git a/common/lib/symmath/symmath/formula.py b/common/lib/symmath/symmath/formula.py index 126be0b6257d3a9cacbd6165596d4fe39defb718..715e981218f2e479998201545c45dbc18b2fd10b 100644 --- a/common/lib/symmath/symmath/formula.py +++ b/common/lib/symmath/symmath/formula.py @@ -21,7 +21,7 @@ import unicodedata from copy import deepcopy from functools import reduce -import six +import six # lint-amnesty, pylint: disable=unused-import import sympy from lxml import etree from sympy import latex, sympify diff --git a/common/lib/xmodule/xmodule/modulestore/search.py b/common/lib/xmodule/xmodule/modulestore/search.py index d1e7762a6714d439f232f8455ef36bb8a606ba89..674a5a3169c2d9bbc8bac55cd459f4b9bf535586 100644 --- a/common/lib/xmodule/xmodule/modulestore/search.py +++ b/common/lib/xmodule/xmodule/modulestore/search.py @@ -6,7 +6,7 @@ from logging import getLogger from lms.djangoapps.courseware.access import has_access from lms.djangoapps.courseware.masquerade import MASQUERADE_SETTINGS_KEY -from common.djangoapps.student.roles import GlobalStaff +from common.djangoapps.student.roles import GlobalStaff # lint-amnesty, pylint: disable=unused-import from .exceptions import ItemNotFoundError, NoPathToItem LOGGER = getLogger(__name__) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/factories.py b/common/lib/xmodule/xmodule/modulestore/tests/factories.py index 5aa7e067450e9c8dd42cab4e0c55cf213dcea976..514abbced870fd846e76fcea41e9262cc6358aef 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/factories.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/factories.py @@ -324,7 +324,7 @@ class ItemFactory(XModuleFactory): return parent.location @classmethod - def _create(cls, target_class, **kwargs): # lint-amnesty, pylint: disable=arguments-differ, unused-argument + def _create(cls, target_class, **kwargs): # lint-amnesty, pylint: disable=arguments-differ, too-many-statements, unused-argument """ Uses ``**kwargs``: diff --git a/common/lib/xmodule/xmodule/progress.py b/common/lib/xmodule/xmodule/progress.py index 4c8c1bbcc9ae1b4a30037aa141a575da1e149eab..deaddd282b6296cb831fbd96b2f5cd1d99aee7ae 100644 --- a/common/lib/xmodule/xmodule/progress.py +++ b/common/lib/xmodule/xmodule/progress.py @@ -31,10 +31,10 @@ class Progress: # pylint: disable=eq-without-hash isinstance(b, numbers.Number)): raise TypeError(f'a and b must be numbers. Passed {a}/{b}') - if a > b: + if a > b: # lint-amnesty, pylint: disable=consider-using-min-builtin a = b - if a < 0: + if a < 0: # lint-amnesty, pylint: disable=consider-using-max-builtin a = 0 if b <= 0: diff --git a/common/test/acceptance/fixtures/course.py b/common/test/acceptance/fixtures/course.py index 23296c46f3e43afe2ffebe62e2e72798127cc452..2e43ff1a3835948a89121d3e63c1d9fc7e4f934e 100644 --- a/common/test/acceptance/fixtures/course.py +++ b/common/test/acceptance/fixtures/course.py @@ -396,7 +396,7 @@ class CourseFixture(XBlockContainerFixture): for asset_name in self._assets: asset_file_path = test_dir + '/data/uploads/' + asset_name - asset_file = open(asset_file_path, mode='rb') # lint-amnesty, pylint: disable=bad-option-value, open-builtin + asset_file = open(asset_file_path, mode='rb') # lint-amnesty, pylint: disable=consider-using-with files = {'file': (asset_name, asset_file, mimetypes.guess_type(asset_file_path)[0])} headers = { diff --git a/lms/djangoapps/commerce/api/v0/tests/test_views.py b/lms/djangoapps/commerce/api/v0/tests/test_views.py index dfcadd03b33fd86698d5a13208594d7ff6045022..5a1e47cb7149aa90340075ae66457392dab67365 100644 --- a/lms/djangoapps/commerce/api/v0/tests/test_views.py +++ b/lms/djangoapps/commerce/api/v0/tests/test_views.py @@ -17,7 +17,7 @@ from django.urls import reverse, reverse_lazy from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.tests.factories import CourseModeFactory from common.djangoapps.student.models import CourseEnrollment -from common.djangoapps.student.tests.tests import EnrollmentEventTestMixin +from common.djangoapps.student.tests.tests import EnrollmentEventTestMixin # lint-amnesty, pylint: disable=unused-import from openedx.core.djangoapps.embargo.test_utils import restrict_course from openedx.core.djangoapps.enrollments.api import get_enrollment from openedx.core.lib.django_test_client_utils import get_absolute_url diff --git a/lms/djangoapps/commerce/api/v0/views.py b/lms/djangoapps/commerce/api/v0/views.py index a8fd9313de3c4426ecebae4969ad13c54dba4511..26dafe0343ece553236ad1878bd1c756bc0ad0a3 100644 --- a/lms/djangoapps/commerce/api/v0/views.py +++ b/lms/djangoapps/commerce/api/v0/views.py @@ -150,7 +150,7 @@ class BasketsView(APIView): ) log.info(msg) self._enroll(course_key, user, default_enrollment_mode.slug) - mode = CourseMode.AUDIT if audit_mode else CourseMode.HONOR + mode = CourseMode.AUDIT if audit_mode else CourseMode.HONOR # lint-amnesty, pylint: disable=unused-variable self._handle_marketing_opt_in(request, course_key, user) return DetailResponse(msg) else: diff --git a/lms/djangoapps/course_home_api/course_metadata/v1/views.py b/lms/djangoapps/course_home_api/course_metadata/v1/views.py index 78a323d810fcc821b50c33c5e3f02b4e80904765..4417f3d44ae40e888c11f9353d744513fba373aa 100644 --- a/lms/djangoapps/course_home_api/course_metadata/v1/views.py +++ b/lms/djangoapps/course_home_api/course_metadata/v1/views.py @@ -14,7 +14,7 @@ from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiv from openedx.core.djangoapps.courseware_api.utils import get_celebrations_dict from openedx.core.djangoapps.courseware_api.views import CoursewareMeta -from common.djangoapps.student.models import CourseEnrollment, UserCelebration +from common.djangoapps.student.models import CourseEnrollment, UserCelebration # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.course_api.api import course_detail from lms.djangoapps.course_home_api.course_metadata.v1.serializers import CourseHomeMetadataSerializer from lms.djangoapps.courseware.access import has_access diff --git a/lms/djangoapps/courseware/tests/test_video_handlers.py b/lms/djangoapps/courseware/tests/test_video_handlers.py index 9f944f0a3a037dd5bcb99c96508da2b6460f5a89..0d266f5e8f6c5a6e6ff3087e2507717ba2fe12b9 100644 --- a/lms/djangoapps/courseware/tests/test_video_handlers.py +++ b/lms/djangoapps/courseware/tests/test_video_handlers.py @@ -49,7 +49,7 @@ def _create_srt_file(content=None): """ content = content or SRT_content - srt_file = tempfile.NamedTemporaryFile(suffix=".srt") + srt_file = tempfile.NamedTemporaryFile(suffix=".srt") # lint-amnesty, pylint: disable=consider-using-with srt_file.content_type = 'application/x-subrip; charset=utf-8' srt_file.write(content.encode('utf-8')) srt_file.seek(0) @@ -93,7 +93,7 @@ def _create_file(content=''): """ Create temporary subs_somevalue.srt.sjson file. """ - sjson_file = tempfile.NamedTemporaryFile(prefix="subs_", suffix=".srt.sjson") + sjson_file = tempfile.NamedTemporaryFile(prefix="subs_", suffix=".srt.sjson") # lint-amnesty, pylint: disable=consider-using-with sjson_file.content_type = 'application/json' sjson_file.write(textwrap.dedent(content).encode('utf-8')) sjson_file.seek(0) diff --git a/lms/djangoapps/discussion/rest_api/views.py b/lms/djangoapps/discussion/rest_api/views.py index b18ddbb7c12e13e86032916fe80359004d10bbdd..418df91bf1d27389520949aff59d5addf24d6443 100644 --- a/lms/djangoapps/discussion/rest_api/views.py +++ b/lms/djangoapps/discussion/rest_api/views.py @@ -16,7 +16,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from rest_framework.viewsets import ViewSet -from lms.djangoapps.discussion.django_comment_client.utils import available_division_schemes +from lms.djangoapps.discussion.django_comment_client.utils import available_division_schemes # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.discussion.rest_api.api import ( create_comment, create_thread, @@ -43,7 +43,7 @@ from lms.djangoapps.discussion.rest_api.serializers import ( DiscussionRolesSerializer, DiscussionSettingsSerializer ) -from lms.djangoapps.discussion.views import get_divided_discussions +from lms.djangoapps.discussion.views import get_divided_discussions # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.instructor.access import update_forum_role from openedx.core.djangoapps.django_comment_common import comment_client from openedx.core.djangoapps.django_comment_common.models import Role diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py b/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py index 0bc48d31a7933f683ae6467946092e28004d9da9..b0141f14aef3cf95551d508108428694cf61f732 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py @@ -1043,7 +1043,7 @@ class GradebookViewTest(GradebookViewTestBase): assert status.HTTP_200_OK == resp.status_code actual_data = dict(resp.data) expected_page_size = page_size or CourseEnrollmentPagination.page_size - if expected_page_size > user_size: + if expected_page_size > user_size: # lint-amnesty, pylint: disable=consider-using-min-builtin expected_page_size = user_size assert len(actual_data['results']) == expected_page_size diff --git a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py index 742a8461dadd9be723fcafebeb03671903a0630b..ce8cfabc3b53ff7a3579c7c741184eaab71f6d95 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py @@ -1423,7 +1423,7 @@ class MockDefaultStorage: def open(self, file_name): """Mock out DefaultStorage.open with standard python open""" - return open(file_name) # lint-amnesty, pylint: disable=bad-option-value, open-builtin + return open(file_name) # lint-amnesty, pylint: disable=bad-option-value, open-builtin # lint-amnesty, pylint: disable=consider-using-with @patch('lms.djangoapps.instructor_task.tasks_helper.misc.DefaultStorage', new=MockDefaultStorage) diff --git a/openedx/core/djangoapps/courseware_api/views.py b/openedx/core/djangoapps/courseware_api/views.py index d29f2c99033a11c1117ee9560ccf1161325ad152..01052b9edea0040d60cbc67c0bc5d090cc2057bc 100644 --- a/openedx/core/djangoapps/courseware_api/views.py +++ b/openedx/core/djangoapps/courseware_api/views.py @@ -2,7 +2,7 @@ Course API Views """ -import json +import json # lint-amnesty, pylint: disable=unused-import from completion.exceptions import UnavailableCompletionData from completion.utilities import get_key_to_last_completed_block diff --git a/openedx/core/djangoapps/credentials/management/commands/notify_credentials.py b/openedx/core/djangoapps/credentials/management/commands/notify_credentials.py index 840403420df4d4aff9315749e157851f18bfe485..92472b92887a61231a0b407083b67c1974696738 100644 --- a/openedx/core/djangoapps/credentials/management/commands/notify_credentials.py +++ b/openedx/core/djangoapps/credentials/management/commands/notify_credentials.py @@ -13,7 +13,7 @@ signals.) import logging import shlex -import sys +import sys # lint-amnesty, pylint: disable=unused-import from datetime import datetime, timedelta import dateutil.parser diff --git a/openedx/core/djangoapps/credentials/management/commands/tests/test_notify_credentials.py b/openedx/core/djangoapps/credentials/management/commands/tests/test_notify_credentials.py index be70f413f8e0de07ec44a70dd854904a63d93bcf..059c7819754308a0e395192ec8185c4bdcb9a50e 100644 --- a/openedx/core/djangoapps/credentials/management/commands/tests/test_notify_credentials.py +++ b/openedx/core/djangoapps/credentials/management/commands/tests/test_notify_credentials.py @@ -8,7 +8,7 @@ from unittest import mock from django.core.management import call_command from django.core.management.base import CommandError -from django.test import TestCase, override_settings +from django.test import TestCase, override_settings # lint-amnesty, pylint: disable=unused-import from freezegun import freeze_time from openedx.core.djangoapps.catalog.tests.factories import ProgramFactory, CourseFactory, CourseRunFactory diff --git a/openedx/core/djangoapps/credentials/tests/test_signals.py b/openedx/core/djangoapps/credentials/tests/test_signals.py index c73625803d60137f0408b3d8f0bda97017655da1..5ea44fafa003c7cbf55a4e43dd2fc35c7fb6f213 100644 --- a/openedx/core/djangoapps/credentials/tests/test_signals.py +++ b/openedx/core/djangoapps/credentials/tests/test_signals.py @@ -3,8 +3,8 @@ from unittest import mock -from django.conf import settings -from django.test import TestCase, override_settings +from django.conf import settings # lint-amnesty, pylint: disable=unused-import +from django.test import TestCase, override_settings # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory diff --git a/openedx/core/djangoapps/discussions/views.py b/openedx/core/djangoapps/discussions/views.py index a3ff3a374f2f52b6e83c445dcdca31cac8343e49..18a7ae9a1ea488d7e444ac44574b2ad8a9b7c9f7 100644 --- a/openedx/core/djangoapps/discussions/views.py +++ b/openedx/core/djangoapps/discussions/views.py @@ -126,7 +126,7 @@ class LegacySettingsSerializer(serializers.BaseSerializer): raise serializers.ValidationError('Wrong type for discussion_topics') payload = { key: value - for key, value in data.items() + for key, value in data.items() # lint-amnesty, pylint: disable=unnecessary-comprehension } return payload diff --git a/openedx/core/djangoapps/profile_images/tests/helpers.py b/openedx/core/djangoapps/profile_images/tests/helpers.py index 3170b58234f4d6a1ccf6acd69b25ba84fc36796b..cbb6e76ac95753ea5837fe1616d5ce775a3b46f9 100644 --- a/openedx/core/djangoapps/profile_images/tests/helpers.py +++ b/openedx/core/djangoapps/profile_images/tests/helpers.py @@ -28,7 +28,7 @@ def make_image_file(dimensions=(320, 240), prefix='tmp', extension='.jpeg', forc """ image = Image.new('RGB', dimensions, "green") - image_file = NamedTemporaryFile(prefix=prefix, suffix=extension) + image_file = NamedTemporaryFile(prefix=prefix, suffix=extension) # lint-amnesty, pylint: disable=consider-using-with try: if orientation and orientation in range(1, 9): exif_bytes = piexif.dump({'0th': {piexif.ImageIFD.Orientation: orientation}}) diff --git a/openedx/core/djangoapps/programs/tests/test_utils.py b/openedx/core/djangoapps/programs/tests/test_utils.py index 68db25827bff06ee9e83d80c8e28ab6dfb20fee8..b61fdfe5ea05884b32acc0f937c59a12a5de9d3b 100644 --- a/openedx/core/djangoapps/programs/tests/test_utils.py +++ b/openedx/core/djangoapps/programs/tests/test_utils.py @@ -475,7 +475,7 @@ class TestProgramProgressMeter(ModuleStoreTestCase): programs = data[:3] assert meter.engaged_programs == programs - def test_simulate_progress(self, mock_get_programs): + def test_simulate_progress(self, mock_get_programs): # lint-amnesty, pylint: disable=too-many-statements """Simulate the entirety of a user's progress through a program.""" today = datetime.datetime.now(utc) two_days_ago = today - datetime.timedelta(days=2) diff --git a/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py b/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py index e167fb5a466692c10741bb3be170d53480677e92..0a1a5121ae58fd41b0990318d6a941222eb1394c 100644 --- a/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py +++ b/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py @@ -274,7 +274,7 @@ class EmailOptInListTest(ModuleStoreTestCase): call_command('email_opt_in_list', *args) def test_file_already_exists(self): - temp_file = tempfile.NamedTemporaryFile(delete=True) + temp_file = tempfile.NamedTemporaryFile(delete=True) # lint-amnesty, pylint: disable=consider-using-with def _cleanup(): temp_file.close() diff --git a/openedx/core/djangoapps/user_authn/utils.py b/openedx/core/djangoapps/user_authn/utils.py index e6635a23cabad0fd84632eef34ab4338a9a34dab..8947cd9d98fe0373f9ee9d8e911167c4a5afb243 100644 --- a/openedx/core/djangoapps/user_authn/utils.py +++ b/openedx/core/djangoapps/user_authn/utils.py @@ -5,7 +5,7 @@ Utility functions used during user authentication. import random import string from urllib.parse import urlparse # pylint: disable=import-error -from uuid import uuid4 +from uuid import uuid4 # lint-amnesty, pylint: disable=unused-import from django.conf import settings from django.utils import http diff --git a/openedx/core/djangoapps/user_authn/views/login.py b/openedx/core/djangoapps/user_authn/views/login.py index 58c349bfacbf4718677839a0a1136a2c53913aa2..0900d5c28ec5f3c143183397490d5b9957e0ce62 100644 --- a/openedx/core/djangoapps/user_authn/views/login.py +++ b/openedx/core/djangoapps/user_authn/views/login.py @@ -44,7 +44,7 @@ from openedx.core.djangoapps.user_authn.views.utils import ( from openedx.core.djangoapps.user_authn.toggles import is_require_third_party_auth_enabled from openedx.core.djangoapps.user_authn.config.waffle import ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY from openedx.core.djangolib.markup import HTML, Text -from openedx.core.lib.api.view_utils import require_post_params +from openedx.core.lib.api.view_utils import require_post_params # lint-amnesty, pylint: disable=unused-import from openedx.features.enterprise_support.api import activate_learner_enterprise, get_enterprise_learner_data_from_api from common.djangoapps.student.helpers import get_next_url_for_login_page, get_redirect_url_with_host from common.djangoapps.student.models import LoginFailures, AllowedAuthUser, UserProfile diff --git a/openedx/core/lib/html_to_text.py b/openedx/core/lib/html_to_text.py index a6d2daddf788e56b504f7753746f505f23cb21ee..fdb851840caef1fb126e47d0cd7c8f04a8e867e4 100644 --- a/openedx/core/lib/html_to_text.py +++ b/openedx/core/lib/html_to_text.py @@ -12,7 +12,7 @@ def html_to_text(html_message): Currently uses lynx in a subprocess; should be refactored to use something more pythonic. """ - process = Popen( + process = Popen( # lint-amnesty, pylint: disable=consider-using-with ['lynx', '-stdin', '-display_charset=UTF-8', '-assume_charset=UTF-8', '-dump'], stdin=PIPE, stdout=PIPE diff --git a/openedx/core/process_warnings.py b/openedx/core/process_warnings.py index 331816d196e2f52fd8dfba49bb0fabf67da36cb9..6141fc874dcbe45edef7799036c36afd725eb18a 100644 --- a/openedx/core/process_warnings.py +++ b/openedx/core/process_warnings.py @@ -4,7 +4,7 @@ Script to process pytest warnings output by pytest-json-report plugin and output """ import argparse -import io +import io # lint-amnesty, pylint: disable=unused-import import itertools import json import os diff --git a/openedx/core/pytest_hooks.py b/openedx/core/pytest_hooks.py index 1552b394961cec94e0d68ad567585e5d3e32b269..49911c92f87ee723e55ad26a8714c1e88f073cae 100644 --- a/openedx/core/pytest_hooks.py +++ b/openedx/core/pytest_hooks.py @@ -2,7 +2,7 @@ Module to put all pytest hooks that modify pytest behaviour """ import os -import io +import io # lint-amnesty, pylint: disable=unused-import import json diff --git a/openedx/core/write_to_html.py b/openedx/core/write_to_html.py index aa35b8a575a6f7ae0f570971bd71833ba61bfd98..8c211e113825e907ab962d21c54818bac37e31c8 100644 --- a/openedx/core/write_to_html.py +++ b/openedx/core/write_to_html.py @@ -2,7 +2,7 @@ Class used to write pytest warning data into html format """ import textwrap -import six +import six # lint-amnesty, pylint: disable=unused-import class HtmlOutlineWriter: diff --git a/openedx/features/course_experience/tests/views/test_course_dates.py b/openedx/features/course_experience/tests/views/test_course_dates.py index 19d5ef8f0aade90bf6f7f96631cf53e59a6a5f50..af7867741c461a0fe5c02af7b1d459459ea40f0c 100644 --- a/openedx/features/course_experience/tests/views/test_course_dates.py +++ b/openedx/features/course_experience/tests/views/test_course_dates.py @@ -5,7 +5,7 @@ Tests for course dates fragment. from datetime import datetime, timedelta -import six +import six # lint-amnesty, pylint: disable=unused-import from django.urls import reverse from common.djangoapps.student.tests.factories import UserFactory diff --git a/openedx/features/course_experience/url_helpers.py b/openedx/features/course_experience/url_helpers.py index 122e9ab7f59dd5a4335dedb8571cb06501052eae..c0ab5f62624061673146c4436bf0ad343891cee0 100644 --- a/openedx/features/course_experience/url_helpers.py +++ b/openedx/features/course_experience/url_helpers.py @@ -7,7 +7,7 @@ because the Studio course outline may need these utilities. from enum import Enum from typing import Optional -import six +import six # lint-amnesty, pylint: disable=unused-import from django.conf import settings from django.contrib.auth import get_user_model from django.http import HttpRequest diff --git a/openedx/features/course_experience/views/course_home.py b/openedx/features/course_experience/views/course_home.py index 89f12028eaf9e144c6c7ce41eb02445b57080fdb..3718c4e8b4e88b4f2894d4e86759a452405ef55c 100644 --- a/openedx/features/course_experience/views/course_home.py +++ b/openedx/features/course_experience/views/course_home.py @@ -3,7 +3,7 @@ Views for the course home page. """ -import six +import six # lint-amnesty, pylint: disable=unused-import from django.conf import settings from django.template.context_processors import csrf from django.template.loader import render_to_string diff --git a/openedx/features/course_experience/views/course_updates.py b/openedx/features/course_experience/views/course_updates.py index 5f76b592ee29e5038fb319d3041c3ece6b42e6fc..f3ee5de4ad98e9d40da8689cf549489336bccae1 100644 --- a/openedx/features/course_experience/views/course_updates.py +++ b/openedx/features/course_experience/views/course_updates.py @@ -2,7 +2,7 @@ Views that handle course updates. """ -import six +import six # lint-amnesty, pylint: disable=unused-import from django.contrib.auth.decorators import login_required from django.template.context_processors import csrf from django.template.loader import render_to_string diff --git a/openedx/features/course_experience/views/welcome_message.py b/openedx/features/course_experience/views/welcome_message.py index 19f64a68b9712154723d718570384fa056feb63c..410d3425a3e90b1d83e201afdf1a9ab1b33470c6 100644 --- a/openedx/features/course_experience/views/welcome_message.py +++ b/openedx/features/course_experience/views/welcome_message.py @@ -3,7 +3,7 @@ View logic for handling course welcome messages. """ -import six +import six # lint-amnesty, pylint: disable=unused-import from django.http import HttpResponse from django.template.loader import render_to_string from django.urls import reverse diff --git a/openedx/features/enterprise_support/signals.py b/openedx/features/enterprise_support/signals.py index 316df2702b4a89b6789d145792ce23962c0aa7a9..84d321c98519b117e43810732c2bfda06dcebb6f 100644 --- a/openedx/features/enterprise_support/signals.py +++ b/openedx/features/enterprise_support/signals.py @@ -9,7 +9,7 @@ from django.conf import settings from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db.models.signals import post_save, pre_save from django.dispatch import receiver -from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomer, EnterpriseCustomerUser +from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomer, EnterpriseCustomerUser # lint-amnesty, pylint: disable=unused-import from integrated_channels.integrated_channel.tasks import ( transmit_single_learner_data, transmit_single_subsection_learner_data diff --git a/pavelib/paver_tests/test_paver_quality.py b/pavelib/paver_tests/test_paver_quality.py index 5842c9dc0b7766182208d13dbc69c86c580bbb8f..62ba7580624bad0635acb3a476fc50dc563a7f39 100644 --- a/pavelib/paver_tests/test_paver_quality.py +++ b/pavelib/paver_tests/test_paver_quality.py @@ -28,7 +28,7 @@ class TestPaverQualityViolations(unittest.TestCase): """ def setUp(self): super().setUp() - self.f = tempfile.NamedTemporaryFile(delete=False) + self.f = tempfile.NamedTemporaryFile(delete=False) # lint-amnesty, pylint: disable=consider-using-with self.f.close() self.addCleanup(os.remove, self.f.name) @@ -102,7 +102,7 @@ class TestPaverReportViolationsCounts(unittest.TestCase): super().setUp() # Temporary file infrastructure - self.f = tempfile.NamedTemporaryFile(delete=False) + self.f = tempfile.NamedTemporaryFile(delete=False) # lint-amnesty, pylint: disable=consider-using-with self.f.close() # Cleanup various mocks and tempfiles @@ -241,7 +241,7 @@ class TestPrepareReportDir(unittest.TestCase): def setUp(self): super().setUp() self.test_dir = tempfile.mkdtemp() - self.test_file = tempfile.NamedTemporaryFile(delete=False, dir=self.test_dir) + self.test_file = tempfile.NamedTemporaryFile(delete=False, dir=self.test_dir) # lint-amnesty, pylint: disable=consider-using-with self.addCleanup(os.removedirs, self.test_dir) def test_report_dir_with_files(self): diff --git a/pavelib/prereqs.py b/pavelib/prereqs.py index 9e7e8dcc34bd3c23bce34e6f7c63281c67afb294..d56825cd990fa1f4740337dc8de6c3051086c655 100644 --- a/pavelib/prereqs.py +++ b/pavelib/prereqs.py @@ -135,20 +135,20 @@ def node_prereqs_installation(): npm_log_file_path = f'{Env.GEN_LOG_DIR}/npm-install.{shard_str}.log' else: npm_log_file_path = f'{Env.GEN_LOG_DIR}/npm-install.log' - npm_log_file = open(npm_log_file_path, 'wb') + npm_log_file = open(npm_log_file_path, 'wb') # lint-amnesty, pylint: disable=consider-using-with npm_command = 'npm install --verbose'.split() # The implementation of Paver's `sh` function returns before the forked # actually returns. Using a Popen object so that we can ensure that # the forked process has returned - proc = subprocess.Popen(npm_command, stderr=npm_log_file) + proc = subprocess.Popen(npm_command, stderr=npm_log_file) # lint-amnesty, pylint: disable=consider-using-with retcode = proc.wait() if retcode == 1: # Error handling around a race condition that produces "cb() never called" error. This # evinces itself as `cb_error_text` and it ought to disappear when we upgrade # npm to 3 or higher. TODO: clean this up when we do that. print("npm install error detected. Retrying...") - proc = subprocess.Popen(npm_command, stderr=npm_log_file) + proc = subprocess.Popen(npm_command, stderr=npm_log_file) # lint-amnesty, pylint: disable=consider-using-with retcode = proc.wait() if retcode == 1: raise Exception(f"npm install failed: See {npm_log_file_path}") diff --git a/pavelib/utils/process.py b/pavelib/utils/process.py index fd2ee5bfcf1977bc536b5755635d16b611f86684..813c1b2c7c7a750b6113c634bff18ef7e8b81a37 100644 --- a/pavelib/utils/process.py +++ b/pavelib/utils/process.py @@ -36,11 +36,11 @@ def run_multi_processes(cmd_list, out_log=None, err_log=None): pids = [] if out_log: - out_log_file = open(out_log, 'w') + out_log_file = open(out_log, 'w') # lint-amnesty, pylint: disable=consider-using-with kwargs['stdout'] = out_log_file if err_log: - err_log_file = open(err_log, 'w') + err_log_file = open(err_log, 'w') # lint-amnesty, pylint: disable=consider-using-with kwargs['stderr'] = err_log_file # If the user is performing a dry run of a task, then just log @@ -93,14 +93,14 @@ def run_background_process(cmd, out_log=None, err_log=None, cwd=None): kwargs = {'shell': True, 'cwd': cwd} if out_log: - out_log_file = open(out_log, 'w') + out_log_file = open(out_log, 'w') # lint-amnesty, pylint: disable=consider-using-with kwargs['stdout'] = out_log_file if err_log: - err_log_file = open(err_log, 'w') + err_log_file = open(err_log, 'w') # lint-amnesty, pylint: disable=consider-using-with kwargs['stderr'] = err_log_file - proc = subprocess.Popen(cmd, **kwargs) + proc = subprocess.Popen(cmd, **kwargs) # lint-amnesty, pylint: disable=consider-using-with def exit_handler(): """ diff --git a/pavelib/utils/test/suites/suite.py b/pavelib/utils/test/suites/suite.py index 9c7e96ce65a5e416731596c2f0b0e3596340fd74..5a423c827c21a7928d4a671eaad1a3c9c33fc867 100644 --- a/pavelib/utils/test/suites/suite.py +++ b/pavelib/utils/test/suites/suite.py @@ -99,7 +99,7 @@ class TestSuite: process = None try: - process = subprocess.Popen(cmd, **kwargs) + process = subprocess.Popen(cmd, **kwargs) # lint-amnesty, pylint: disable=consider-using-with return self.is_success(process.wait()) except KeyboardInterrupt: kill_process(process) diff --git a/scripts/thresholds.sh b/scripts/thresholds.sh index 26826157e9849d8b465f9ed86528a7473bdd3246..ff982ed4311cd50485f6ed472a231f97cc1d8954 100755 --- a/scripts/thresholds.sh +++ b/scripts/thresholds.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -export LOWER_PYLINT_THRESHOLD=200 -export UPPER_PYLINT_THRESHOLD=200 +export LOWER_PYLINT_THRESHOLD=0 +export UPPER_PYLINT_THRESHOLD=1 export ESLINT_THRESHOLD=5300 export STYLELINT_THRESHOLD=880