Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 9, 2024
1 parent baa6c95 commit 0ad5088
Show file tree
Hide file tree
Showing 43 changed files with 97 additions and 60 deletions.
1 change: 1 addition & 0 deletions src/edx_sysadmin/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from django.urls import re_path

from edx_sysadmin.api.views import (
GitCourseDetailsAPIView,
GitReloadAPIView,
Expand Down
11 changes: 6 additions & 5 deletions src/edx_sysadmin/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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__)

Expand Down
7 changes: 4 additions & 3 deletions src/edx_sysadmin/git_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
5 changes: 3 additions & 2 deletions src/edx_sysadmin/management/commands/git_add_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions src/edx_sysadmin/tests/test_sysadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +24,9 @@
SharedModuleStoreTestCase,
)

from edx_sysadmin.git_import import GitImportNoDirError
from edx_sysadmin.models import CourseGitLog


class SysadminBaseTestCase(SharedModuleStoreTestCase): # pragma: allowlist secret
"""
Expand Down
1 change: 1 addition & 0 deletions src/edx_sysadmin/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from django.urls import include, re_path

from edx_sysadmin.views import (
CoursesPanel,
GitImport,
Expand Down
5 changes: 3 additions & 2 deletions src/edx_sysadmin/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
5 changes: 3 additions & 2 deletions src/edx_sysadmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)

Expand Down
3 changes: 2 additions & 1 deletion src/ol_openedx_canvas_integration/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_canvas_integration/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_canvas_integration/task_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_canvas_integration/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_canvas_integration/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from django.urls import re_path

from ol_openedx_canvas_integration import views

urlpatterns = [
Expand Down
3 changes: 2 additions & 1 deletion src/ol_openedx_canvas_integration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_checkout_external/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from django.urls import re_path

from ol_openedx_checkout_external.views import external_checkout

urlpatterns = [
Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_checkout_external/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_course_export/s3_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import boto3
from django.conf import settings

from ol_openedx_course_export.utils import get_file_name_with_extension


Expand Down
2 changes: 1 addition & 1 deletion src/ol_openedx_course_export/settings/common.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/ol_openedx_course_export/settings/production.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/ol_openedx_course_export/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_course_export/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from django.conf import settings
from django.urls import re_path

from ol_openedx_course_export.views import CourseExportView

urlpatterns = [
Expand Down
1 change: 1 addition & 0 deletions src/ol_openedx_course_export/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf import settings

from ol_openedx_course_export.constants import AWS_S3_DEFAULT_URL_PREFIX


Expand Down
13 changes: 7 additions & 6 deletions src/ol_openedx_course_export/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
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
from rest_framework.permissions import IsAdminUser
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__)


Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/ol_openedx_course_structure_api/settings/common.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/ol_openedx_course_structure_api/settings/production.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/ol_openedx_course_structure_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion src/ol_openedx_course_structure_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
3 changes: 2 additions & 1 deletion src/ol_openedx_git_auto_export/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
3 changes: 2 additions & 1 deletion src/ol_openedx_otel_monitoring/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/ol_openedx_otel_monitoring/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import logging

from django.conf import settings
from opentelemetry.instrumentation.django import DjangoInstrumentor

from ol_openedx_otel_monitoring.exceptions import (
ConfigurationError,
InitializationError,
InstrumentationError,
)
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__)
Expand Down
Loading

0 comments on commit 0ad5088

Please sign in to comment.