From 0ad50888848ac555ff67e90753f314e7bea531f5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:39:05 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/edx_sysadmin/api/urls.py | 1 + src/edx_sysadmin/api/views.py | 11 ++++++----- src/edx_sysadmin/git_import.py | 7 ++++--- .../management/commands/git_add_course.py | 5 +++-- .../commands/tests/test_git_add_course.py | 7 ++++--- src/edx_sysadmin/tests/test_sysadmin.py | 5 +++-- src/edx_sysadmin/urls.py | 1 + src/edx_sysadmin/utils/utils.py | 5 +++-- src/edx_sysadmin/views.py | 5 +++-- src/ol_openedx_canvas_integration/api.py | 3 ++- src/ol_openedx_canvas_integration/client.py | 1 + src/ol_openedx_canvas_integration/task_helpers.py | 1 + src/ol_openedx_canvas_integration/tasks.py | 1 + src/ol_openedx_canvas_integration/urls.py | 1 + src/ol_openedx_canvas_integration/views.py | 3 ++- src/ol_openedx_checkout_external/urls.py | 1 + src/ol_openedx_checkout_external/views.py | 1 + src/ol_openedx_course_export/s3_client.py | 1 + src/ol_openedx_course_export/settings/common.py | 2 +- src/ol_openedx_course_export/settings/production.py | 2 +- src/ol_openedx_course_export/tasks.py | 3 ++- src/ol_openedx_course_export/urls.py | 1 + src/ol_openedx_course_export/utils.py | 1 + src/ol_openedx_course_export/views.py | 13 +++++++------ .../settings/common.py | 2 +- .../settings/production.py | 2 +- src/ol_openedx_course_structure_api/urls.py | 1 + src/ol_openedx_course_structure_api/views.py | 2 +- src/ol_openedx_git_auto_export/signals.py | 3 ++- src/ol_openedx_otel_monitoring/apps.py | 3 ++- src/ol_openedx_otel_monitoring/client.py | 3 ++- src/ol_openedx_otel_monitoring/metrics.py | 9 +++++---- src/ol_openedx_otel_monitoring/tracing.py | 9 +++++---- src/ol_openedx_otel_monitoring/urls.py | 1 + .../context_api.py | 3 ++- src/ol_openedx_rapid_response_reports/urls.py | 1 + src/rapid_response_xblock/block.py | 9 +++++---- src/rapid_response_xblock/logger.py | 1 + src/rapid_response_xblock/tests/conftest.py | 2 +- src/rapid_response_xblock/tests/test_aside.py | 9 +++++---- src/rapid_response_xblock/tests/test_events.py | 11 ++++++----- src/rapid_response_xblock/tests/test_utils.py | 3 ++- src/rapid_response_xblock/urls.py | 1 + 43 files changed, 97 insertions(+), 60 deletions(-) diff --git a/src/edx_sysadmin/api/urls.py b/src/edx_sysadmin/api/urls.py index 084d6d72..b14c473c 100644 --- a/src/edx_sysadmin/api/urls.py +++ b/src/edx_sysadmin/api/urls.py @@ -3,6 +3,7 @@ """ from django.urls import re_path + from edx_sysadmin.api.views import ( GitCourseDetailsAPIView, GitReloadAPIView, diff --git a/src/edx_sysadmin/api/views.py b/src/edx_sysadmin/api/views.py index ed32f857..3071951e 100644 --- a/src/edx_sysadmin/api/views.py +++ b/src/edx_sysadmin/api/views.py @@ -4,6 +4,12 @@ from django.conf import settings from django.utils.translation import gettext as _ +from path import Path as get_path # noqa: N813 +from rest_framework import permissions, status +from rest_framework.authentication import SessionAuthentication +from rest_framework.response import Response +from rest_framework.views import APIView + from edx_sysadmin.api.permissions import GithubWebhookPermission from edx_sysadmin.git_import import ( DEFAULT_GIT_REPO_DIR, @@ -14,11 +20,6 @@ get_local_active_branch, get_local_course_repo, ) -from path import Path as get_path # noqa: N813 -from rest_framework import permissions, status -from rest_framework.authentication import SessionAuthentication -from rest_framework.response import Response -from rest_framework.views import APIView logger = logging.getLogger(__name__) diff --git a/src/edx_sysadmin/git_import.py b/src/edx_sysadmin/git_import.py index d78dc0d5..b785d824 100644 --- a/src/edx_sysadmin/git_import.py +++ b/src/edx_sysadmin/git_import.py @@ -18,14 +18,15 @@ from django.core.management.base import CommandError from django.utils import timezone from django.utils.translation import gettext_lazy as _ +from opaque_keys.edx.locator import CourseLocator +from xmodule.modulestore.django import SignalHandler +from xmodule.util.sandboxing import DEFAULT_PYTHON_LIB_FILENAME + from edx_sysadmin.models import CourseGitLog from edx_sysadmin.utils.utils import ( DEFAULT_GIT_REPO_PREFIX, remove_old_course_import_logs, ) -from opaque_keys.edx.locator import CourseLocator -from xmodule.modulestore.django import SignalHandler -from xmodule.util.sandboxing import DEFAULT_PYTHON_LIB_FILENAME log = logging.getLogger(__name__) diff --git a/src/edx_sysadmin/management/commands/git_add_course.py b/src/edx_sysadmin/management/commands/git_add_course.py index 56183475..de0234ac 100644 --- a/src/edx_sysadmin/management/commands/git_add_course.py +++ b/src/edx_sysadmin/management/commands/git_add_course.py @@ -8,10 +8,11 @@ from django.core.management.base import BaseCommand, CommandError from django.utils.translation import gettext as _ -from edx_sysadmin import git_import from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml import XMLModuleStore +from edx_sysadmin import git_import + log = logging.getLogger(__name__) @@ -57,4 +58,4 @@ def handle(self, *args, **options): # noqa: ARG002 try: git_import.add_repo(options["repository_url"], rdir_arg, branch) except git_import.GitImportError as ex: - raise CommandError(str(ex)) # noqa: B904, TRY200 + raise CommandError(str(ex)) # noqa: B904 diff --git a/src/edx_sysadmin/management/commands/tests/test_git_add_course.py b/src/edx_sysadmin/management/commands/tests/test_git_add_course.py index 2f09c53c..f2edd0c8 100644 --- a/src/edx_sysadmin/management/commands/tests/test_git_add_course.py +++ b/src/edx_sysadmin/management/commands/tests/test_git_add_course.py @@ -16,6 +16,10 @@ from django.core.management import call_command from django.core.management.base import CommandError from django.test.utils import override_settings +from xmodule.modulestore import ModuleStoreEnum +from xmodule.modulestore.django import modulestore +from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase + from edx_sysadmin import git_import from edx_sysadmin.git_import import ( GitImportBadRepoError, @@ -25,9 +29,6 @@ GitImportRemoteBranchMissingError, GitImportUrlBadError, ) -from xmodule.modulestore import ModuleStoreEnum -from xmodule.modulestore.django import modulestore -from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase @override_settings( diff --git a/src/edx_sysadmin/tests/test_sysadmin.py b/src/edx_sysadmin/tests/test_sysadmin.py index 51be0fd0..de948741 100644 --- a/src/edx_sysadmin/tests/test_sysadmin.py +++ b/src/edx_sysadmin/tests/test_sysadmin.py @@ -15,8 +15,6 @@ from django.test.client import Client from django.test.utils import override_settings from django.urls import reverse -from edx_sysadmin.git_import import GitImportNoDirError -from edx_sysadmin.models import CourseGitLog from opaque_keys.edx.locator import CourseLocator from openedx.core.djangolib.markup import Text from pytz import UTC @@ -26,6 +24,9 @@ SharedModuleStoreTestCase, ) +from edx_sysadmin.git_import import GitImportNoDirError +from edx_sysadmin.models import CourseGitLog + class SysadminBaseTestCase(SharedModuleStoreTestCase): # pragma: allowlist secret """ diff --git a/src/edx_sysadmin/urls.py b/src/edx_sysadmin/urls.py index 041855d1..6d91e717 100644 --- a/src/edx_sysadmin/urls.py +++ b/src/edx_sysadmin/urls.py @@ -3,6 +3,7 @@ """ from django.urls import include, re_path + from edx_sysadmin.views import ( CoursesPanel, GitImport, diff --git a/src/edx_sysadmin/utils/utils.py b/src/edx_sysadmin/utils/utils.py index 084994f3..5cb1ce95 100644 --- a/src/edx_sysadmin/utils/utils.py +++ b/src/edx_sysadmin/utils/utils.py @@ -19,14 +19,15 @@ from django.urls import reverse from django.utils.translation import gettext as _ from django_countries import countries -from edx_sysadmin.models import CourseGitLog -from edx_sysadmin.utils.markup import HTML, Text from git import InvalidGitRepositoryError, NoSuchPathError, Repo from openedx.core.djangoapps.user_authn.toggles import ( is_require_third_party_auth_enabled, ) from xmodule.modulestore.django import modulestore +from edx_sysadmin.models import CourseGitLog +from edx_sysadmin.utils.markup import HTML, Text + User = get_user_model() logger = logging.getLogger(__name__) diff --git a/src/edx_sysadmin/views.py b/src/edx_sysadmin/views.py index 75bd8ea0..a3263528 100644 --- a/src/edx_sysadmin/views.py +++ b/src/edx_sysadmin/views.py @@ -19,6 +19,9 @@ from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.http import condition from django.views.generic.base import RedirectView, TemplateView +from opaque_keys.edx.keys import CourseKey +from xmodule.modulestore.django import modulestore + from edx_sysadmin import git_import from edx_sysadmin.forms import UserRegistrationForm from edx_sysadmin.git_import import GitImportError @@ -35,8 +38,6 @@ user_has_access_to_sysadmin, user_has_access_to_users_panel, ) -from opaque_keys.edx.keys import CourseKey -from xmodule.modulestore.django import modulestore log = logging.getLogger(__name__) diff --git a/src/ol_openedx_canvas_integration/api.py b/src/ol_openedx_canvas_integration/api.py index e4a12c46..4cd0036c 100644 --- a/src/ol_openedx_canvas_integration/api.py +++ b/src/ol_openedx_canvas_integration/api.py @@ -9,12 +9,13 @@ from lms.djangoapps.courseware.courses import get_course_by_id from lms.djangoapps.grades.context import grading_context_for_course from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory +from opaque_keys.edx.locator import CourseLocator + from ol_openedx_canvas_integration.client import ( CanvasClient, create_assignment_payload, update_grade_payload_kv, ) -from opaque_keys.edx.locator import CourseLocator log = logging.getLogger(__name__) diff --git a/src/ol_openedx_canvas_integration/client.py b/src/ol_openedx_canvas_integration/client.py index 0752d469..b150abbe 100644 --- a/src/ol_openedx_canvas_integration/client.py +++ b/src/ol_openedx_canvas_integration/client.py @@ -4,6 +4,7 @@ import pytz import requests from django.conf import settings + from ol_openedx_canvas_integration.constants import DEFAULT_ASSIGNMENT_POINTS log = logging.getLogger(__name__) diff --git a/src/ol_openedx_canvas_integration/task_helpers.py b/src/ol_openedx_canvas_integration/task_helpers.py index 57869a65..dbbbec64 100644 --- a/src/ol_openedx_canvas_integration/task_helpers.py +++ b/src/ol_openedx_canvas_integration/task_helpers.py @@ -6,6 +6,7 @@ from lms.djangoapps.courseware.courses import get_course_by_id from lms.djangoapps.instructor_task.tasks_helper.runner import TaskProgress + from ol_openedx_canvas_integration import api diff --git a/src/ol_openedx_canvas_integration/tasks.py b/src/ol_openedx_canvas_integration/tasks.py index fc615f23..4f00d226 100644 --- a/src/ol_openedx_canvas_integration/tasks.py +++ b/src/ol_openedx_canvas_integration/tasks.py @@ -8,6 +8,7 @@ from lms.djangoapps.instructor_task.api_helper import submit_task from lms.djangoapps.instructor_task.tasks_base import BaseInstructorTask from lms.djangoapps.instructor_task.tasks_helper.runner import run_main_task + from ol_openedx_canvas_integration import task_helpers from ol_openedx_canvas_integration.constants import ( TASK_TYPE_PUSH_EDX_GRADES_TO_CANVAS, diff --git a/src/ol_openedx_canvas_integration/urls.py b/src/ol_openedx_canvas_integration/urls.py index c8e0a243..f54c4936 100644 --- a/src/ol_openedx_canvas_integration/urls.py +++ b/src/ol_openedx_canvas_integration/urls.py @@ -3,6 +3,7 @@ """ from django.urls import re_path + from ol_openedx_canvas_integration import views urlpatterns = [ diff --git a/src/ol_openedx_canvas_integration/views.py b/src/ol_openedx_canvas_integration/views.py index 677bbdfe..c7b22a04 100644 --- a/src/ol_openedx_canvas_integration/views.py +++ b/src/ol_openedx_canvas_integration/views.py @@ -14,9 +14,10 @@ from lms.djangoapps.instructor import permissions from lms.djangoapps.instructor.views.api import require_course_permission from lms.djangoapps.instructor_task.api_helper import AlreadyRunningError +from opaque_keys.edx.locator import CourseLocator + from ol_openedx_canvas_integration import tasks from ol_openedx_canvas_integration.client import CanvasClient -from opaque_keys.edx.locator import CourseLocator log = logging.getLogger(__name__) diff --git a/src/ol_openedx_checkout_external/urls.py b/src/ol_openedx_checkout_external/urls.py index 0299e68d..4b8c8773 100644 --- a/src/ol_openedx_checkout_external/urls.py +++ b/src/ol_openedx_checkout_external/urls.py @@ -3,6 +3,7 @@ """ from django.urls import re_path + from ol_openedx_checkout_external.views import external_checkout urlpatterns = [ diff --git a/src/ol_openedx_checkout_external/views.py b/src/ol_openedx_checkout_external/views.py index 8e44f7e7..1d256af5 100644 --- a/src/ol_openedx_checkout_external/views.py +++ b/src/ol_openedx_checkout_external/views.py @@ -7,6 +7,7 @@ from django.conf import settings from django.contrib.auth.decorators import login_required from django.http import Http404, HttpResponseRedirect + from ol_openedx_checkout_external.exceptions import ExternalCheckoutError log = logging.getLogger(__name__) diff --git a/src/ol_openedx_course_export/s3_client.py b/src/ol_openedx_course_export/s3_client.py index 212ae63f..47803b02 100644 --- a/src/ol_openedx_course_export/s3_client.py +++ b/src/ol_openedx_course_export/s3_client.py @@ -1,5 +1,6 @@ import boto3 from django.conf import settings + from ol_openedx_course_export.utils import get_file_name_with_extension diff --git a/src/ol_openedx_course_export/settings/common.py b/src/ol_openedx_course_export/settings/common.py index 5575d74a..9eefd2db 100644 --- a/src/ol_openedx_course_export/settings/common.py +++ b/src/ol_openedx_course_export/settings/common.py @@ -1,5 +1,5 @@ """Common settings unique to the course export plugin.""" -def plugin_settings(settings): # noqa: ARG001 +def plugin_settings(settings): """Settings for the course export s3 location plugin.""" # noqa: D401 diff --git a/src/ol_openedx_course_export/settings/production.py b/src/ol_openedx_course_export/settings/production.py index 369b68a9..dc46850a 100644 --- a/src/ol_openedx_course_export/settings/production.py +++ b/src/ol_openedx_course_export/settings/production.py @@ -1,5 +1,5 @@ """Production settings unique to the course export plugin.""" -def plugin_settings(settings): # noqa: ARG001 +def plugin_settings(settings): """Settings for the course export plugin.""" # noqa: D401 diff --git a/src/ol_openedx_course_export/tasks.py b/src/ol_openedx_course_export/tasks.py index b21898ce..6acdf52f 100644 --- a/src/ol_openedx_course_export/tasks.py +++ b/src/ol_openedx_course_export/tasks.py @@ -7,11 +7,12 @@ from botocore.exceptions import ClientError from celery import shared_task # pylint: disable=import-error from cms.djangoapps.contentstore.tasks import CourseExportTask, create_export_tarball -from ol_openedx_course_export.s3_client import S3Client from opaque_keys.edx.keys import CourseKey from user_tasks.models import UserTaskStatus from xmodule.modulestore.django import modulestore +from ol_openedx_course_export.s3_client import S3Client + log = logging.getLogger(__name__) diff --git a/src/ol_openedx_course_export/urls.py b/src/ol_openedx_course_export/urls.py index 2e073aba..ce898341 100644 --- a/src/ol_openedx_course_export/urls.py +++ b/src/ol_openedx_course_export/urls.py @@ -4,6 +4,7 @@ from django.conf import settings from django.urls import re_path + from ol_openedx_course_export.views import CourseExportView urlpatterns = [ diff --git a/src/ol_openedx_course_export/utils.py b/src/ol_openedx_course_export/utils.py index 7f9cf785..a2af40b2 100644 --- a/src/ol_openedx_course_export/utils.py +++ b/src/ol_openedx_course_export/utils.py @@ -1,4 +1,5 @@ from django.conf import settings + from ol_openedx_course_export.constants import AWS_S3_DEFAULT_URL_PREFIX diff --git a/src/ol_openedx_course_export/views.py b/src/ol_openedx_course_export/views.py index fc4ae7a0..78fd63db 100644 --- a/src/ol_openedx_course_export/views.py +++ b/src/ol_openedx_course_export/views.py @@ -6,11 +6,6 @@ CourseImportExportViewMixin, ) from cms.djangoapps.contentstore.tasks import CourseExportTask -from ol_openedx_course_export.tasks import task_upload_course_s3 -from ol_openedx_course_export.utils import ( - get_aws_file_url, - is_bucket_configuration_valid, -) from openedx.core.lib.api.view_utils import verify_course_exists from rest_framework import status from rest_framework.generics import GenericAPIView @@ -18,6 +13,12 @@ from rest_framework.response import Response from user_tasks.models import UserTaskStatus +from ol_openedx_course_export.tasks import task_upload_course_s3 +from ol_openedx_course_export.utils import ( + get_aws_file_url, + is_bucket_configuration_valid, +) + log = logging.getLogger(__name__) @@ -159,7 +160,7 @@ def get(self, request, course_id): return Response({"state": task_status.state}) except Exception as e: log.exception(str(e)) # noqa: TRY401 - raise self.api_error( # noqa: B904, TRY200 + raise self.api_error( # noqa: B904 status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, developer_message=str(e), error_code="internal_error", diff --git a/src/ol_openedx_course_structure_api/settings/common.py b/src/ol_openedx_course_structure_api/settings/common.py index a20b228e..e2b7f3e5 100644 --- a/src/ol_openedx_course_structure_api/settings/common.py +++ b/src/ol_openedx_course_structure_api/settings/common.py @@ -1,5 +1,5 @@ """Common settings unique to the course structure API plugin.""" -def plugin_settings(settings): # noqa: ARG001 +def plugin_settings(settings): """Settings for the course structure API plugin""" # noqa: D401 diff --git a/src/ol_openedx_course_structure_api/settings/production.py b/src/ol_openedx_course_structure_api/settings/production.py index 27495cb4..f826f1ba 100644 --- a/src/ol_openedx_course_structure_api/settings/production.py +++ b/src/ol_openedx_course_structure_api/settings/production.py @@ -1,5 +1,5 @@ """Production settings unique to the course structure API.""" -def plugin_settings(settings): # noqa: ARG001 +def plugin_settings(settings): """Settings for the course structure API.""" # noqa: D401 diff --git a/src/ol_openedx_course_structure_api/urls.py b/src/ol_openedx_course_structure_api/urls.py index d6b33c62..124da447 100644 --- a/src/ol_openedx_course_structure_api/urls.py +++ b/src/ol_openedx_course_structure_api/urls.py @@ -4,6 +4,7 @@ from django.conf import settings from django.urls import re_path + from ol_openedx_course_structure_api.views import CourseStructureView urlpatterns = [ diff --git a/src/ol_openedx_course_structure_api/views.py b/src/ol_openedx_course_structure_api/views.py index 398240cc..fb198380 100644 --- a/src/ol_openedx_course_structure_api/views.py +++ b/src/ol_openedx_course_structure_api/views.py @@ -83,7 +83,7 @@ def get(self, request, course_id): try: course_key = CourseKey.from_string(course_id) except InvalidKeyError: - raise DeveloperErrorViewMixin.api_error( # noqa: B904, TRY200 + raise DeveloperErrorViewMixin.api_error( # noqa: B904 status_code=status.HTTP_404_NOT_FOUND, developer_message="Invalid course_id", ) diff --git a/src/ol_openedx_git_auto_export/signals.py b/src/ol_openedx_git_auto_export/signals.py index c0c3f27e..9b21aa67 100644 --- a/src/ol_openedx_git_auto_export/signals.py +++ b/src/ol_openedx_git_auto_export/signals.py @@ -3,9 +3,10 @@ from django.conf import settings from django.dispatch import receiver +from xmodule.modulestore.django import SignalHandler + from ol_openedx_git_auto_export.constants import ENABLE_GIT_AUTO_EXPORT from ol_openedx_git_auto_export.tasks import async_export_to_git -from xmodule.modulestore.django import SignalHandler log = logging.getLogger(__name__) diff --git a/src/ol_openedx_otel_monitoring/apps.py b/src/ol_openedx_otel_monitoring/apps.py index a4805072..df921392 100644 --- a/src/ol_openedx_otel_monitoring/apps.py +++ b/src/ol_openedx_otel_monitoring/apps.py @@ -4,9 +4,10 @@ from django.apps import AppConfig from edx_django_utils.plugins import PluginSettings, PluginURLs -from ol_openedx_otel_monitoring.client import initialize_otel from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType +from ol_openedx_otel_monitoring.client import initialize_otel + class OTelMonitoringConfig(AppConfig): name = "ol_openedx_otel_monitoring" diff --git a/src/ol_openedx_otel_monitoring/client.py b/src/ol_openedx_otel_monitoring/client.py index 56dd4e42..b1a77fac 100644 --- a/src/ol_openedx_otel_monitoring/client.py +++ b/src/ol_openedx_otel_monitoring/client.py @@ -9,6 +9,8 @@ import logging from django.conf import settings +from opentelemetry.instrumentation.django import DjangoInstrumentor + from ol_openedx_otel_monitoring.exceptions import ( ConfigurationError, InitializationError, @@ -16,7 +18,6 @@ ) from ol_openedx_otel_monitoring.metrics import prepare_metrics from ol_openedx_otel_monitoring.tracing import setup_tracing -from opentelemetry.instrumentation.django import DjangoInstrumentor # Configure logger for this module logger = logging.getLogger(__name__) diff --git a/src/ol_openedx_otel_monitoring/metrics.py b/src/ol_openedx_otel_monitoring/metrics.py index f196d3db..3d157ac5 100644 --- a/src/ol_openedx_otel_monitoring/metrics.py +++ b/src/ol_openedx_otel_monitoring/metrics.py @@ -15,6 +15,11 @@ from urllib.parse import urlparse from django.conf import settings +from opentelemetry import metrics +from opentelemetry.sdk.metrics import MeterProvider +from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader +from opentelemetry.sdk.resources import Resource + from ol_openedx_otel_monitoring.exceptions import ( ConfigurationError, EnvironmentVariableError, @@ -22,10 +27,6 @@ InitializationError, InstrumentationError, ) -from opentelemetry import metrics -from opentelemetry.sdk.metrics import MeterProvider -from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader -from opentelemetry.sdk.resources import Resource logger = logging.getLogger(__name__) diff --git a/src/ol_openedx_otel_monitoring/tracing.py b/src/ol_openedx_otel_monitoring/tracing.py index 72c88370..e93eb109 100644 --- a/src/ol_openedx_otel_monitoring/tracing.py +++ b/src/ol_openedx_otel_monitoring/tracing.py @@ -14,6 +14,11 @@ from urllib.parse import urlparse from django.conf import settings +from opentelemetry import trace +from opentelemetry.sdk.resources import Resource +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import BatchSpanProcessor + from ol_openedx_otel_monitoring.exceptions import ( ConfigurationError, EnvironmentVariableError, @@ -21,10 +26,6 @@ InitializationError, InstrumentationError, ) -from opentelemetry import trace -from opentelemetry.sdk.resources import Resource -from opentelemetry.sdk.trace import TracerProvider -from opentelemetry.sdk.trace.export import BatchSpanProcessor # Configure logger for this module logger = logging.getLogger(__name__) diff --git a/src/ol_openedx_otel_monitoring/urls.py b/src/ol_openedx_otel_monitoring/urls.py index a1288d3f..9dbae35f 100644 --- a/src/ol_openedx_otel_monitoring/urls.py +++ b/src/ol_openedx_otel_monitoring/urls.py @@ -3,6 +3,7 @@ """ from django.urls import path + from ol_openedx_otel_monitoring import views urlpatterns = [ diff --git a/src/ol_openedx_rapid_response_reports/context_api.py b/src/ol_openedx_rapid_response_reports/context_api.py index c6dfd8e6..dece4597 100644 --- a/src/ol_openedx_rapid_response_reports/context_api.py +++ b/src/ol_openedx_rapid_response_reports/context_api.py @@ -3,9 +3,10 @@ """ from django.utils.translation import gettext as _ -from rapid_response_xblock.utils import get_run_data_for_course from web_fragments.fragment import Fragment +from rapid_response_xblock.utils import get_run_data_for_course + def plugin_context(context): """Provide data for the rapid responses dashboard section""" diff --git a/src/ol_openedx_rapid_response_reports/urls.py b/src/ol_openedx_rapid_response_reports/urls.py index 1c5bf7f7..dbb311a0 100644 --- a/src/ol_openedx_rapid_response_reports/urls.py +++ b/src/ol_openedx_rapid_response_reports/urls.py @@ -3,6 +3,7 @@ """ from django.urls import re_path + from ol_openedx_rapid_response_reports.api import get_rapid_response_report urlpatterns = [ diff --git a/src/rapid_response_xblock/block.py b/src/rapid_response_xblock/block.py index f58a65d5..a8fb156b 100644 --- a/src/rapid_response_xblock/block.py +++ b/src/rapid_response_xblock/block.py @@ -11,16 +11,17 @@ from django.db.models import Count from django.template import Context, Template from django.utils.translation import gettext_lazy as _ -from rapid_response_xblock.models import ( - RapidResponseRun, - RapidResponseSubmission, -) from web_fragments.fragment import Fragment from webob.response import Response from xblock.core import XBlock, XBlockAside from xblock.fields import Boolean, Scope from xmodule.modulestore.django import modulestore +from rapid_response_xblock.models import ( + RapidResponseRun, + RapidResponseSubmission, +) + log = logging.getLogger(__name__) diff --git a/src/rapid_response_xblock/logger.py b/src/rapid_response_xblock/logger.py index b4576586..e059de65 100644 --- a/src/rapid_response_xblock/logger.py +++ b/src/rapid_response_xblock/logger.py @@ -9,6 +9,7 @@ from django.db import transaction from opaque_keys.edx.keys import UsageKey from opaque_keys.edx.locator import CourseLocator + from rapid_response_xblock.block import MULTIPLE_CHOICE_TYPE from rapid_response_xblock.models import ( RapidResponseRun, diff --git a/src/rapid_response_xblock/tests/conftest.py b/src/rapid_response_xblock/tests/conftest.py index f0b931e4..c5e59639 100644 --- a/src/rapid_response_xblock/tests/conftest.py +++ b/src/rapid_response_xblock/tests/conftest.py @@ -33,7 +33,7 @@ def pytest_configure(config): logging.disable(logging.WARNING) -@pytest.fixture() +@pytest.fixture def example_event(request): # noqa: PT004 """An example real event captured previously""" # noqa: D401 with Path.open(BASE_DIR / ".." / "test_data" / "example_event.json") as f: diff --git a/src/rapid_response_xblock/tests/test_aside.py b/src/rapid_response_xblock/tests/test_aside.py index 5ec66736..5e3f8aa9 100644 --- a/src/rapid_response_xblock/tests/test_aside.py +++ b/src/rapid_response_xblock/tests/test_aside.py @@ -10,6 +10,11 @@ from dateutil.parser import parse as parse_datetime from ddt import data, ddt, unpack from opaque_keys.edx.keys import UsageKey +from tests.utils import ( + RuntimeEnabledTestCase, + make_scope_ids, +) + from rapid_response_xblock.block import ( BLOCK_PROBLEM_CATEGORY, MULTIPLE_CHOICE_TYPE, @@ -19,10 +24,6 @@ RapidResponseRun, RapidResponseSubmission, ) -from tests.utils import ( - RuntimeEnabledTestCase, - make_scope_ids, -) @ddt diff --git a/src/rapid_response_xblock/tests/test_events.py b/src/rapid_response_xblock/tests/test_events.py index 12312bfc..44bc1188 100644 --- a/src/rapid_response_xblock/tests/test_events.py +++ b/src/rapid_response_xblock/tests/test_events.py @@ -8,11 +8,6 @@ from lms.djangoapps.courseware.block_render import load_single_xblock from opaque_keys.edx.keys import UsageKey from opaque_keys.edx.locator import CourseLocator -from rapid_response_xblock.logger import SubmissionRecorder -from rapid_response_xblock.models import ( - RapidResponseRun, - RapidResponseSubmission, -) from tests.utils import ( RuntimeEnabledTestCase, combine_dicts, @@ -20,6 +15,12 @@ ) from xmodule.modulestore.django import modulestore +from rapid_response_xblock.logger import SubmissionRecorder +from rapid_response_xblock.models import ( + RapidResponseRun, + RapidResponseSubmission, +) + # pylint: disable=no-member @pytest.mark.usefixtures("example_event") diff --git a/src/rapid_response_xblock/tests/test_utils.py b/src/rapid_response_xblock/tests/test_utils.py index 156a4425..f57e9607 100644 --- a/src/rapid_response_xblock/tests/test_utils.py +++ b/src/rapid_response_xblock/tests/test_utils.py @@ -3,9 +3,10 @@ import pytest from common.djangoapps.student.tests.factories import UserFactory from opaque_keys.edx.keys import UsageKey +from tests.utils import RuntimeEnabledTestCase + from rapid_response_xblock.models import RapidResponseRun, RapidResponseSubmission from rapid_response_xblock.utils import get_run_data_for_course, get_run_submission_data -from tests.utils import RuntimeEnabledTestCase class TestUtils(RuntimeEnabledTestCase): diff --git a/src/rapid_response_xblock/urls.py b/src/rapid_response_xblock/urls.py index 240b6578..99c09ee1 100644 --- a/src/rapid_response_xblock/urls.py +++ b/src/rapid_response_xblock/urls.py @@ -3,6 +3,7 @@ """ from django.urls import re_path + from rapid_response_xblock.views import toggle_rapid_response urlpatterns = [