From 4cdf46621577c1101b949c64afe9ce2afa53c11b Mon Sep 17 00:00:00 2001 From: Jawayria Date: Thu, 18 Feb 2021 21:20:33 +0500 Subject: [PATCH] refactor: Removed unused imports Removed unused imports from openedx/core/{djangolib, lib} and openedx/{tests, features} --- openedx/core/djangolib/translation_utils.py | 2 +- openedx/core/lib/api/tests/test_authentication.py | 2 +- openedx/core/lib/session_serializers.py | 1 - .../content_type_gating/tests/test_access.py | 5 +---- .../content_type_gating/tests/test_models.py | 1 - .../content_type_gating/tests/test_partitions.py | 7 ++----- openedx/features/course_experience/urls.py | 1 - openedx/features/course_experience/utils.py | 1 - .../course_experience/views/course_outline.py | 13 ------------- openedx/features/enterprise_support/admin/views.py | 2 +- .../learner_profile/views/learner_profile.py | 2 -- .../show_answer/show_answer_field_override.py | 3 --- openedx/tests/settings.py | 4 ---- 13 files changed, 6 insertions(+), 38 deletions(-) diff --git a/openedx/core/djangolib/translation_utils.py b/openedx/core/djangolib/translation_utils.py index f9749e37c2..9bd5ea3777 100644 --- a/openedx/core/djangolib/translation_utils.py +++ b/openedx/core/djangolib/translation_utils.py @@ -3,7 +3,7 @@ i18n utility functions """ -from django.utils.translation import ugettext as _, override # lint-amnesty, pylint: disable=unused-import +from django.utils.translation import override from django.utils.formats import dateformat, get_format diff --git a/openedx/core/lib/api/tests/test_authentication.py b/openedx/core/lib/api/tests/test_authentication.py index 4b5926ad9a..b880f5f2e2 100644 --- a/openedx/core/lib/api/tests/test_authentication.py +++ b/openedx/core/lib/api/tests/test_authentication.py @@ -11,7 +11,7 @@ from datetime import timedelta import ddt from django.conf import settings -from django.conf.urls import include, url # lint-amnesty, pylint: disable=unused-import +from django.conf.urls import url from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.http import HttpResponse from django.test import TestCase diff --git a/openedx/core/lib/session_serializers.py b/openedx/core/lib/session_serializers.py index 571eea7fbc..b6b336db04 100644 --- a/openedx/core/lib/session_serializers.py +++ b/openedx/core/lib/session_serializers.py @@ -2,7 +2,6 @@ Custom session serializer to deal with going from python2 and python3. """ import pickle -import six # lint-amnesty, pylint: disable=unused-import class PickleSerializer(object): diff --git a/openedx/features/content_type_gating/tests/test_access.py b/openedx/features/content_type_gating/tests/test_access.py index 087cae0ec8..6d613c9d03 100644 --- a/openedx/features/content_type_gating/tests/test_access.py +++ b/openedx/features/content_type_gating/tests/test_access.py @@ -1,8 +1,6 @@ """ Test audit user's access to various content based on content-gating features. """ - - import os from datetime import datetime, timedelta @@ -33,8 +31,7 @@ from openedx.core.djangoapps.django_comment_common.models import ( FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_COMMUNITY_TA, FORUM_ROLE_GROUP_MODERATOR, - FORUM_ROLE_MODERATOR, - Role + FORUM_ROLE_MODERATOR ) from openedx.core.djangoapps.user_api.tests.factories import UserCourseTagFactory from openedx.core.djangoapps.util.testing import TestConditionalContent diff --git a/openedx/features/content_type_gating/tests/test_models.py b/openedx/features/content_type_gating/tests/test_models.py index f261b02588..ab81c0a16e 100644 --- a/openedx/features/content_type_gating/tests/test_models.py +++ b/openedx/features/content_type_gating/tests/test_models.py @@ -12,7 +12,6 @@ from unittest.mock import Mock from opaque_keys.edx.locator import CourseLocator from common.djangoapps.course_modes.tests.factories import CourseModeFactory -from edx_toggles.toggles.testutils import override_waffle_flag from openedx.core.djangoapps.config_model_utils.models import Provenance from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfigurationFactory diff --git a/openedx/features/content_type_gating/tests/test_partitions.py b/openedx/features/content_type_gating/tests/test_partitions.py index 7dffe8d954..6258e5714a 100644 --- a/openedx/features/content_type_gating/tests/test_partitions.py +++ b/openedx/features/content_type_gating/tests/test_partitions.py @@ -1,6 +1,4 @@ from datetime import datetime - -from django.conf import settings from django.test import RequestFactory from unittest.mock import Mock, patch from opaque_keys.edx.keys import CourseKey @@ -10,10 +8,9 @@ from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory from openedx.core.djangolib.testing.utils import CacheIsolationTestCase from openedx.features.content_type_gating.helpers import CONTENT_GATING_PARTITION_ID, FULL_ACCESS, LIMITED_ACCESS from openedx.features.content_type_gating.models import ContentTypeGatingConfig -from openedx.features.content_type_gating.partitions import ContentTypeGatingPartition, create_content_gating_partition +from openedx.features.content_type_gating.partitions import create_content_gating_partition from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory -from common.djangoapps.student.tests.factories import GroupFactory -from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID, UserPartitionError +from xmodule.partitions.partitions import UserPartitionError class TestContentTypeGatingPartition(CacheIsolationTestCase): diff --git a/openedx/features/course_experience/urls.py b/openedx/features/course_experience/urls.py index f550814c73..ae005c7883 100644 --- a/openedx/features/course_experience/urls.py +++ b/openedx/features/course_experience/urls.py @@ -8,7 +8,6 @@ from django.conf.urls import url from .views.course_dates import CourseDatesFragmentMobileView from .views.course_home import CourseHomeFragmentView, CourseHomeView from .views.course_outline import CourseOutlineFragmentView -from .views.course_sock import CourseSockFragmentView # lint-amnesty, pylint: disable=unused-import from .views.course_updates import CourseUpdatesFragmentView, CourseUpdatesView from .views.latest_update import LatestUpdateFragmentView from .views.welcome_message import WelcomeMessageFragmentView, dismiss_welcome_message diff --git a/openedx/features/course_experience/utils.py b/openedx/features/course_experience/utils.py index 023df00f47..b26788cc79 100644 --- a/openedx/features/course_experience/utils.py +++ b/openedx/features/course_experience/utils.py @@ -2,7 +2,6 @@ Common utilities for the course experience, including course outline. """ - from django.utils import timezone from opaque_keys.edx.keys import CourseKey diff --git a/openedx/features/course_experience/views/course_outline.py b/openedx/features/course_experience/views/course_outline.py index 3b09fdd9a2..4f5dc03fbc 100644 --- a/openedx/features/course_experience/views/course_outline.py +++ b/openedx/features/course_experience/views/course_outline.py @@ -5,33 +5,21 @@ Views to show a course outline. import datetime import re -import six # lint-amnesty, pylint: disable=unused-import from completion.waffle import ENABLE_COMPLETION_TRACKING_SWITCH from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user -from django.db.models import Q # lint-amnesty, pylint: disable=unused-import -from django.shortcuts import redirect # lint-amnesty, pylint: disable=unused-import from django.template.context_processors import csrf from django.template.loader import render_to_string from django.urls import reverse -from django.utils import timezone # lint-amnesty, pylint: disable=unused-import -from django.views.decorators.csrf import ensure_csrf_cookie # lint-amnesty, pylint: disable=unused-import import edx_when.api as edx_when_api from opaque_keys.edx.keys import CourseKey from pytz import UTC from waffle.models import Switch from web_fragments.fragment import Fragment - -from lms.djangoapps.courseware.access import has_access # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.courseware.courses import get_course_overview_with_access from lms.djangoapps.courseware.date_summary import verified_upgrade_deadline_link -from lms.djangoapps.courseware.masquerade import setup_masquerade # lint-amnesty, pylint: disable=unused-import -from openedx.core.djangoapps.content.course_overviews.models import CourseOverview # lint-amnesty, pylint: disable=unused-import from openedx.core.djangoapps.plugin_api.views import EdxFragmentView -from openedx.core.djangoapps.schedules.utils import reset_self_paced_schedule # lint-amnesty, pylint: disable=unused-import -from openedx.features.course_experience import RELATIVE_DATES_FLAG # lint-amnesty, pylint: disable=unused-import from openedx.features.course_experience.utils import dates_banner_should_display -from openedx.features.content_type_gating.models import ContentTypeGatingConfig # lint-amnesty, pylint: disable=unused-import from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.util.milestones_helpers import get_course_content_milestones from xmodule.course_module import COURSE_VISIBILITY_PUBLIC @@ -52,7 +40,6 @@ class CourseOutlineFragmentView(EdxFragmentView): Renders the course outline as a fragment. """ from lms.urls import RESET_COURSE_DEADLINES_NAME - from openedx.features.course_experience.urls import COURSE_HOME_VIEW_NAME # lint-amnesty, pylint: disable=unused-import course_key = CourseKey.from_string(course_id) course_overview = get_course_overview_with_access( diff --git a/openedx/features/enterprise_support/admin/views.py b/openedx/features/enterprise_support/admin/views.py index 21d5785ed2..3ab1cc097b 100644 --- a/openedx/features/enterprise_support/admin/views.py +++ b/openedx/features/enterprise_support/admin/views.py @@ -2,7 +2,7 @@ Enterprise support admin views. """ -from django.contrib import admin, messages # lint-amnesty, pylint: disable=unused-import +from django.contrib import messages from django.urls import reverse from django.utils.translation import ugettext as _ from django.views.generic.edit import FormView diff --git a/openedx/features/learner_profile/views/learner_profile.py b/openedx/features/learner_profile/views/learner_profile.py index 99fa9259f0..86b268a299 100644 --- a/openedx/features/learner_profile/views/learner_profile.py +++ b/openedx/features/learner_profile/views/learner_profile.py @@ -8,7 +8,6 @@ from django.core.exceptions import ObjectDoesNotExist from django.http import Http404 from django.shortcuts import redirect, render from django.urls import reverse -from django.utils.translation import ugettext as _ # lint-amnesty, pylint: disable=unused-import from django.views.decorators.http import require_http_methods from django_countries import countries @@ -20,7 +19,6 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_ from openedx.core.djangoapps.user_api.accounts.api import get_account_settings from openedx.core.djangoapps.user_api.errors import UserNotAuthorized, UserNotFound from openedx.core.djangoapps.user_api.preferences.api import get_user_preferences -from openedx.core.djangolib.markup import HTML, Text # lint-amnesty, pylint: disable=unused-import from openedx.features.learner_profile.toggles import should_redirect_to_profile_microfrontend from openedx.features.learner_profile.views.learner_achievements import LearnerAchievementsFragmentView from common.djangoapps.student.models import User diff --git a/openedx/features/personalized_learner_schedules/show_answer/show_answer_field_override.py b/openedx/features/personalized_learner_schedules/show_answer/show_answer_field_override.py index 96a772e35b..a5eea67de5 100644 --- a/openedx/features/personalized_learner_schedules/show_answer/show_answer_field_override.py +++ b/openedx/features/personalized_learner_schedules/show_answer/show_answer_field_override.py @@ -3,9 +3,6 @@ FieldOverride that forces Show Answer values that use Past Due logic to new Show Answer values that remove the Past Due check (keeping the rest intact) """ - -from django.conf import settings # lint-amnesty, pylint: disable=unused-import - from common.lib.xmodule.xmodule.capa_base import SHOWANSWER from lms.djangoapps.courseware.field_overrides import FieldOverrideProvider from openedx.features.course_experience import RELATIVE_DATES_FLAG diff --git a/openedx/tests/settings.py b/openedx/tests/settings.py index 624e37015f..084e52adf1 100644 --- a/openedx/tests/settings.py +++ b/openedx/tests/settings.py @@ -2,13 +2,9 @@ Minimal Django settings for tests of common/lib. Required in Django 1.9+ due to imports of models in stock Django apps. """ - - -import sys # lint-amnesty, pylint: disable=unused-import import tempfile from django.utils.translation import ugettext_lazy as _ -from path import Path # lint-amnesty, pylint: disable=unused-import ALL_LANGUAGES = []