From d42b0c401d61be16f0f8a1c821eeb97263e060b4 Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Sun, 14 Mar 2021 20:28:25 -0400 Subject: [PATCH] refactor: normalize xmodule imports Code in ./common/lib/xmodule/xmodule should be imported as `from xmodule`, since `xmodule` is a locally-installed package. This is weird, but as long as it is the case, we should be consistent. (In BOM-2584, I propose moving the files to ./xmodule, which would quell this confusion.) --- cms/djangoapps/contentstore/rest_api/v1/serializers.py | 2 +- cms/djangoapps/contentstore/rest_api/v1/views.py | 2 +- cms/djangoapps/contentstore/tests/test_proctoring.py | 2 +- common/lib/xmodule/xmodule/vertical_block.py | 2 +- lms/djangoapps/discussion/rest_api/tests/test_utils.py | 2 +- lms/envs/common.py | 2 +- .../api/processors/enrollment_track_partition_groups.py | 6 +++--- .../content/learning_sequences/api/tests/test_outlines.py | 2 +- openedx/core/djangoapps/course_date_signals/handlers.py | 2 +- openedx/core/djangoapps/discussions/tests/test_views.py | 4 ++-- .../personalized_learner_schedules/call_to_action.py | 2 +- .../show_answer/show_answer_field_override.py | 2 +- .../show_answer/tests/test_show_answer_override.py | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cms/djangoapps/contentstore/rest_api/v1/serializers.py b/cms/djangoapps/contentstore/rest_api/v1/serializers.py index 36235a886b..ee99efa31f 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/serializers.py +++ b/cms/djangoapps/contentstore/rest_api/v1/serializers.py @@ -4,7 +4,7 @@ API Serializers for Contentstore from rest_framework import serializers -from common.lib.xmodule.xmodule.course_module import get_available_providers +from xmodule.course_module import get_available_providers class ProctoredExamSettingsSerializer(serializers.Serializer): diff --git a/cms/djangoapps/contentstore/rest_api/v1/views.py b/cms/djangoapps/contentstore/rest_api/v1/views.py index 76ba4b359e..75c08b42ca 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views.py @@ -9,7 +9,7 @@ from rest_framework.views import APIView from cms.djangoapps.contentstore.views.course import get_course_and_check_access from cms.djangoapps.models.settings.course_metadata import CourseMetadata -from common.lib.xmodule.xmodule.course_module import get_available_providers +from xmodule.course_module import get_available_providers from openedx.core.lib.api.view_utils import view_auth_classes from xmodule.modulestore.django import modulestore diff --git a/cms/djangoapps/contentstore/tests/test_proctoring.py b/cms/djangoapps/contentstore/tests/test_proctoring.py index 95f8282cd4..a24116f9f1 100644 --- a/cms/djangoapps/contentstore/tests/test_proctoring.py +++ b/cms/djangoapps/contentstore/tests/test_proctoring.py @@ -13,7 +13,7 @@ from pytz import UTC from cms.djangoapps.contentstore.signals.handlers import listen_for_course_publish from common.djangoapps.student.tests.factories import UserFactory -from common.lib.xmodule.xmodule.modulestore import ModuleStoreEnum +from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory diff --git a/common/lib/xmodule/xmodule/vertical_block.py b/common/lib/xmodule/xmodule/vertical_block.py index f7a4e39a64..811aa57881 100644 --- a/common/lib/xmodule/xmodule/vertical_block.py +++ b/common/lib/xmodule/xmodule/vertical_block.py @@ -12,7 +12,7 @@ import pytz from lxml import etree from web_fragments.fragment import Fragment -from common.lib.xmodule.xmodule.util.misc import is_xblock_an_assignment +from xmodule.util.misc import is_xblock_an_assignment from xblock.core import XBlock # lint-amnesty, pylint: disable=wrong-import-order from xmodule.mako_module import MakoTemplateBlockBase from xmodule.progress import Progress diff --git a/lms/djangoapps/discussion/rest_api/tests/test_utils.py b/lms/djangoapps/discussion/rest_api/tests/test_utils.py index d3d6abc2dd..80ccc4e88c 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_utils.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_utils.py @@ -7,7 +7,7 @@ from datetime import datetime, timedelta from pytz import UTC from common.djangoapps.student.tests.factories import UserFactory, CourseEnrollmentFactory -from common.lib.xmodule.xmodule.modulestore.tests.django_utils import ModuleStoreTestCase +from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from lms.djangoapps.discussion.django_comment_client.tests.factories import RoleFactory from lms.djangoapps.discussion.rest_api.utils import discussion_open_for_user from xmodule.modulestore.tests.factories import CourseFactory diff --git a/lms/envs/common.py b/lms/envs/common.py index f45c3dccc3..7f585c3aec 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1462,7 +1462,7 @@ XBLOCK_FS_STORAGE_PREFIX = None # .. setting_default: {} # .. setting_description: Dictionary containing server-wide configuration of XBlocks on a per-type basis. # By default, keys should match the XBlock `block_settings_key` attribute/property. If the attribute/property -# is not defined, use the XBlock class name. Check `common.lib.xmodule.xmodule.services.SettingsService` +# is not defined, use the XBlock class name. Check `xmodule.services.SettingsService` # for more reference. XBLOCK_SETTINGS = {} diff --git a/openedx/core/djangoapps/content/learning_sequences/api/processors/enrollment_track_partition_groups.py b/openedx/core/djangoapps/content/learning_sequences/api/processors/enrollment_track_partition_groups.py index e5499ad7ce..82fed38599 100644 --- a/openedx/core/djangoapps/content/learning_sequences/api/processors/enrollment_track_partition_groups.py +++ b/openedx/core/djangoapps/content/learning_sequences/api/processors/enrollment_track_partition_groups.py @@ -1,13 +1,13 @@ # lint-amnesty, pylint: disable=missing-module-docstring import logging -from common.lib.xmodule.xmodule.partitions.enrollment_track_partition_generator import ( +from xmodule.partitions.enrollment_track_partition_generator import ( create_enrollment_track_partition_with_course_id ) -from common.lib.xmodule.xmodule.partitions.partitions import ( +from xmodule.partitions.partitions import ( ENROLLMENT_TRACK_PARTITION_ID, ) -from common.lib.xmodule.xmodule.partitions.partitions_service import get_user_partition_groups +from xmodule.partitions.partitions_service import get_user_partition_groups from .base import OutlineProcessor diff --git a/openedx/core/djangoapps/content/learning_sequences/api/tests/test_outlines.py b/openedx/core/djangoapps/content/learning_sequences/api/tests/test_outlines.py index 5e930614bb..e4dd66d614 100644 --- a/openedx/core/djangoapps/content/learning_sequences/api/tests/test_outlines.py +++ b/openedx/core/djangoapps/content/learning_sequences/api/tests/test_outlines.py @@ -24,7 +24,7 @@ from common.djangoapps.course_modes.signals import update_masters_access_course from common.djangoapps.student.auth import user_has_role from common.djangoapps.student.roles import CourseBetaTesterRole from common.djangoapps.student.tests.factories import BetaTesterFactory -from common.lib.xmodule.xmodule.partitions.partitions import ( +from xmodule.partitions.partitions import ( ENROLLMENT_TRACK_PARTITION_ID, ) diff --git a/openedx/core/djangoapps/course_date_signals/handlers.py b/openedx/core/djangoapps/course_date_signals/handlers.py index ac906c7b4b..263916c538 100644 --- a/openedx/core/djangoapps/course_date_signals/handlers.py +++ b/openedx/core/djangoapps/course_date_signals/handlers.py @@ -6,7 +6,7 @@ import logging from django.dispatch import receiver from edx_when.api import FIELDS_TO_EXTRACT, set_dates_for_course -from common.lib.xmodule.xmodule.util.misc import is_xblock_an_assignment +from xmodule.util.misc import is_xblock_an_assignment from openedx.core.lib.graph_traversals import get_children, leaf_filter, traverse_pre_order from xblock.fields import Scope # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore import ModuleStoreEnum diff --git a/openedx/core/djangoapps/discussions/tests/test_views.py b/openedx/core/djangoapps/discussions/tests/test_views.py index 88f87df999..5e4157ff52 100644 --- a/openedx/core/djangoapps/discussions/tests/test_views.py +++ b/openedx/core/djangoapps/discussions/tests/test_views.py @@ -11,8 +11,8 @@ from django.urls import reverse from rest_framework import status from rest_framework.test import APITestCase -from common.lib.xmodule.xmodule.modulestore.tests.django_utils import CourseUserType -from common.lib.xmodule.xmodule.modulestore.tests.django_utils import ModuleStoreTestCase +from xmodule.modulestore.tests.django_utils import CourseUserType +from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.factories import CourseFactory diff --git a/openedx/features/personalized_learner_schedules/call_to_action.py b/openedx/features/personalized_learner_schedules/call_to_action.py index 85d33e1338..e1f577853a 100644 --- a/openedx/features/personalized_learner_schedules/call_to_action.py +++ b/openedx/features/personalized_learner_schedules/call_to_action.py @@ -10,7 +10,7 @@ from django.conf import settings from django.urls import reverse from django.utils.translation import ngettext, gettext as _ -from common.lib.xmodule.xmodule.util.misc import is_xblock_an_assignment +from xmodule.util.misc import is_xblock_an_assignment from openedx.core.lib.mobile_utils import is_request_from_mobile_app from openedx.features.course_experience.url_helpers import is_request_from_learning_mfe from openedx.features.course_experience.utils import dates_banner_should_display 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 06afb64741..f7d8dc82dd 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,9 @@ 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 common.lib.xmodule.xmodule.capa_module import SHOWANSWER from lms.djangoapps.courseware.field_overrides import FieldOverrideProvider from openedx.features.course_experience import RELATIVE_DATES_FLAG +from xmodule.capa_module import SHOWANSWER class ShowAnswerFieldOverride(FieldOverrideProvider): diff --git a/openedx/features/personalized_learner_schedules/show_answer/tests/test_show_answer_override.py b/openedx/features/personalized_learner_schedules/show_answer/tests/test_show_answer_override.py index 7f405ccd7b..8002eeaf35 100644 --- a/openedx/features/personalized_learner_schedules/show_answer/tests/test_show_answer_override.py +++ b/openedx/features/personalized_learner_schedules/show_answer/tests/test_show_answer_override.py @@ -6,11 +6,11 @@ from django.test.utils import override_settings from edx_toggles.toggles.testutils import override_waffle_flag -from common.lib.xmodule.xmodule.capa_module import SHOWANSWER from lms.djangoapps.ccx.tests.test_overrides import inject_field_overrides from lms.djangoapps.courseware.model_data import FieldDataCache from lms.djangoapps.courseware.module_render import get_module from openedx.features.course_experience import RELATIVE_DATES_FLAG +from xmodule.capa_module import SHOWANSWER from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory