From 7f5b4a6a47bfc663e3f980dc6ca2d519feab6253 Mon Sep 17 00:00:00 2001 From: Jawayria <39649635+Jawayria@users.noreply.github.com> Date: Thu, 6 Jan 2022 19:14:51 +0500 Subject: [PATCH] chore: removed 'wrong-import-order' from disabled imports (#29365) * chore: removed 'wrong-import-order' from disabled imports --- cms/djangoapps/contentstore/api/urls.py | 2 +- .../rest_api/v0/tests/test_tabs.py | 2 +- cms/djangoapps/maintenance/urls.py | 3 +- cms/urls_dev.py | 2 +- .../course_modes/rest_api/v1/urls.py | 2 +- common/djangoapps/course_modes/urls.py | 2 +- .../entitlements/rest_api/v1/urls.py | 2 +- common/djangoapps/student/urls.py | 2 +- .../djangoapps/third_party_auth/api/urls.py | 2 +- common/djangoapps/third_party_auth/urls.py | 2 +- common/djangoapps/track/urls.py | 2 +- lms/djangoapps/courseware/module_render.py | 2 +- lms/djangoapps/discussion/rest_api/api.py | 6 +-- .../learner_dashboard/tests/test_views.py | 2 +- .../courseware_api/tests/test_views.py | 12 ++--- .../discussions/tests/test_transformer.py | 5 ++- .../discussions/tests/test_views.py | 4 +- pylintrc | 45 +++++++++---------- 18 files changed, 50 insertions(+), 49 deletions(-) diff --git a/cms/djangoapps/contentstore/api/urls.py b/cms/djangoapps/contentstore/api/urls.py index 2b363c705a..6d8158c4c8 100644 --- a/cms/djangoapps/contentstore/api/urls.py +++ b/cms/djangoapps/contentstore/api/urls.py @@ -2,9 +2,9 @@ from django.conf import settings +from django.urls import re_path from cms.djangoapps.contentstore.api.views import course_import, course_quality, course_validation -from django.urls import re_path app_name = 'contentstore' diff --git a/cms/djangoapps/contentstore/rest_api/v0/tests/test_tabs.py b/cms/djangoapps/contentstore/rest_api/v0/tests/test_tabs.py index b5e53fadb9..5162b50b06 100644 --- a/cms/djangoapps/contentstore/rest_api/v0/tests/test_tabs.py +++ b/cms/djangoapps/contentstore/rest_api/v0/tests/test_tabs.py @@ -3,10 +3,10 @@ Tests for the course tab API. """ import json +import random from urllib.parse import urlencode import ddt -import random from django.urls import reverse from xmodule.modulestore.tests.factories import ItemFactory from xmodule.tabs import CourseTabList diff --git a/cms/djangoapps/maintenance/urls.py b/cms/djangoapps/maintenance/urls.py index c3bdbb98be..42febd1395 100644 --- a/cms/djangoapps/maintenance/urls.py +++ b/cms/djangoapps/maintenance/urls.py @@ -2,6 +2,8 @@ URLs for the maintenance app. """ +from django.urls import path, re_path + from .views import ( AnnouncementCreateView, AnnouncementDeleteView, @@ -10,7 +12,6 @@ from .views import ( ForcePublishCourseView, MaintenanceIndexView ) -from django.urls import path, re_path app_name = 'cms.djangoapps.maintenance' diff --git a/cms/urls_dev.py b/cms/urls_dev.py index 2d02198b9b..200d857691 100644 --- a/cms/urls_dev.py +++ b/cms/urls_dev.py @@ -5,8 +5,8 @@ development mode; otherwise, it is ignored. """ -from cms.djangoapps.contentstore.views.dev import dev_mode from django.urls import path +from cms.djangoapps.contentstore.views.dev import dev_mode urlpatterns = [ path('dev_mode', dev_mode, name='dev_mode'), diff --git a/common/djangoapps/course_modes/rest_api/v1/urls.py b/common/djangoapps/course_modes/rest_api/v1/urls.py index 6ec5e004a1..6a066d7e63 100644 --- a/common/djangoapps/course_modes/rest_api/v1/urls.py +++ b/common/djangoapps/course_modes/rest_api/v1/urls.py @@ -5,8 +5,8 @@ URL definitions for the course_modes v1 API. from django.conf import settings -from common.djangoapps.course_modes.rest_api.v1 import views from django.urls import re_path +from common.djangoapps.course_modes.rest_api.v1 import views app_name = 'v1' diff --git a/common/djangoapps/course_modes/urls.py b/common/djangoapps/course_modes/urls.py index 91cf3e466f..8c3e562688 100644 --- a/common/djangoapps/course_modes/urls.py +++ b/common/djangoapps/course_modes/urls.py @@ -3,8 +3,8 @@ from django.conf import settings -from common.djangoapps.course_modes import views from django.urls import re_path +from common.djangoapps.course_modes import views urlpatterns = [ re_path(fr'^choose/{settings.COURSE_ID_PATTERN}/$', views.ChooseModeView.as_view(), name='course_modes_choose'), diff --git a/common/djangoapps/entitlements/rest_api/v1/urls.py b/common/djangoapps/entitlements/rest_api/v1/urls.py index 5befc2a5c9..a4c2c95367 100644 --- a/common/djangoapps/entitlements/rest_api/v1/urls.py +++ b/common/djangoapps/entitlements/rest_api/v1/urls.py @@ -5,8 +5,8 @@ URLs for the V1 of the Entitlements API. from django.conf.urls import include from rest_framework.routers import DefaultRouter -from .views import EntitlementEnrollmentViewSet, EntitlementViewSet from django.urls import path, re_path +from .views import EntitlementEnrollmentViewSet, EntitlementViewSet router = DefaultRouter() router.register(r'entitlements', EntitlementViewSet, basename='entitlements') diff --git a/common/djangoapps/student/urls.py b/common/djangoapps/student/urls.py index b452114751..ecaaf7f36f 100644 --- a/common/djangoapps/student/urls.py +++ b/common/djangoapps/student/urls.py @@ -4,9 +4,9 @@ URLs for student app from django.conf import settings +from django.urls import path, re_path from . import views -from django.urls import path, re_path urlpatterns = [ diff --git a/common/djangoapps/third_party_auth/api/urls.py b/common/djangoapps/third_party_auth/api/urls.py index 361c7097f0..451f180359 100644 --- a/common/djangoapps/third_party_auth/api/urls.py +++ b/common/djangoapps/third_party_auth/api/urls.py @@ -2,9 +2,9 @@ from django.conf import settings +from django.urls import path, re_path from .views import ThirdPartyAuthUserStatusView, UserMappingView, UserView, UserViewV2 -from django.urls import path, re_path PROVIDER_PATTERN = r'(?P[\w.+-]+)(?:\:(?P[\w.+-]+))?' diff --git a/common/djangoapps/third_party_auth/urls.py b/common/djangoapps/third_party_auth/urls.py index e923637dc0..6d600856f9 100644 --- a/common/djangoapps/third_party_auth/urls.py +++ b/common/djangoapps/third_party_auth/urls.py @@ -1,6 +1,7 @@ """Url configuration for the auth module.""" from django.conf.urls import include +from django.urls import path, re_path from .views import ( IdPRedirectView, @@ -9,7 +10,6 @@ from .views import ( post_to_custom_auth_form, saml_metadata_view ) -from django.urls import path, re_path urlpatterns = [ path('auth/inactive', inactive_user_view, name="third_party_inactive_redirect"), diff --git a/common/djangoapps/track/urls.py b/common/djangoapps/track/urls.py index ac43112a56..9f8a26b70d 100644 --- a/common/djangoapps/track/urls.py +++ b/common/djangoapps/track/urls.py @@ -1,10 +1,10 @@ """ URLs for track app """ +from django.urls import path from . import views from .views import segmentio -from django.urls import path urlpatterns = [ path('event', views.user_track), diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 828419d55a..a8fb7cf8f6 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -41,7 +41,7 @@ from xblock.runtime import KvsFieldData from common.djangoapps import static_replace from common.djangoapps.xblock_django.constants import ATTR_KEY_USER_ID -from capa.xqueue_interface import XQueueService +from capa.xqueue_interface import XQueueService # lint-amnesty, pylint: disable=wrong-import-order from lms.djangoapps.courseware.access import get_user_role, has_access from lms.djangoapps.courseware.entrance_exams import user_can_skip_entrance_exam, user_has_passed_entrance_exam from lms.djangoapps.courseware.masquerade import ( diff --git a/lms/djangoapps/discussion/rest_api/api.py b/lms/djangoapps/discussion/rest_api/api.py index e0053ab32f..dc1e463ca7 100644 --- a/lms/djangoapps/discussion/rest_api/api.py +++ b/lms/djangoapps/discussion/rest_api/api.py @@ -5,6 +5,7 @@ from __future__ import annotations import itertools from collections import defaultdict +from enum import Enum from typing import Dict, List, Literal, Optional, Set, Tuple from urllib.parse import urlencode, urlunparse @@ -12,11 +13,12 @@ from django.contrib.auth import get_user_model from django.core.exceptions import ValidationError from django.http import Http404 from django.urls import reverse -from enum import Enum # lint-amnesty, pylint: disable=wrong-import-order from opaque_keys import InvalidKeyError from opaque_keys.edx.locator import CourseKey from rest_framework.exceptions import PermissionDenied from rest_framework.request import Request +from xmodule.course_module import CourseBlock +from xmodule.tabs import CourseTabList from lms.djangoapps.courseware.courses import get_course_with_access from lms.djangoapps.courseware.exceptions import CourseAccessRedirect @@ -44,8 +46,6 @@ from openedx.core.djangoapps.django_comment_common.signals import ( from openedx.core.djangoapps.user_api.accounts.api import get_account_settings from openedx.core.lib.exceptions import CourseNotFoundError, DiscussionNotFoundError, PageNotFoundError -from xmodule.course_module import CourseBlock # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.tabs import CourseTabList from .exceptions import ( CommentNotFoundError, DiscussionBlackOutException, diff --git a/lms/djangoapps/learner_dashboard/tests/test_views.py b/lms/djangoapps/learner_dashboard/tests/test_views.py index d39569e1d9..eeeebd569f 100644 --- a/lms/djangoapps/learner_dashboard/tests/test_views.py +++ b/lms/djangoapps/learner_dashboard/tests/test_views.py @@ -2,8 +2,8 @@ Unit tests covering the program discussion iframe API. """ -import ddt from uuid import uuid4 +import ddt from django.urls import reverse_lazy from edx_toggles.toggles.testutils import override_waffle_flag diff --git a/openedx/core/djangoapps/courseware_api/tests/test_views.py b/openedx/core/djangoapps/courseware_api/tests/test_views.py index 0d560fd6cd..af3ae97145 100644 --- a/openedx/core/djangoapps/courseware_api/tests/test_views.py +++ b/openedx/core/djangoapps/courseware_api/tests/test_views.py @@ -15,6 +15,12 @@ from django.test.client import RequestFactory from edx_django_utils.cache import TieredCache from edx_toggles.toggles.testutils import override_waffle_flag +from xmodule.data import CertificatesDisplayBehaviors +from xmodule.modulestore.django import modulestore +from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase +from xmodule.modulestore.tests.factories import ItemFactory, ToyCourseFactory +from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID + from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.tests.factories import CourseModeFactory from lms.djangoapps.certificates.api import get_certificate_url @@ -39,12 +45,6 @@ from common.djangoapps.student.tests.factories import CourseEnrollmentCelebratio from openedx.core.djangoapps.agreements.api import create_integrity_signature from openedx.core.djangoapps.agreements.toggles import ENABLE_INTEGRITY_SIGNATURE -from xmodule.data import CertificatesDisplayBehaviors # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import ItemFactory, ToyCourseFactory # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID - User = get_user_model() diff --git a/openedx/core/djangoapps/discussions/tests/test_transformer.py b/openedx/core/djangoapps/discussions/tests/test_transformer.py index b8b7f4fac7..50059d3da5 100644 --- a/openedx/core/djangoapps/discussions/tests/test_transformer.py +++ b/openedx/core/djangoapps/discussions/tests/test_transformer.py @@ -2,12 +2,13 @@ Tests for discussions course block transformer """ +from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, TEST_DATA_SPLIT_MODULESTORE +from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory + from lms.djangoapps.course_blocks.api import get_course_blocks from lms.djangoapps.course_blocks.transformers.tests.helpers import TransformerRegistryTestMixin from openedx.core.djangoapps.discussions.models import DEFAULT_PROVIDER_TYPE, DiscussionTopicLink from openedx.core.djangoapps.discussions.transformers import DiscussionsTopicLinkTransformer -from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, TEST_DATA_SPLIT_MODULESTORE -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory class DiscussionsTopicLinkTransformerTestCase(TransformerRegistryTestMixin, ModuleStoreTestCase): diff --git a/openedx/core/djangoapps/discussions/tests/test_views.py b/openedx/core/djangoapps/discussions/tests/test_views.py index 848c254fe4..d46624e15a 100644 --- a/openedx/core/djangoapps/discussions/tests/test_views.py +++ b/openedx/core/djangoapps/discussions/tests/test_views.py @@ -13,11 +13,11 @@ from lti_consumer.models import CourseAllowPIISharingInLTIFlag from rest_framework import status from rest_framework.test import APITestCase -from common.djangoapps.student.tests.factories import UserFactory -from lms.djangoapps.discussion.django_comment_client.tests.factories import RoleFactory from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import CourseUserType, ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory +from common.djangoapps.student.tests.factories import UserFactory +from lms.djangoapps.discussion.django_comment_client.tests.factories import RoleFactory from ..models import AVAILABLE_PROVIDER_MAP, DEFAULT_CONFIG_ENABLED, DEFAULT_PROVIDER_TYPE, Provider DATA_LEGACY_COHORTS = { diff --git a/pylintrc b/pylintrc index e1163f4aa7..6e5f0ea8ef 100644 --- a/pylintrc +++ b/pylintrc @@ -72,10 +72,10 @@ persistent = yes load-plugins = edx_lint.pylint,pylint_django_settings,pylint_django,pylint_celery,pylint_pytest [MESSAGES CONTROL] -enable = +enable = blacklisted-name, line-too-long, - + abstract-class-instantiated, abstract-method, access-member-before-definition, @@ -212,7 +212,7 @@ enable = using-constant-test, yield-outside-function, zip-builtin-not-iterating, - + astroid-error, django-not-available-placeholder, django-not-available, @@ -220,20 +220,20 @@ enable = method-check-failed, parse-error, raw-checker-failed, - + empty-docstring, invalid-characters-in-docstring, missing-docstring, wrong-spelling-in-comment, wrong-spelling-in-docstring, - + unused-argument, unused-import, unused-variable, - + eval-used, exec-used, - + bad-classmethod-argument, bad-mcs-classmethod-argument, bad-mcs-method-argument, @@ -271,31 +271,31 @@ enable = unneeded-not, useless-else-on-loop, wrong-assert-type, - + deprecated-method, deprecated-module, - + too-many-boolean-expressions, too-many-nested-blocks, too-many-statements, - + wildcard-import, wrong-import-order, wrong-import-position, - + missing-final-newline, mixed-indentation, mixed-line-endings, trailing-newlines, trailing-whitespace, unexpected-line-ending-format, - + bad-inline-option, bad-option-value, deprecated-pragma, unrecognized-inline-option, useless-suppression, - + cmp-method, coerce-method, delslice-method, @@ -312,7 +312,7 @@ enable = rdiv-method, setslice-method, using-cmp-argument, -disable = +disable = bad-continuation, bad-indentation, consider-using-f-string, @@ -342,10 +342,10 @@ disable = unspecified-encoding, unused-wildcard-import, use-maxsplit-arg, - + feature-toggle-needs-doc, illegal-waffle-usage, - + apply-builtin, backtick, bad-python3-import, @@ -383,7 +383,7 @@ disable = unicode-builtin, unpacking-in-except, xrange-builtin, - + logging-fstring-interpolation, native-string, import-outside-toplevel, @@ -394,7 +394,6 @@ disable = useless-suppression, cyclic-import, logging-format-interpolation, - wrong-import-order, consider-using-dict-items, unnecessary-dict-index-lookup, arguments-renamed, @@ -452,7 +451,7 @@ ignore-imports = no ignore-mixin-members = yes ignored-classes = SQLObject unsafe-load-any-extension = yes -generated-members = +generated-members = REQUEST, acl_users, aq_parent, @@ -478,7 +477,7 @@ generated-members = [VARIABLES] init-import = no dummy-variables-rgx = _|dummy|unused|.*_unused -additional-builtins = +additional-builtins = [CLASSES] defining-attr-methods = __init__,__new__,setUp @@ -499,9 +498,9 @@ max-public-methods = 20 [IMPORTS] deprecated-modules = regsub,TERMIOS,Bastion,rexec -import-graph = -ext-import-graph = -int-import-graph = +import-graph = +ext-import-graph = +int-import-graph = [EXCEPTIONS] overgeneral-exceptions = Exception