diff --git a/RELEASE.rst b/RELEASE.rst index 165011999..d77568449 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -1,6 +1,14 @@ Release Notes ============= +Version 0.146.1 +--------------- + +- fix: check for courseware object in cms (#2968) +- chore(deps): update dependency ruff to ^0.4.0 (#2962) +- chore(deps): update nginx docker tag to v1.26.0 +- fix(deps): update dependency boto3 to v1.34.96 + Version 0.146.0 (Released May 02, 2024) --------------- diff --git a/affiliate/api.py b/affiliate/api.py index 149aa7db9..9b874b375 100644 --- a/affiliate/api.py +++ b/affiliate/api.py @@ -1,4 +1,5 @@ """Affiliate tracking logic""" + from affiliate.constants import AFFILIATE_QS_PARAM from affiliate.models import Affiliate from mitxpro.utils import first_or_none diff --git a/affiliate/api_test.py b/affiliate/api_test.py index 3fad2143f..03d7e9217 100644 --- a/affiliate/api_test.py +++ b/affiliate/api_test.py @@ -1,4 +1,5 @@ """Affiliate tracking logic""" + import pytest from django.test.client import RequestFactory diff --git a/affiliate/apps.py b/affiliate/apps.py index 18eeff1ac..c3b329dd1 100644 --- a/affiliate/apps.py +++ b/affiliate/apps.py @@ -1,4 +1,5 @@ """Apps config for affiliate tracking""" + from django.apps import AppConfig diff --git a/affiliate/middleware.py b/affiliate/middleware.py index 7668fd9cc..8d0ce511c 100644 --- a/affiliate/middleware.py +++ b/affiliate/middleware.py @@ -1,4 +1,5 @@ """Middleware for affiliate tracking""" + from affiliate.api import get_affiliate_code_from_qstring from affiliate.constants import AFFILIATE_CODE_SESSION_KEY diff --git a/affiliate/middleware_test.py b/affiliate/middleware_test.py index 54dbf1c6b..2676f2d49 100644 --- a/affiliate/middleware_test.py +++ b/affiliate/middleware_test.py @@ -1,4 +1,5 @@ """Affiliate middleware tests""" + from django.contrib.sessions.middleware import SessionMiddleware from django.test.client import RequestFactory diff --git a/affiliate/models.py b/affiliate/models.py index 2acc931c0..1d8e0bd7f 100644 --- a/affiliate/models.py +++ b/affiliate/models.py @@ -1,4 +1,5 @@ """Model definitions for affiliate tracking""" + from django.conf import settings from django.db import models diff --git a/authentication/api.py b/authentication/api.py index 20127dcef..d7430896a 100644 --- a/authentication/api.py +++ b/authentication/api.py @@ -1,4 +1,5 @@ """Authentication api""" + from importlib import import_module from django.conf import settings diff --git a/authentication/api_test.py b/authentication/api_test.py index e97c65f4c..5c3186cf8 100644 --- a/authentication/api_test.py +++ b/authentication/api_test.py @@ -1,4 +1,5 @@ """API tests""" + import pytest from django.db import IntegrityError diff --git a/authentication/apps.py b/authentication/apps.py index 7aa306912..8797ac05c 100644 --- a/authentication/apps.py +++ b/authentication/apps.py @@ -1,4 +1,5 @@ """Authentication Apps""" + from django.apps import AppConfig diff --git a/authentication/exceptions.py b/authentication/exceptions.py index e103fe9b1..7d00eaf4d 100644 --- a/authentication/exceptions.py +++ b/authentication/exceptions.py @@ -1,4 +1,5 @@ """Authentication exceptions""" + from social_core.exceptions import AuthException diff --git a/authentication/middleware.py b/authentication/middleware.py index eaa545c50..3483e6c6d 100644 --- a/authentication/middleware.py +++ b/authentication/middleware.py @@ -1,4 +1,5 @@ """Authentication middleware""" + from urllib.parse import quote from django.shortcuts import redirect diff --git a/authentication/middleware_test.py b/authentication/middleware_test.py index 6c44d5d90..72655e76a 100644 --- a/authentication/middleware_test.py +++ b/authentication/middleware_test.py @@ -1,4 +1,5 @@ """Tests for auth middleware""" + from urllib.parse import quote from django.contrib.sessions.middleware import SessionMiddleware diff --git a/authentication/pipeline/compliance.py b/authentication/pipeline/compliance.py index 3e81f6d27..da0cd921f 100644 --- a/authentication/pipeline/compliance.py +++ b/authentication/pipeline/compliance.py @@ -1,4 +1,5 @@ """Compliance pipeline actions""" + import logging import pycountry diff --git a/authentication/pipeline/compliance_test.py b/authentication/pipeline/compliance_test.py index d2b6d0aee..71f0a9874 100644 --- a/authentication/pipeline/compliance_test.py +++ b/authentication/pipeline/compliance_test.py @@ -1,4 +1,5 @@ """Compliance pipeline tests""" + import pytest from social_core.exceptions import AuthException diff --git a/authentication/pipeline/user.py b/authentication/pipeline/user.py index 0d31273b0..8ee1ee7af 100644 --- a/authentication/pipeline/user.py +++ b/authentication/pipeline/user.py @@ -1,4 +1,5 @@ """Auth pipline functions for user authentication""" + import json import logging diff --git a/authentication/serializers.py b/authentication/serializers.py index a7cea5712..6e13d031a 100644 --- a/authentication/serializers.py +++ b/authentication/serializers.py @@ -1,4 +1,5 @@ """Authentication serializers""" + import logging from django.contrib.auth import get_user_model diff --git a/authentication/serializers_test.py b/authentication/serializers_test.py index 05ccabaad..e199bb0c2 100644 --- a/authentication/serializers_test.py +++ b/authentication/serializers_test.py @@ -1,4 +1,5 @@ """Serializers tests""" + import pytest from rest_framework.serializers import ValidationError from social_core.backends.email import EmailAuth diff --git a/authentication/strategy.py b/authentication/strategy.py index 0968220f2..d89c50a68 100644 --- a/authentication/strategy.py +++ b/authentication/strategy.py @@ -1,4 +1,5 @@ """Custom strategy""" + from social_django.strategy import DjangoStrategy diff --git a/authentication/strategy_test.py b/authentication/strategy_test.py index 2f76d0408..683e75eab 100644 --- a/authentication/strategy_test.py +++ b/authentication/strategy_test.py @@ -1,4 +1,5 @@ """Tests for the strategy""" + from django.http import HttpRequest from rest_framework.request import Request diff --git a/authentication/urls.py b/authentication/urls.py index 35d267615..c26985fdf 100644 --- a/authentication/urls.py +++ b/authentication/urls.py @@ -1,4 +1,5 @@ """URL configurations for authentication""" + from django.urls import path from django.urls.conf import include diff --git a/authentication/utils.py b/authentication/utils.py index bb702bed0..a2c0f5197 100644 --- a/authentication/utils.py +++ b/authentication/utils.py @@ -1,4 +1,5 @@ """Authentication utils""" + import hashlib from social_core.utils import get_strategy diff --git a/authentication/utils_test.py b/authentication/utils_test.py index 1f9917d43..7fc4056eb 100644 --- a/authentication/utils_test.py +++ b/authentication/utils_test.py @@ -1,4 +1,5 @@ """Utils tests""" + from authentication.strategy import DjangoRestFrameworkStrategy from authentication.utils import load_drf_strategy diff --git a/authentication/views.py b/authentication/views.py index 0aef07d77..8a121fc77 100644 --- a/authentication/views.py +++ b/authentication/views.py @@ -1,4 +1,5 @@ """Authentication views""" + from urllib.parse import quote, urlencode, urljoin, urlparse import requests diff --git a/authentication/views_test.py b/authentication/views_test.py index d8d0595fb..511096663 100644 --- a/authentication/views_test.py +++ b/authentication/views_test.py @@ -1,4 +1,5 @@ """Tests for authentication views""" + from contextlib import ExitStack, contextmanager from unittest.mock import patch @@ -105,9 +106,10 @@ def noop(): @contextmanager def export_check_response(response_name): """Context manager for configuring export check responses""" - with override_settings( - **get_cybersource_test_settings() - ), responses.RequestsMock() as mocked_responses: + with ( + override_settings(**get_cybersource_test_settings()), + responses.RequestsMock() as mocked_responses, + ): mock_cybersource_wsdl(mocked_responses, settings) mock_cybersource_wsdl_operation(mocked_responses, response_name) yield @@ -264,14 +266,15 @@ def register_email_exists(self, recaptcha_enabled): def register_email_not_exists_with_recaptcha_invalid(self): """Yield a function for this step""" self.flow_started = True - with patch( - "authentication.views.requests.post", - return_value=MockResponse( - content='{"success": false, "error-codes": ["bad-request"]}', - status_code=status.HTTP_200_OK, - ), - ) as mock_recaptcha_failure, override_settings( - **{"RECAPTCHA_SITE_KEY": "fakse"} + with ( + patch( + "authentication.views.requests.post", + return_value=MockResponse( + content='{"success": false, "error-codes": ["bad-request"]}', + status_code=status.HTTP_200_OK, + ), + ) as mock_recaptcha_failure, + override_settings(**{"RECAPTCHA_SITE_KEY": "fakse"}), ): assert_api_call( self.client, @@ -449,9 +452,12 @@ def login_password_user_inactive(self, auth_state, verify_exports): @rule(auth_state=consumes(LoginPasswordAuthStates)) def login_password_exports_temporary_error(self, auth_state): """Login for a user who hasn't been OFAC verified yet""" - with override_settings(**get_cybersource_test_settings()), patch( - "authentication.pipeline.compliance.api.verify_user_with_exports", - side_effect=Exception("register_details_export_temporary_error"), + with ( + override_settings(**get_cybersource_test_settings()), + patch( + "authentication.pipeline.compliance.api.verify_user_with_exports", + side_effect=Exception("register_details_export_temporary_error"), + ), ): assert_api_call( self.client, @@ -646,9 +652,12 @@ def register_details_export_reject(self, auth_state): @rule(auth_state=consumes(ConfirmationRedeemedAuthStates)) def register_details_export_temporary_error(self, auth_state): """Complete the register confirmation details page with exports raising a temporary error""" - with override_settings(**get_cybersource_test_settings()), patch( - "authentication.pipeline.compliance.api.verify_user_with_exports", - side_effect=Exception("register_details_export_temporary_error"), + with ( + override_settings(**get_cybersource_test_settings()), + patch( + "authentication.pipeline.compliance.api.verify_user_with_exports", + side_effect=Exception("register_details_export_temporary_error"), + ), ): assert_api_call( self.client, diff --git a/b2b_ecommerce/admin_test.py b/b2b_ecommerce/admin_test.py index fcf52a94c..66f9ee6cb 100644 --- a/b2b_ecommerce/admin_test.py +++ b/b2b_ecommerce/admin_test.py @@ -1,4 +1,5 @@ """Tests for admin interface for b2b_ecommerce""" + import pytest from b2b_ecommerce.admin import B2BCouponAdmin, B2BOrderAdmin diff --git a/b2b_ecommerce/api.py b/b2b_ecommerce/api.py index 97aa4b6de..99d71ee1d 100644 --- a/b2b_ecommerce/api.py +++ b/b2b_ecommerce/api.py @@ -1,4 +1,5 @@ """Functions for b2b_ecommerce""" + import uuid from decimal import Decimal diff --git a/b2b_ecommerce/api_test.py b/b2b_ecommerce/api_test.py index b9db73c13..373317c3b 100644 --- a/b2b_ecommerce/api_test.py +++ b/b2b_ecommerce/api_test.py @@ -1,4 +1,5 @@ """Tests for b2b_ecommerce functions""" + from decimal import Decimal import faker diff --git a/b2b_ecommerce/apps.py b/b2b_ecommerce/apps.py index 9bb3ae721..c7ab696fe 100644 --- a/b2b_ecommerce/apps.py +++ b/b2b_ecommerce/apps.py @@ -1,4 +1,5 @@ """b2b_ecommerce app settings""" + from django.apps import AppConfig diff --git a/b2b_ecommerce/conftest.py b/b2b_ecommerce/conftest.py index 64a7a2b45..7b693590d 100644 --- a/b2b_ecommerce/conftest.py +++ b/b2b_ecommerce/conftest.py @@ -1,4 +1,5 @@ """Fixtures for b2b_ecommerce""" + from types import SimpleNamespace import pytest diff --git a/b2b_ecommerce/constants.py b/b2b_ecommerce/constants.py index 015f11677..da1ed7b19 100644 --- a/b2b_ecommerce/constants.py +++ b/b2b_ecommerce/constants.py @@ -1,3 +1,4 @@ """Constants for b2b_ecommerce""" + REFERENCE_NUMBER_PREFIX = "xpro-bulk-" B2B_ORDER_PREFIX = "XPRO-B2BORDER" diff --git a/b2b_ecommerce/factories.py b/b2b_ecommerce/factories.py index d532c9b9c..8c9d2a0f7 100644 --- a/b2b_ecommerce/factories.py +++ b/b2b_ecommerce/factories.py @@ -1,4 +1,5 @@ """Factories for b2b_ecommerce""" + from datetime import timezone import factory diff --git a/b2b_ecommerce/models.py b/b2b_ecommerce/models.py index b87e26b4d..9751f11c7 100644 --- a/b2b_ecommerce/models.py +++ b/b2b_ecommerce/models.py @@ -1,4 +1,5 @@ """Models for business to business ecommerce""" + import uuid from django.conf import settings diff --git a/b2b_ecommerce/models_test.py b/b2b_ecommerce/models_test.py index 5056f8698..b63048ed1 100644 --- a/b2b_ecommerce/models_test.py +++ b/b2b_ecommerce/models_test.py @@ -1,4 +1,5 @@ """models for b2b_ecommerce""" + from datetime import timedelta import pytest diff --git a/b2b_ecommerce/signals.py b/b2b_ecommerce/signals.py index 6c68c17c5..929a85667 100644 --- a/b2b_ecommerce/signals.py +++ b/b2b_ecommerce/signals.py @@ -1,4 +1,5 @@ """Signals for b2b_ecommerce models""" + from django.db.models.signals import post_save from django.dispatch import receiver diff --git a/b2b_ecommerce/urls.py b/b2b_ecommerce/urls.py index f25a7dabb..9b9b42307 100644 --- a/b2b_ecommerce/urls.py +++ b/b2b_ecommerce/urls.py @@ -1,4 +1,5 @@ """URLs for business to business ecommerce""" + from django.urls import path from b2b_ecommerce.views import ( diff --git a/b2b_ecommerce/views_test.py b/b2b_ecommerce/views_test.py index 9d38478b4..80122326a 100644 --- a/b2b_ecommerce/views_test.py +++ b/b2b_ecommerce/views_test.py @@ -1,4 +1,5 @@ """Views for b2b_ecommerce""" + import uuid from urllib.parse import urlencode, urljoin diff --git a/blog/api.py b/blog/api.py index f17249c7c..6f8b421ab 100644 --- a/blog/api.py +++ b/blog/api.py @@ -1,4 +1,5 @@ """API for the Blog app""" + import logging import requests diff --git a/blog/api_test.py b/blog/api_test.py index 850cce099..721f30db5 100644 --- a/blog/api_test.py +++ b/blog/api_test.py @@ -1,4 +1,5 @@ """Tests for Blog API""" + import pytest from blog.api import fetch_blog, parse_blog diff --git a/cms/api.py b/cms/api.py index 7f160b0ab..d0577f7ea 100644 --- a/cms/api.py +++ b/cms/api.py @@ -1,4 +1,5 @@ """API for the CMS app""" + import itertools import logging from datetime import MAXYEAR, datetime, timezone diff --git a/cms/api_test.py b/cms/api_test.py index a960cefa7..faa591923 100644 --- a/cms/api_test.py +++ b/cms/api_test.py @@ -1,4 +1,5 @@ """Tests for CMS API""" + from datetime import timedelta import pytest diff --git a/cms/blocks.py b/cms/blocks.py index cf498d635..735f4b1a8 100644 --- a/cms/blocks.py +++ b/cms/blocks.py @@ -1,6 +1,7 @@ """ Wagtail custom blocks for the CMS """ + from django import forms from django.apps import apps from django.core.exceptions import ValidationError diff --git a/cms/embeds_test.py b/cms/embeds_test.py index 69636fe7d..9a94bf644 100644 --- a/cms/embeds_test.py +++ b/cms/embeds_test.py @@ -1,4 +1,5 @@ """Tests for custom embed providers and finders""" + import pytest from django.core.exceptions import ImproperlyConfigured from wagtail.embeds.oembed_providers import vimeo diff --git a/cms/factories.py b/cms/factories.py index dd309b94e..0578dc0d9 100644 --- a/cms/factories.py +++ b/cms/factories.py @@ -1,4 +1,5 @@ """Wagtail page factories""" + import factory import faker import wagtail_factories diff --git a/cms/forms.py b/cms/forms.py index 5e7af2b9f..4d7cc2543 100644 --- a/cms/forms.py +++ b/cms/forms.py @@ -1,6 +1,7 @@ """ Custom forms for the cms """ + from django import forms from django.contrib.contenttypes.models import ContentType from wagtail.admin.forms import WagtailAdminPageForm @@ -44,12 +45,12 @@ def __init__(self, data=None, files=None, parent_page=None, *args, **kwargs): instance = kwargs.get("instance", None) if instance and instance.id: - if instance.is_internal_or_external_course_page: + if instance.is_internal_or_external_course_page and instance.course: course_runs = instance.course.courseruns.all() course_run_choices = [("", "")] + [(run.id, run) for run in course_runs] self.fields["course_run"].choices = course_run_choices - elif instance.is_internal_or_external_program_page: + elif instance.is_internal_or_external_program_page and instance.program: self.fields["price"].initial = instance.program.current_price def save(self, commit=True): # noqa: FBT002 diff --git a/cms/management/commands/configure_wagtail.py b/cms/management/commands/configure_wagtail.py index 8066164cb..1e6740260 100644 --- a/cms/management/commands/configure_wagtail.py +++ b/cms/management/commands/configure_wagtail.py @@ -1,4 +1,5 @@ """Management command to fully configure Wagtail""" + from django.core.management.base import BaseCommand from cms.api import configure_wagtail diff --git a/cms/management/commands/setup_index_pages.py b/cms/management/commands/setup_index_pages.py index 147f43923..8fe50bee1 100644 --- a/cms/management/commands/setup_index_pages.py +++ b/cms/management/commands/setup_index_pages.py @@ -1,4 +1,5 @@ """Management command to setup courseware index pages""" + from django.core.management.base import BaseCommand from cms.api import ensure_index_pages diff --git a/cms/migrations/0029_setup_course_program_index_pages.py b/cms/migrations/0029_setup_course_program_index_pages.py index 3cd687740..b9fd890c4 100644 --- a/cms/migrations/0029_setup_course_program_index_pages.py +++ b/cms/migrations/0029_setup_course_program_index_pages.py @@ -1,6 +1,7 @@ """ Data migrations moved to cms/migrations/0046_page_data_migrations.py in response to Page model change """ + from django.db import migrations diff --git a/cms/models.py b/cms/models.py index 54cdda606..823091208 100644 --- a/cms/models.py +++ b/cms/models.py @@ -1,6 +1,7 @@ """ Page models for the CMS """ + import re from collections import defaultdict from datetime import datetime, timedelta diff --git a/cms/models_test.py b/cms/models_test.py index be8f2beb7..5892462af 100644 --- a/cms/models_test.py +++ b/cms/models_test.py @@ -1,4 +1,5 @@ """Tests for cms pages.""" + import json from datetime import date, datetime, timedelta diff --git a/cms/template_tags_test.py b/cms/template_tags_test.py index b8d512efe..9be0195fe 100644 --- a/cms/template_tags_test.py +++ b/cms/template_tags_test.py @@ -1,4 +1,5 @@ """Tests for custom CMS templatetags""" + from urllib.parse import urljoin import pytest diff --git a/cms/urls.py b/cms/urls.py index 061566335..d8b4370f2 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -11,6 +11,7 @@ The pattern(s) defined here serve the same Wagtail view that the library-defined pattern serves. """ + from django.urls import re_path from wagtail import views from wagtail.coreutils import WAGTAIL_APPEND_SLASH diff --git a/cms/views_test.py b/cms/views_test.py index 5740283b9..c8fc58a8a 100644 --- a/cms/views_test.py +++ b/cms/views_test.py @@ -1,4 +1,5 @@ """Tests for CMS views""" + from datetime import datetime, timedelta from types import SimpleNamespace diff --git a/cms/wagtail_hooks.py b/cms/wagtail_hooks.py index faa6b77e0..9675f00a5 100644 --- a/cms/wagtail_hooks.py +++ b/cms/wagtail_hooks.py @@ -1,4 +1,5 @@ """Custom hooks to configure wagtail behavior""" + from wagtail import hooks from wagtail.admin.api.views import PagesAdminAPIViewSet diff --git a/compliance/api.py b/compliance/api.py index f27c8bd15..d8616882f 100644 --- a/compliance/api.py +++ b/compliance/api.py @@ -1,4 +1,5 @@ """Compliance API""" + import logging from collections import namedtuple diff --git a/compliance/api_test.py b/compliance/api_test.py index a1c51b22c..e3e6059bb 100644 --- a/compliance/api_test.py +++ b/compliance/api_test.py @@ -1,4 +1,5 @@ """Tests for compliance api""" + import time import pytest diff --git a/compliance/apps.py b/compliance/apps.py index 51b9ac621..70129f8ba 100644 --- a/compliance/apps.py +++ b/compliance/apps.py @@ -1,4 +1,5 @@ """Compliance app""" + from django.apps import AppConfig diff --git a/compliance/factories.py b/compliance/factories.py index 65de7686f..01df6d915 100644 --- a/compliance/factories.py +++ b/compliance/factories.py @@ -1,4 +1,5 @@ """Factories for compliance app""" + from factory import Faker, SubFactory, Trait from factory.django import DjangoModelFactory from factory.fuzzy import FuzzyChoice diff --git a/compliance/management/commands/decrypt_exports_inquiry.py b/compliance/management/commands/decrypt_exports_inquiry.py index 5a03c1d86..31d41d41d 100644 --- a/compliance/management/commands/decrypt_exports_inquiry.py +++ b/compliance/management/commands/decrypt_exports_inquiry.py @@ -1,6 +1,7 @@ """ Management command to decrypts a user's ExportInquiryLog record """ + import sys from django.contrib.auth import get_user_model diff --git a/compliance/models.py b/compliance/models.py index 78e126b0c..6ec171e6b 100644 --- a/compliance/models.py +++ b/compliance/models.py @@ -1,4 +1,5 @@ """Compliance app models""" + from django.conf import settings from django.db import models diff --git a/compliance/test_utils.py b/compliance/test_utils.py index e683ee61a..0d950bad0 100644 --- a/compliance/test_utils.py +++ b/compliance/test_utils.py @@ -1,4 +1,5 @@ """Testing utils around CyberSource""" + from nacl.encoding import Base64Encoder from nacl.public import PrivateKey from rest_framework import status diff --git a/conftest.py b/conftest.py index d14f5e9f0..97f57847f 100644 --- a/conftest.py +++ b/conftest.py @@ -1,4 +1,5 @@ """Project conftest""" + import os import shutil diff --git a/courses/api_test.py b/courses/api_test.py index 8e89d80bb..7944c46c3 100644 --- a/courses/api_test.py +++ b/courses/api_test.py @@ -1,4 +1,5 @@ """Courses API tests""" + import contextlib from datetime import timedelta from types import SimpleNamespace @@ -221,9 +222,11 @@ def test_create_run_enrollments_enroll_api_fail( successful_enrollments = [] edx_request_success = False - with pytest.raises( - EdxEnrollmentCreateError - ) if not keep_failed_enrollments else contextlib.suppress(): # noqa: B022 + with ( + pytest.raises(EdxEnrollmentCreateError) + if not keep_failed_enrollments + else contextlib.suppress() + ): # noqa: B022 successful_enrollments, edx_request_success = create_run_enrollments( user, runs, diff --git a/courses/apps.py b/courses/apps.py index 0d2b0040d..4bbf7e93a 100644 --- a/courses/apps.py +++ b/courses/apps.py @@ -1,6 +1,7 @@ """ Django App """ + from django.apps import AppConfig diff --git a/courses/constants_test.py b/courses/constants_test.py index 4f0f6bb58..4f4bb6d5b 100644 --- a/courses/constants_test.py +++ b/courses/constants_test.py @@ -1,4 +1,5 @@ """Tests for courses constants""" + import pytest from django.contrib.contenttypes.models import ContentType diff --git a/courses/credentials.py b/courses/credentials.py index fbe950113..cafcf2ed7 100644 --- a/courses/credentials.py +++ b/courses/credentials.py @@ -1,4 +1,5 @@ """Digital courseware credentials""" + import logging from typing import Union from urllib.parse import urljoin diff --git a/courses/credentials_test.py b/courses/credentials_test.py index 93a05af02..3a46f671a 100644 --- a/courses/credentials_test.py +++ b/courses/credentials_test.py @@ -1,4 +1,5 @@ """Credentials tests""" + from urllib.parse import urljoin import pytest diff --git a/courses/factories.py b/courses/factories.py index 4d0875e63..b14a49fbf 100644 --- a/courses/factories.py +++ b/courses/factories.py @@ -1,4 +1,5 @@ """Factories for creating course data in tests""" + from datetime import timezone import factory diff --git a/courses/management/commands/backfill_program_runs.py b/courses/management/commands/backfill_program_runs.py index a79918104..5122e5884 100644 --- a/courses/management/commands/backfill_program_runs.py +++ b/courses/management/commands/backfill_program_runs.py @@ -1,4 +1,5 @@ """Management command to create program runs for programs that have a complete sets of course runs""" + import re from collections import defaultdict diff --git a/courses/management/commands/create_enrollment.py b/courses/management/commands/create_enrollment.py index b38aafb42..734e0e151 100644 --- a/courses/management/commands/create_enrollment.py +++ b/courses/management/commands/create_enrollment.py @@ -1,4 +1,5 @@ """Management command to change enrollment status""" + from django.contrib.auth import get_user_model from django.core.management.base import BaseCommand, CommandError from django.db import transaction diff --git a/courses/management/commands/defer_enrollment.py b/courses/management/commands/defer_enrollment.py index 4b49e0687..a895314e5 100644 --- a/courses/management/commands/defer_enrollment.py +++ b/courses/management/commands/defer_enrollment.py @@ -1,4 +1,5 @@ """Management command to change enrollment status""" + from django.contrib.auth import get_user_model from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.management.base import CommandError diff --git a/courses/management/commands/manage_program_certificates.py b/courses/management/commands/manage_program_certificates.py index bdf671112..f6e12a492 100644 --- a/courses/management/commands/manage_program_certificates.py +++ b/courses/management/commands/manage_program_certificates.py @@ -7,6 +7,7 @@ You must specify --program, since that will be used to filter programs for certificate generation """ + from django.core.management.base import BaseCommand, CommandError from django.db.models import Q diff --git a/courses/management/commands/refund_enrollment.py b/courses/management/commands/refund_enrollment.py index f0e32fb12..0b546851b 100644 --- a/courses/management/commands/refund_enrollment.py +++ b/courses/management/commands/refund_enrollment.py @@ -1,4 +1,5 @@ """Management command to change enrollment status""" + from django.contrib.auth import get_user_model from courses.api import deactivate_program_enrollment, deactivate_run_enrollment diff --git a/courses/management/commands/revoke_certificate.py b/courses/management/commands/revoke_certificate.py index d9128cafa..4fad63477 100644 --- a/courses/management/commands/revoke_certificate.py +++ b/courses/management/commands/revoke_certificate.py @@ -1,6 +1,7 @@ """ Management command to revoke and un revoke a certificate for a course run or program for the given user. """ + from django.core.management.base import BaseCommand, CommandError from courses.utils import revoke_course_run_certificate, revoke_program_certificate diff --git a/courses/management/commands/sync_courseruns.py b/courses/management/commands/sync_courseruns.py index 03ecc4d0e..9d3afb936 100644 --- a/courses/management/commands/sync_courseruns.py +++ b/courses/management/commands/sync_courseruns.py @@ -1,6 +1,7 @@ """ Management command to sync dates and title for all or a specific course run from edX """ + from django.core.management.base import BaseCommand, CommandError from django.db.models import Q diff --git a/courses/management/commands/sync_grades_and_certificates.py b/courses/management/commands/sync_grades_and_certificates.py index 823ceeba2..df88c7be0 100644 --- a/courses/management/commands/sync_grades_and_certificates.py +++ b/courses/management/commands/sync_grades_and_certificates.py @@ -1,6 +1,7 @@ """ Management command to sync grades and certificates for a course run """ + from django.core.management.base import BaseCommand, CommandError from courses.models import CourseRun diff --git a/courses/management/commands/transfer_enrollment.py b/courses/management/commands/transfer_enrollment.py index 745f76790..d4d781d7d 100644 --- a/courses/management/commands/transfer_enrollment.py +++ b/courses/management/commands/transfer_enrollment.py @@ -1,4 +1,5 @@ """Management command to change enrollment status""" + from django.contrib.auth import get_user_model from django.core.management.base import CommandError diff --git a/courses/management/utils.py b/courses/management/utils.py index 58f43212a..81a51cea9 100644 --- a/courses/management/utils.py +++ b/courses/management/utils.py @@ -1,4 +1,5 @@ """Utility functions/classes for course management commands""" + from django.core.management.base import BaseCommand, CommandError from courses.models import CourseRun, CourseRunEnrollment, Program, ProgramEnrollment diff --git a/courses/management/utils_test.py b/courses/management/utils_test.py index 0c4cd1c81..771b12e08 100644 --- a/courses/management/utils_test.py +++ b/courses/management/utils_test.py @@ -1,4 +1,5 @@ """Tests for command utils""" + from datetime import timedelta import pytest diff --git a/courses/migrations/0012_backpopulate_readable_id.py b/courses/migrations/0012_backpopulate_readable_id.py index 745f445eb..62604cefb 100644 --- a/courses/migrations/0012_backpopulate_readable_id.py +++ b/courses/migrations/0012_backpopulate_readable_id.py @@ -2,6 +2,7 @@ Data migration to ensure that all Courses and Programs have a readable_id before setting the field to required and unique """ + from django.db import migrations from django.utils.text import slugify diff --git a/courses/models.py b/courses/models.py index 8607a2a76..3079244f8 100644 --- a/courses/models.py +++ b/courses/models.py @@ -1,6 +1,7 @@ """ Course models """ + import logging import operator as op import uuid diff --git a/courses/models_test.py b/courses/models_test.py index 9cdc36e9e..617e277fb 100644 --- a/courses/models_test.py +++ b/courses/models_test.py @@ -1,4 +1,5 @@ """Tests for course models""" + from datetime import timedelta import factory diff --git a/courses/serializers.py b/courses/serializers.py index 7118a52ad..a56590a70 100644 --- a/courses/serializers.py +++ b/courses/serializers.py @@ -1,6 +1,7 @@ """ Course model serializers """ + from urllib.parse import urljoin from django.conf import settings diff --git a/courses/serializers_test.py b/courses/serializers_test.py index 762d5b679..f7972b29f 100644 --- a/courses/serializers_test.py +++ b/courses/serializers_test.py @@ -1,6 +1,7 @@ """ Tests for course serializers """ + from datetime import datetime, timedelta, timezone import factory diff --git a/courses/signals.py b/courses/signals.py index 7b979afe9..9fa44034d 100644 --- a/courses/signals.py +++ b/courses/signals.py @@ -1,6 +1,7 @@ """ Signals for micromasters course certificates """ + from django.db import transaction from django.db.models.signals import post_save from django.dispatch import receiver diff --git a/courses/signals_test.py b/courses/signals_test.py index 801f3f441..549405758 100644 --- a/courses/signals_test.py +++ b/courses/signals_test.py @@ -1,6 +1,7 @@ """ Tests for signals """ + from unittest.mock import patch import pytest diff --git a/courses/tasks.py b/courses/tasks.py index 5d482cb54..b65db55eb 100644 --- a/courses/tasks.py +++ b/courses/tasks.py @@ -1,6 +1,7 @@ """ Tasks for the courses app """ + import logging from datetime import timedelta diff --git a/courses/urls.py b/courses/urls.py index e18910851..83f18942d 100644 --- a/courses/urls.py +++ b/courses/urls.py @@ -1,4 +1,5 @@ """Course API URL routes""" + from django.urls import include, path, re_path from rest_framework import routers diff --git a/courses/utils.py b/courses/utils.py index 90c47d006..9b7610ffb 100644 --- a/courses/utils.py +++ b/courses/utils.py @@ -1,6 +1,7 @@ """ Utilities for courses/certificates """ + import logging from django.conf import settings diff --git a/courses/utils_test.py b/courses/utils_test.py index f9f1919b0..8234ba331 100644 --- a/courses/utils_test.py +++ b/courses/utils_test.py @@ -1,6 +1,7 @@ """ Tests for signals """ + from unittest.mock import Mock import pytest diff --git a/courses/views/v1/__init__.py b/courses/views/v1/__init__.py index a6185902d..6fab8519f 100644 --- a/courses/views/v1/__init__.py +++ b/courses/views/v1/__init__.py @@ -1,4 +1,5 @@ """Course views verson 1""" + from django.db.models import Prefetch, Q from mitol.digitalcredentials.mixins import DigitalCredentialsRequestViewSetMixin from rest_framework import status, viewsets diff --git a/courses/views_test.py b/courses/views_test.py index 47bc27e8c..b65581c23 100644 --- a/courses/views_test.py +++ b/courses/views_test.py @@ -1,6 +1,7 @@ """ Tests for course views """ + import operator as op from datetime import timedelta diff --git a/courses/wagtail_hooks.py b/courses/wagtail_hooks.py index 8daa7d464..fe1540889 100644 --- a/courses/wagtail_hooks.py +++ b/courses/wagtail_hooks.py @@ -1,4 +1,5 @@ """Wagtail hooks for courses app""" + from wagtail import hooks from courses.wagtail_views import CourseTopicViewSet diff --git a/courses/wagtail_views.py b/courses/wagtail_views.py index 7d08ce47f..9ac16486c 100644 --- a/courses/wagtail_views.py +++ b/courses/wagtail_views.py @@ -1,4 +1,5 @@ """Wagtail admin views""" + from wagtail.admin.viewsets.model import ModelViewSet from courses.models import CourseTopic diff --git a/courseware/api.py b/courseware/api.py index 763c4f56f..fdb7074d9 100644 --- a/courseware/api.py +++ b/courseware/api.py @@ -1,4 +1,5 @@ """Courseware API functions""" + import logging from dataclasses import dataclass from datetime import timedelta diff --git a/courseware/api_test.py b/courseware/api_test.py index 1681690fe..a80bbed87 100644 --- a/courseware/api_test.py +++ b/courseware/api_test.py @@ -1,4 +1,5 @@ """Courseware API tests""" + import itertools from datetime import timedelta from types import SimpleNamespace diff --git a/courseware/apps.py b/courseware/apps.py index d361d4c2b..8ece6666e 100644 --- a/courseware/apps.py +++ b/courseware/apps.py @@ -1,4 +1,5 @@ """Courseware Django app""" + from django.apps import AppConfig diff --git a/courseware/exceptions.py b/courseware/exceptions.py index 61829aaa8..16d73d486 100644 --- a/courseware/exceptions.py +++ b/courseware/exceptions.py @@ -1,4 +1,5 @@ """Courseware exceptions""" + from mitxpro.utils import get_error_response_summary diff --git a/courseware/factories.py b/courseware/factories.py index d63ead088..4aeb3d0cb 100644 --- a/courseware/factories.py +++ b/courseware/factories.py @@ -1,4 +1,5 @@ """Courseware factories""" + from datetime import timedelta, timezone from factory import Faker, LazyAttribute, SubFactory, Trait diff --git a/courseware/management/commands/repair_missing_courseware_records.py b/courseware/management/commands/repair_missing_courseware_records.py index 3bfe2b2ac..df66edf2a 100644 --- a/courseware/management/commands/repair_missing_courseware_records.py +++ b/courseware/management/commands/repair_missing_courseware_records.py @@ -1,6 +1,7 @@ """ Management command to repair missing courseware records """ + from django.contrib.auth import get_user_model from django.core.management import BaseCommand from requests.exceptions import HTTPError diff --git a/courseware/management/commands/retry_edx_enrollment.py b/courseware/management/commands/retry_edx_enrollment.py index a53ce9a4a..f53c4887c 100644 --- a/courseware/management/commands/retry_edx_enrollment.py +++ b/courseware/management/commands/retry_edx_enrollment.py @@ -1,6 +1,7 @@ """ Management command to retry edX enrollment for a user's course run enrollments """ + from django.contrib.auth import get_user_model from django.core.management import BaseCommand diff --git a/courseware/migrations/0001_add_oauth_application.py b/courseware/migrations/0001_add_oauth_application.py index f6bd223a5..db080e94c 100644 --- a/courseware/migrations/0001_add_oauth_application.py +++ b/courseware/migrations/0001_add_oauth_application.py @@ -1,4 +1,5 @@ """This migration has been moved into seed_data command. The Application model keeps on changing over time hance breaking this migration on fresh installations""" + from django.db import migrations diff --git a/courseware/models.py b/courseware/models.py index 450028d54..7f39bae1a 100644 --- a/courseware/models.py +++ b/courseware/models.py @@ -1,4 +1,5 @@ """Courseware models""" + from django.conf import settings from django.db import models diff --git a/courseware/tasks.py b/courseware/tasks.py index ffea4dac6..67379cb1d 100644 --- a/courseware/tasks.py +++ b/courseware/tasks.py @@ -1,4 +1,5 @@ """Courseware tasks""" + from courseware import api from mitxpro.celery import app from users.api import get_user_by_id diff --git a/courseware/tasks_test.py b/courseware/tasks_test.py index b09ae5d71..780c29d93 100644 --- a/courseware/tasks_test.py +++ b/courseware/tasks_test.py @@ -1,4 +1,5 @@ """Courseware tasks""" + import pytest from courseware import tasks diff --git a/courseware/urls.py b/courseware/urls.py index 8692e141d..9dac435c0 100644 --- a/courseware/urls.py +++ b/courseware/urls.py @@ -1,4 +1,5 @@ """Courseware urls""" + from django.urls import path from courseware import views diff --git a/courseware/utils.py b/courseware/utils.py index 633eff72e..2dd1b1bcb 100644 --- a/courseware/utils.py +++ b/courseware/utils.py @@ -1,4 +1,5 @@ """Utility functions for the courseware app""" + from urllib.parse import urljoin from django.conf import settings diff --git a/courseware/views.py b/courseware/views.py index b57d40ba0..1fb9eb6e5 100644 --- a/courseware/views.py +++ b/courseware/views.py @@ -1,4 +1,5 @@ """Views for courseware""" + from django.http import HttpResponse from rest_framework import status diff --git a/courseware/views_test.py b/courseware/views_test.py index 35c07641b..ba1c48e5f 100644 --- a/courseware/views_test.py +++ b/courseware/views_test.py @@ -1,4 +1,5 @@ """Test courseware views""" + import pytest from django.shortcuts import reverse from rest_framework import status diff --git a/docker-compose.yml b/docker-compose.yml index 9596c87ec..12bb74db4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,7 +38,7 @@ services: - "6379" nginx: - image: nginx:1.25.5 + image: nginx:1.26.0 ports: - "8053:8053" links: diff --git a/ecommerce/admin.py b/ecommerce/admin.py index c7bcfa1d5..5af42c220 100644 --- a/ecommerce/admin.py +++ b/ecommerce/admin.py @@ -1,4 +1,5 @@ """admin classes for ecommerce""" + from django import forms from django.contrib import admin from django.contrib.contenttypes.models import ContentType diff --git a/ecommerce/admin_test.py b/ecommerce/admin_test.py index d7bb6bf88..56a1cfa2b 100644 --- a/ecommerce/admin_test.py +++ b/ecommerce/admin_test.py @@ -1,4 +1,5 @@ """tests for admin classes""" + import pytest from courses.factories import CourseFactory diff --git a/ecommerce/api.py b/ecommerce/api.py index 776634585..1c6c23ca3 100644 --- a/ecommerce/api.py +++ b/ecommerce/api.py @@ -1,6 +1,7 @@ """ Functions for ecommerce """ + import decimal import hashlib import hmac diff --git a/ecommerce/api_test.py b/ecommerce/api_test.py index 6025a0b5d..6a1440344 100644 --- a/ecommerce/api_test.py +++ b/ecommerce/api_test.py @@ -1,6 +1,7 @@ """ Test for ecommerce functions """ + import hashlib import hmac import ipaddress diff --git a/ecommerce/apps.py b/ecommerce/apps.py index a042e478e..fe6cf9cf6 100644 --- a/ecommerce/apps.py +++ b/ecommerce/apps.py @@ -1,4 +1,5 @@ """ecommerce app settings""" + from django.apps import AppConfig diff --git a/ecommerce/conftest.py b/ecommerce/conftest.py index 01d4e9b94..5641d2fd3 100644 --- a/ecommerce/conftest.py +++ b/ecommerce/conftest.py @@ -1,4 +1,5 @@ """fixtures for ecommerce tests""" + from collections import namedtuple from decimal import Decimal from types import SimpleNamespace diff --git a/ecommerce/factories.py b/ecommerce/factories.py index 959eaf2d8..ffa8ed97a 100644 --- a/ecommerce/factories.py +++ b/ecommerce/factories.py @@ -1,6 +1,7 @@ """ Factories for ecommerce models """ + from datetime import timezone import faker diff --git a/ecommerce/filters.py b/ecommerce/filters.py index a66a25493..28412938d 100644 --- a/ecommerce/filters.py +++ b/ecommerce/filters.py @@ -1,4 +1,5 @@ """Ecommerce filters""" + from django_filters import rest_framework as filters from courses.constants import VALID_PRODUCT_TYPE_CHOICES diff --git a/ecommerce/mail_api.py b/ecommerce/mail_api.py index 963f1c8d4..006be10a6 100644 --- a/ecommerce/mail_api.py +++ b/ecommerce/mail_api.py @@ -1,4 +1,5 @@ """Ecommerce mail API""" + import logging from urllib.parse import urlencode, urljoin diff --git a/ecommerce/mail_api_test.py b/ecommerce/mail_api_test.py index d3d62029d..a89258346 100644 --- a/ecommerce/mail_api_test.py +++ b/ecommerce/mail_api_test.py @@ -1,4 +1,5 @@ """Ecommerce mail API tests""" + import datetime from urllib.parse import quote_plus, urljoin diff --git a/ecommerce/models.py b/ecommerce/models.py index bae5d4a3b..36babae34 100644 --- a/ecommerce/models.py +++ b/ecommerce/models.py @@ -1,4 +1,5 @@ """Models for ecommerce""" + import logging from decimal import Decimal diff --git a/ecommerce/models_test.py b/ecommerce/models_test.py index d32cde9ae..3c7de86fc 100644 --- a/ecommerce/models_test.py +++ b/ecommerce/models_test.py @@ -1,4 +1,5 @@ """Tests for ecommerce models""" + import pytest from django.core.exceptions import ValidationError from django.db.utils import IntegrityError diff --git a/ecommerce/permissions.py b/ecommerce/permissions.py index b3c24b6ac..587ff5447 100644 --- a/ecommerce/permissions.py +++ b/ecommerce/permissions.py @@ -1,4 +1,5 @@ """Permission classes for ecommerce""" + import logging from rest_framework.permissions import BasePermission diff --git a/ecommerce/permissions_test.py b/ecommerce/permissions_test.py index a18ca045c..3ad90edc7 100644 --- a/ecommerce/permissions_test.py +++ b/ecommerce/permissions_test.py @@ -1,6 +1,7 @@ """ Tests for ecommerce permissions """ + from ecommerce.api import generate_cybersource_sa_signature from ecommerce.permissions import IsSignedByCyberSource diff --git a/ecommerce/serializers.py b/ecommerce/serializers.py index b9d798409..3702ae12f 100644 --- a/ecommerce/serializers.py +++ b/ecommerce/serializers.py @@ -1,4 +1,5 @@ """ecommerce serializers""" + import logging from decimal import Decimal @@ -960,9 +961,9 @@ def get_receipt(self, instance): "req_bill_to_forename" in receipt.data or "req_bill_to_surname" in receipt.data ): - data[ - "name" - ] = f"{receipt.data.get('req_bill_to_forename')} {receipt.data.get('req_bill_to_surname')}" + data["name"] = ( + f"{receipt.data.get('req_bill_to_forename')} {receipt.data.get('req_bill_to_surname')}" + ) return data return None diff --git a/ecommerce/serializers_test.py b/ecommerce/serializers_test.py index be83f594a..3f3adeed4 100644 --- a/ecommerce/serializers_test.py +++ b/ecommerce/serializers_test.py @@ -1,6 +1,7 @@ """ Tests for ecommerce serializers """ + from decimal import Decimal import pytest diff --git a/ecommerce/signals.py b/ecommerce/signals.py index 2f66f2a18..022ad4241 100644 --- a/ecommerce/signals.py +++ b/ecommerce/signals.py @@ -1,4 +1,5 @@ """Signals for ecommerce models""" + from django.db.models.signals import post_save from django.dispatch import receiver diff --git a/ecommerce/signals_test.py b/ecommerce/signals_test.py index f93254e98..080ec3cfb 100644 --- a/ecommerce/signals_test.py +++ b/ecommerce/signals_test.py @@ -1,6 +1,7 @@ """ Tests for signals """ + import pytest from courses.factories import CourseFactory, CourseRunFactory diff --git a/ecommerce/test_utils.py b/ecommerce/test_utils.py index 2fd26a4bb..cbea7ecac 100644 --- a/ecommerce/test_utils.py +++ b/ecommerce/test_utils.py @@ -1,4 +1,5 @@ """Functions used in testing ecommerce""" + from contextlib import contextmanager import faker diff --git a/ecommerce/urls.py b/ecommerce/urls.py index 360b564c6..6a87a8d6e 100644 --- a/ecommerce/urls.py +++ b/ecommerce/urls.py @@ -1,4 +1,5 @@ """URLs for ecommerce""" + from django.urls import include, path, re_path from rest_framework.routers import SimpleRouter diff --git a/ecommerce/utils.py b/ecommerce/utils.py index 9a94251fe..51eefb01c 100644 --- a/ecommerce/utils.py +++ b/ecommerce/utils.py @@ -1,4 +1,5 @@ """Utility functions for ecommerce""" + import logging from urllib.parse import urlencode, urljoin diff --git a/ecommerce/utils_test.py b/ecommerce/utils_test.py index ac4de594d..802e790ac 100644 --- a/ecommerce/utils_test.py +++ b/ecommerce/utils_test.py @@ -1,4 +1,5 @@ """Tests for utility functions for ecommerce""" + from urllib.parse import urljoin import pytest diff --git a/ecommerce/views.py b/ecommerce/views.py index adfbae27f..600927654 100644 --- a/ecommerce/views.py +++ b/ecommerce/views.py @@ -1,4 +1,5 @@ """Views for ecommerce""" + import logging from urllib.parse import urljoin diff --git a/ecommerce/views_test.py b/ecommerce/views_test.py index cc16fa5b1..3c712d7d2 100644 --- a/ecommerce/views_test.py +++ b/ecommerce/views_test.py @@ -1,4 +1,5 @@ """ecommerce tests for views""" + import json from datetime import datetime, timedelta, timezone from urllib.parse import quote_plus, urljoin diff --git a/ecommerce/wagtail_hooks.py b/ecommerce/wagtail_hooks.py index 2b3125636..80e3c7d2a 100644 --- a/ecommerce/wagtail_hooks.py +++ b/ecommerce/wagtail_hooks.py @@ -1,4 +1,5 @@ """Wagtail hooks for courses app""" + from wagtail import hooks from ecommerce.wagtail_views import ProductViewSetGroup diff --git a/ecommerce/wagtail_views.py b/ecommerce/wagtail_views.py index c8bc61e63..93841f687 100644 --- a/ecommerce/wagtail_views.py +++ b/ecommerce/wagtail_views.py @@ -1,4 +1,5 @@ """Wagtail admin views""" + from wagtail.admin.views.generic.models import IndexView, InspectView from wagtail.admin.viewsets.base import ViewSetGroup from wagtail.admin.viewsets.model import ModelViewSet diff --git a/fixtures/autouse.py b/fixtures/autouse.py index 893353124..48859038f 100644 --- a/fixtures/autouse.py +++ b/fixtures/autouse.py @@ -1,4 +1,5 @@ """Fixtures that will be used by default""" + import pytest diff --git a/hubspot_xpro/api.py b/hubspot_xpro/api.py index 29a3422ab..8dee2712f 100644 --- a/hubspot_xpro/api.py +++ b/hubspot_xpro/api.py @@ -1,4 +1,5 @@ """Generate Hubspot message bodies for various model objects""" + import logging import re from decimal import Decimal diff --git a/hubspot_xpro/api_test.py b/hubspot_xpro/api_test.py index 33be1e1a5..43ea3df28 100644 --- a/hubspot_xpro/api_test.py +++ b/hubspot_xpro/api_test.py @@ -1,4 +1,5 @@ """Tests for hubspot_xpro.api""" + import pytest from django.contrib.contenttypes.models import ContentType from mitol.hubspot_api.factories import HubspotObjectFactory, SimplePublicObjectFactory diff --git a/hubspot_xpro/conftest.py b/hubspot_xpro/conftest.py index 1bed44be9..93d0fe047 100644 --- a/hubspot_xpro/conftest.py +++ b/hubspot_xpro/conftest.py @@ -1,6 +1,7 @@ """ Fixtures for hubspot_xpro tests """ + from datetime import datetime, timezone from types import SimpleNamespace diff --git a/hubspot_xpro/management/commands/configure_hubspot_properties.py b/hubspot_xpro/management/commands/configure_hubspot_properties.py index 4be4824b0..b89e2083f 100644 --- a/hubspot_xpro/management/commands/configure_hubspot_properties.py +++ b/hubspot_xpro/management/commands/configure_hubspot_properties.py @@ -1,6 +1,7 @@ """ Management command to configure custom Hubspot properties for Contacts, Deals, Products, and Line Items """ + import sys from django.core.management import BaseCommand diff --git a/hubspot_xpro/management/commands/sync_db_to_hubspot.py b/hubspot_xpro/management/commands/sync_db_to_hubspot.py index c80ad32bb..886c05d0d 100644 --- a/hubspot_xpro/management/commands/sync_db_to_hubspot.py +++ b/hubspot_xpro/management/commands/sync_db_to_hubspot.py @@ -2,6 +2,7 @@ Management command to sync all Users, Orders, Products, and Lines with Hubspot and Line Items """ + import sys from django.contrib.contenttypes.models import ContentType diff --git a/hubspot_xpro/management/commands/sync_hubspot_ids_to_db.py b/hubspot_xpro/management/commands/sync_hubspot_ids_to_db.py index 944037b80..10d392e2a 100644 --- a/hubspot_xpro/management/commands/sync_hubspot_ids_to_db.py +++ b/hubspot_xpro/management/commands/sync_hubspot_ids_to_db.py @@ -1,6 +1,7 @@ """ Management command to sync hubspot ids to database """ + import sys from django.contrib.contenttypes.models import ContentType diff --git a/hubspot_xpro/serializers.py b/hubspot_xpro/serializers.py index 6b80ddca6..07f1f425d 100644 --- a/hubspot_xpro/serializers.py +++ b/hubspot_xpro/serializers.py @@ -1,4 +1,5 @@ """Serializers for HubSpot""" + from django.conf import settings from mitol.hubspot_api.api import format_app_id from rest_framework import serializers diff --git a/hubspot_xpro/task_helpers.py b/hubspot_xpro/task_helpers.py index c40418f3d..ee615331e 100644 --- a/hubspot_xpro/task_helpers.py +++ b/hubspot_xpro/task_helpers.py @@ -1,4 +1,5 @@ """Task helper functions for ecommerce""" + from django.conf import settings from ecommerce.models import Order diff --git a/hubspot_xpro/tasks.py b/hubspot_xpro/tasks.py index b0c1fd24b..562113196 100644 --- a/hubspot_xpro/tasks.py +++ b/hubspot_xpro/tasks.py @@ -1,6 +1,7 @@ """ Hubspot tasks """ + import logging import time from math import ceil diff --git a/hubspot_xpro/tasks_test.py b/hubspot_xpro/tasks_test.py index c2e13345d..24783b19a 100644 --- a/hubspot_xpro/tasks_test.py +++ b/hubspot_xpro/tasks_test.py @@ -1,6 +1,7 @@ """ Tests for hubspot_xpro tasks """ + from decimal import Decimal from math import ceil diff --git a/localdev/seed/api.py b/localdev/seed/api.py index 68ca65ce1..e497845a0 100644 --- a/localdev/seed/api.py +++ b/localdev/seed/api.py @@ -1,4 +1,5 @@ """Functions/classes for adding and removing seed data""" + import datetime import json import os diff --git a/localdev/seed/api_test.py b/localdev/seed/api_test.py index fcc8509f8..eda1acfe4 100644 --- a/localdev/seed/api_test.py +++ b/localdev/seed/api_test.py @@ -1,4 +1,5 @@ """Seed data API tests""" + from types import SimpleNamespace import pytest diff --git a/localdev/seed/management/commands/delete_seed_data.py b/localdev/seed/management/commands/delete_seed_data.py index 75bc7c2cb..3d2ca7ff6 100644 --- a/localdev/seed/management/commands/delete_seed_data.py +++ b/localdev/seed/management/commands/delete_seed_data.py @@ -1,4 +1,5 @@ """Management command to delete seeded data""" + from django.contrib.auth import get_user_model from django.core.management.base import BaseCommand, CommandError diff --git a/localdev/seed/management/commands/seed_data.py b/localdev/seed/management/commands/seed_data.py index 667296583..07a0ea7eb 100644 --- a/localdev/seed/management/commands/seed_data.py +++ b/localdev/seed/management/commands/seed_data.py @@ -1,4 +1,5 @@ """Management command to create or update seed data""" + from django.contrib.auth import get_user_model from django.core.management.base import BaseCommand diff --git a/localdev/seed/serializers.py b/localdev/seed/serializers.py index 59d82394a..44cee751f 100644 --- a/localdev/seed/serializers.py +++ b/localdev/seed/serializers.py @@ -1,6 +1,7 @@ """ Course model serializers """ + from rest_framework import serializers from courses import models diff --git a/mail/api.py b/mail/api.py index f8c928afb..c3caf5a6b 100644 --- a/mail/api.py +++ b/mail/api.py @@ -18,6 +18,7 @@ # send the emails send_messages(messages) """ + import logging import re from collections import namedtuple diff --git a/mail/api_test.py b/mail/api_test.py index 8277f707a..51f5a35ea 100644 --- a/mail/api_test.py +++ b/mail/api_test.py @@ -1,4 +1,5 @@ """API tests""" + from email.utils import formataddr import pytest diff --git a/mail/apps.py b/mail/apps.py index 4b41e0aaa..cda16f3e2 100644 --- a/mail/apps.py +++ b/mail/apps.py @@ -1,4 +1,5 @@ """Mail apps""" + from django.apps import AppConfig diff --git a/mail/forms.py b/mail/forms.py index 2048b8a9c..681e7990b 100644 --- a/mail/forms.py +++ b/mail/forms.py @@ -1,4 +1,5 @@ """Mail forms""" + from django import forms from mail.constants import EMAIL_TYPE_DESCRIPTIONS diff --git a/mail/templatetags/calculate_tax.py b/mail/templatetags/calculate_tax.py index 21ed90fb2..18f46837e 100644 --- a/mail/templatetags/calculate_tax.py +++ b/mail/templatetags/calculate_tax.py @@ -1,4 +1,5 @@ """Calculate tax charged for an item""" + from decimal import Decimal from django import template diff --git a/mail/templatetags/calculate_tax_total.py b/mail/templatetags/calculate_tax_total.py index 20b490c7e..91b0fb956 100644 --- a/mail/templatetags/calculate_tax_total.py +++ b/mail/templatetags/calculate_tax_total.py @@ -1,4 +1,5 @@ """Calculate tax charged for an item""" + from decimal import Decimal from django import template diff --git a/mail/templatetags/format_discount.py b/mail/templatetags/format_discount.py index 4dcd0643b..b41cd27da 100644 --- a/mail/templatetags/format_discount.py +++ b/mail/templatetags/format_discount.py @@ -1,4 +1,5 @@ """Custom template tags for email""" + from decimal import Decimal from django import template diff --git a/mail/templatetags/timeago.py b/mail/templatetags/timeago.py index c9682365d..3f139f661 100644 --- a/mail/templatetags/timeago.py +++ b/mail/templatetags/timeago.py @@ -1,4 +1,5 @@ """Custom template tags for email""" + from dateutil.parser import parse from django import template diff --git a/mail/urls.py b/mail/urls.py index 7054a2404..55575c408 100644 --- a/mail/urls.py +++ b/mail/urls.py @@ -1,4 +1,5 @@ """URL configurations for mail""" + from django.conf import settings from django.urls import path diff --git a/mail/verification_api.py b/mail/verification_api.py index 3b5ef6b8f..8d90236cd 100644 --- a/mail/verification_api.py +++ b/mail/verification_api.py @@ -1,4 +1,5 @@ """API for email verifications""" + from urllib.parse import quote_plus from django.urls import reverse diff --git a/mail/verification_api_test.py b/mail/verification_api_test.py index 43dbbf1c2..fa54d2986 100644 --- a/mail/verification_api_test.py +++ b/mail/verification_api_test.py @@ -1,4 +1,5 @@ """Tests for verification_api""" + from urllib.parse import quote_plus import pytest diff --git a/mail/views.py b/mail/views.py index d6e72efde..e710c2a0d 100644 --- a/mail/views.py +++ b/mail/views.py @@ -1,4 +1,5 @@ """Mail views""" + from django.conf import settings from django.http import JsonResponse from django.shortcuts import render diff --git a/maxmind/factories.py b/maxmind/factories.py index 800f8ef41..75605724b 100644 --- a/maxmind/factories.py +++ b/maxmind/factories.py @@ -1,6 +1,7 @@ """ Factories for MaxMind data """ + import ipaddress import faker diff --git a/mitxpro/admin.py b/mitxpro/admin.py index aa40f6137..71287c5c7 100644 --- a/mitxpro/admin.py +++ b/mitxpro/admin.py @@ -1,4 +1,5 @@ """Django admin functionality that is relevant to the entire app""" + from django.contrib import admin diff --git a/mitxpro/apps.py b/mitxpro/apps.py index d86ca066d..e167afe9d 100644 --- a/mitxpro/apps.py +++ b/mitxpro/apps.py @@ -1,6 +1,7 @@ """ Django app """ + from django.apps import AppConfig diff --git a/mitxpro/celery_utils.py b/mitxpro/celery_utils.py index f309beeb5..9ebdb5af8 100644 --- a/mitxpro/celery_utils.py +++ b/mitxpro/celery_utils.py @@ -1,4 +1,5 @@ """Utility functions for celery""" + from datetime import timedelta from celery.schedules import schedule diff --git a/mitxpro/context_processors.py b/mitxpro/context_processors.py index a0af1a388..ad8d25715 100644 --- a/mitxpro/context_processors.py +++ b/mitxpro/context_processors.py @@ -1,6 +1,7 @@ """ context processors for bootcamp """ + from django.conf import settings diff --git a/mitxpro/exceptions.py b/mitxpro/exceptions.py index 51d644122..542465d04 100644 --- a/mitxpro/exceptions.py +++ b/mitxpro/exceptions.py @@ -1,4 +1,5 @@ """Exception related classes and functions""" + from rest_framework import exceptions, views diff --git a/mitxpro/models.py b/mitxpro/models.py index 3ba0fbd22..3038b08c1 100644 --- a/mitxpro/models.py +++ b/mitxpro/models.py @@ -1,6 +1,7 @@ """ Common model classes """ + import copy from typing import Iterable # noqa: UP035 diff --git a/mitxpro/models_test.py b/mitxpro/models_test.py index d681e6f58..74db140e5 100644 --- a/mitxpro/models_test.py +++ b/mitxpro/models_test.py @@ -1,4 +1,5 @@ """Tests for mitxpro models""" + from random import choice, randint, sample from types import SimpleNamespace diff --git a/mitxpro/permissions.py b/mitxpro/permissions.py index 3693d0bf3..b172eb953 100644 --- a/mitxpro/permissions.py +++ b/mitxpro/permissions.py @@ -1,4 +1,5 @@ """Custom permissions""" + from rest_framework import permissions diff --git a/mitxpro/permissions_test.py b/mitxpro/permissions_test.py index 65d9b15a1..6e999b2b1 100644 --- a/mitxpro/permissions_test.py +++ b/mitxpro/permissions_test.py @@ -1,4 +1,5 @@ """Test permissions""" + import pytest from mitxpro.permissions import UserIsOwnerPermission diff --git a/mitxpro/sentry.py b/mitxpro/sentry.py index d5d265823..f5086cc93 100644 --- a/mitxpro/sentry.py +++ b/mitxpro/sentry.py @@ -1,4 +1,5 @@ """Sentry setup and configuration""" + import sentry_sdk from celery.exceptions import WorkerLostError from sentry_sdk.integrations.celery import CeleryIntegration diff --git a/mitxpro/serializers.py b/mitxpro/serializers.py index 75b1ac40d..41b47f6db 100644 --- a/mitxpro/serializers.py +++ b/mitxpro/serializers.py @@ -1,4 +1,5 @@ """MIT xPro serializers""" + from django.conf import settings from rest_framework import serializers diff --git a/mitxpro/settings.py b/mitxpro/settings.py index 41d825436..523ff9b8d 100644 --- a/mitxpro/settings.py +++ b/mitxpro/settings.py @@ -1,6 +1,7 @@ """ Django settings for mitxpro. """ + import logging import os import platform @@ -26,7 +27,7 @@ from mitxpro.celery_utils import OffsettingSchedule from mitxpro.sentry import init_sentry -VERSION = "0.146.0" +VERSION = "0.146.1" ENVIRONMENT = get_string( name="MITXPRO_ENVIRONMENT", diff --git a/mitxpro/settings_test.py b/mitxpro/settings_test.py index 90b9a6c4c..2328cc617 100644 --- a/mitxpro/settings_test.py +++ b/mitxpro/settings_test.py @@ -1,6 +1,7 @@ """ Validate that our settings functions work """ + import sys from types import SimpleNamespace diff --git a/mitxpro/templatetags/js_interop.py b/mitxpro/templatetags/js_interop.py index ee7f7f806..602fbd020 100644 --- a/mitxpro/templatetags/js_interop.py +++ b/mitxpro/templatetags/js_interop.py @@ -1,4 +1,5 @@ """JS interopability template tags""" + import json from django import template diff --git a/mitxpro/templatetags/startswith.py b/mitxpro/templatetags/startswith.py index 815ce365a..3f260b90b 100644 --- a/mitxpro/templatetags/startswith.py +++ b/mitxpro/templatetags/startswith.py @@ -1,4 +1,5 @@ """Module for custom string utility template tags and filters""" + from django import template register = template.Library() diff --git a/mitxpro/test_utils.py b/mitxpro/test_utils.py index 397e3c741..f863b2f52 100644 --- a/mitxpro/test_utils.py +++ b/mitxpro/test_utils.py @@ -1,4 +1,5 @@ """Testing utils""" + import abc import csv import json diff --git a/mitxpro/test_utils_test.py b/mitxpro/test_utils_test.py index 8e4a4f53e..daa51e249 100644 --- a/mitxpro/test_utils_test.py +++ b/mitxpro/test_utils_test.py @@ -1,4 +1,5 @@ """Tests for test utils""" + import pickle import pytest diff --git a/mitxpro/tests/app_tests.py b/mitxpro/tests/app_tests.py index fcd222023..8240e2012 100644 --- a/mitxpro/tests/app_tests.py +++ b/mitxpro/tests/app_tests.py @@ -1,4 +1,5 @@ """Application level tests""" + import json diff --git a/mitxpro/tests/js_interop_test.py b/mitxpro/tests/js_interop_test.py index 456309934..687c70b17 100644 --- a/mitxpro/tests/js_interop_test.py +++ b/mitxpro/tests/js_interop_test.py @@ -1,4 +1,5 @@ """JS interop template tag tests""" + from django.template import Context, Template diff --git a/mitxpro/urls.py b/mitxpro/urls.py index 450e57e0c..7bd930508 100644 --- a/mitxpro/urls.py +++ b/mitxpro/urls.py @@ -13,6 +13,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.conf import settings from django.conf.urls.static import static from django.contrib import admin diff --git a/mitxpro/utils.py b/mitxpro/utils.py index 9b08aec87..faa40d67c 100644 --- a/mitxpro/utils.py +++ b/mitxpro/utils.py @@ -1,4 +1,5 @@ """mitxpro utilities""" + import csv import datetime import itertools diff --git a/mitxpro/utils_test.py b/mitxpro/utils_test.py index 16d282e53..2bd824b01 100644 --- a/mitxpro/utils_test.py +++ b/mitxpro/utils_test.py @@ -1,4 +1,5 @@ """Utils tests""" + import datetime import operator as op import os diff --git a/mitxpro/views.py b/mitxpro/views.py index 9604b0b39..56067fe1f 100644 --- a/mitxpro/views.py +++ b/mitxpro/views.py @@ -1,6 +1,7 @@ """ mitxpro views """ + import json from django.conf import settings @@ -23,9 +24,9 @@ def get_base_context(request): # noqa: ARG001 """ context = {} if settings.GOOGLE_DOMAIN_VERIFICATION_TAG_VALUE: - context[ - "domain_verification_tag" - ] = settings.GOOGLE_DOMAIN_VERIFICATION_TAG_VALUE + context["domain_verification_tag"] = ( + settings.GOOGLE_DOMAIN_VERIFICATION_TAG_VALUE + ) return context diff --git a/mitxpro/views_test.py b/mitxpro/views_test.py index 4650979a9..81d979677 100644 --- a/mitxpro/views_test.py +++ b/mitxpro/views_test.py @@ -1,6 +1,7 @@ """ Test end to end django views. """ + import pytest from django.test import Client from django.urls import reverse diff --git a/mitxpro/wsgi.py b/mitxpro/wsgi.py index 044250586..42a1516d2 100644 --- a/mitxpro/wsgi.py +++ b/mitxpro/wsgi.py @@ -6,6 +6,7 @@ For more information on this file, see https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ """ + import os from django.core.wsgi import get_wsgi_application diff --git a/poetry.lock b/poetry.lock index 84d07c952..03b5a9a84 100644 --- a/poetry.lock +++ b/poetry.lock @@ -216,17 +216,17 @@ files = [ [[package]] name = "boto3" -version = "1.34.88" +version = "1.34.96" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.34.88-py3-none-any.whl", hash = "sha256:1bd4cef11b7c5f293cede50f3d33ca89fe3413c51f1864f40163c56a732dd6b3"}, - {file = "boto3-1.34.88.tar.gz", hash = "sha256:168894499578a9d69d6f7deb5811952bf4171c51b95749a9aef32cf67bc71f87"}, + {file = "boto3-1.34.96-py3-none-any.whl", hash = "sha256:fe3d039631074a96374a354764641b6623036b6ea15381b8a04ac0a193b8c1e0"}, + {file = "boto3-1.34.96.tar.gz", hash = "sha256:42ea7d46688e7cb27259780b9da2cddcfaf2763ff5d327f4d54eac12edba8e72"}, ] [package.dependencies] -botocore = ">=1.34.88,<1.35.0" +botocore = ">=1.34.96,<1.35.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.10.0,<0.11.0" @@ -235,13 +235,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.34.88" +version = "1.34.96" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.34.88-py3-none-any.whl", hash = "sha256:e87a660599ed3e14b2a770f4efc3df2f2f6d04f3c7bfd64ddbae186667864a7b"}, - {file = "botocore-1.34.88.tar.gz", hash = "sha256:36f2e9e8dfa856e55dbbe703aea601f134db3fddc3615f1020a755b27fd26a5e"}, + {file = "botocore-1.34.96-py3-none-any.whl", hash = "sha256:4c307f5772286f1ab58a91220ea8e180416a2ea0cc7e76983a6984e4ef8c212d"}, + {file = "botocore-1.34.96.tar.gz", hash = "sha256:00e917cd8152d902a4771b9e1e4d0cf1ee096c90027ee35f2a76b6d394e2ada5"}, ] [package.dependencies] @@ -3289,28 +3289,28 @@ files = [ [[package]] name = "ruff" -version = "0.1.15" +version = "0.4.2" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:5fe8d54df166ecc24106db7dd6a68d44852d14eb0729ea4672bb4d96c320b7df"}, - {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6f0bfbb53c4b4de117ac4d6ddfd33aa5fc31beeaa21d23c45c6dd249faf9126f"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0d432aec35bfc0d800d4f70eba26e23a352386be3a6cf157083d18f6f5881c8"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9405fa9ac0e97f35aaddf185a1be194a589424b8713e3b97b762336ec79ff807"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c66ec24fe36841636e814b8f90f572a8c0cb0e54d8b5c2d0e300d28a0d7bffec"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6f8ad828f01e8dd32cc58bc28375150171d198491fc901f6f98d2a39ba8e3ff5"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86811954eec63e9ea162af0ffa9f8d09088bab51b7438e8b6488b9401863c25e"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fd4025ac5e87d9b80e1f300207eb2fd099ff8200fa2320d7dc066a3f4622dc6b"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b17b93c02cdb6aeb696effecea1095ac93f3884a49a554a9afa76bb125c114c1"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ddb87643be40f034e97e97f5bc2ef7ce39de20e34608f3f829db727a93fb82c5"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:abf4822129ed3a5ce54383d5f0e964e7fef74a41e48eb1dfad404151efc130a2"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_i686.whl", hash = "sha256:6c629cf64bacfd136c07c78ac10a54578ec9d1bd2a9d395efbee0935868bf852"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1bab866aafb53da39c2cadfb8e1c4550ac5340bb40300083eb8967ba25481447"}, - {file = "ruff-0.1.15-py3-none-win32.whl", hash = "sha256:2417e1cb6e2068389b07e6fa74c306b2810fe3ee3476d5b8a96616633f40d14f"}, - {file = "ruff-0.1.15-py3-none-win_amd64.whl", hash = "sha256:3837ac73d869efc4182d9036b1405ef4c73d9b1f88da2413875e34e0d6919587"}, - {file = "ruff-0.1.15-py3-none-win_arm64.whl", hash = "sha256:9a933dfb1c14ec7a33cceb1e49ec4a16b51ce3c20fd42663198746efc0427360"}, - {file = "ruff-0.1.15.tar.gz", hash = "sha256:f6dfa8c1b21c913c326919056c390966648b680966febcb796cc9d1aaab8564e"}, + {file = "ruff-0.4.2-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:8d14dc8953f8af7e003a485ef560bbefa5f8cc1ad994eebb5b12136049bbccc5"}, + {file = "ruff-0.4.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:24016ed18db3dc9786af103ff49c03bdf408ea253f3cb9e3638f39ac9cf2d483"}, + {file = "ruff-0.4.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0e2e06459042ac841ed510196c350ba35a9b24a643e23db60d79b2db92af0c2b"}, + {file = "ruff-0.4.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3afabaf7ba8e9c485a14ad8f4122feff6b2b93cc53cd4dad2fd24ae35112d5c5"}, + {file = "ruff-0.4.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:799eb468ea6bc54b95527143a4ceaf970d5aa3613050c6cff54c85fda3fde480"}, + {file = "ruff-0.4.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:ec4ba9436a51527fb6931a8839af4c36a5481f8c19e8f5e42c2f7ad3a49f5069"}, + {file = "ruff-0.4.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6a2243f8f434e487c2a010c7252150b1fdf019035130f41b77626f5655c9ca22"}, + {file = "ruff-0.4.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8772130a063f3eebdf7095da00c0b9898bd1774c43b336272c3e98667d4fb8fa"}, + {file = "ruff-0.4.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ab165ef5d72392b4ebb85a8b0fbd321f69832a632e07a74794c0e598e7a8376"}, + {file = "ruff-0.4.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1f32cadf44c2020e75e0c56c3408ed1d32c024766bd41aedef92aa3ca28eef68"}, + {file = "ruff-0.4.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:22e306bf15e09af45ca812bc42fa59b628646fa7c26072555f278994890bc7ac"}, + {file = "ruff-0.4.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:82986bb77ad83a1719c90b9528a9dd663c9206f7c0ab69282af8223566a0c34e"}, + {file = "ruff-0.4.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:652e4ba553e421a6dc2a6d4868bc3b3881311702633eb3672f9f244ded8908cd"}, + {file = "ruff-0.4.2-py3-none-win32.whl", hash = "sha256:7891ee376770ac094da3ad40c116258a381b86c7352552788377c6eb16d784fe"}, + {file = "ruff-0.4.2-py3-none-win_amd64.whl", hash = "sha256:5ec481661fb2fd88a5d6cf1f83403d388ec90f9daaa36e40e2c003de66751798"}, + {file = "ruff-0.4.2-py3-none-win_arm64.whl", hash = "sha256:cbd1e87c71bca14792948c4ccb51ee61c3296e164019d2d484f3eaa2d360dfaf"}, + {file = "ruff-0.4.2.tar.gz", hash = "sha256:33bcc160aee2520664bc0859cfeaebc84bb7323becff3f303b8f1f2d81cb4edc"}, ] [[package]] @@ -3942,4 +3942,4 @@ xmlsec = ["xmlsec (>=0.6.1)"] [metadata] lock-version = "2.0" python-versions = "3.9.14" -content-hash = "14444c56aa6c13627a2f0b7d8accf901993bdfe2c2bc54d3f6e1a79fcd235355" +content-hash = "0fecd82bf6342b104b7931e22a717e5a2b2cebd80a813f579a5bc7dbf756f52e" diff --git a/pyproject.toml b/pyproject.toml index 64416a3d7..9d1ccf2cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ packages = [] python = "3.9.14" beautifulsoup4 = "4.8.2" -boto3 = "1.34.88" +boto3 = "1.34.96" celery = "5.3.6" celery-redbeat = "2.2.0" dj-database-url = "0.5.0" @@ -83,7 +83,7 @@ responses = "*" safety = "*" semantic-version = "*" wagtail-factories = "*" -ruff = "^0.1.11" +ruff = "^0.4.0" [build-system] requires = ["poetry-core>=1.0.0"] @@ -92,6 +92,8 @@ build-backend = "poetry.core.masonry.api" [tool.ruff] target-version = "py39" line-length = 88 + +[lint] select = [ "A", # flake8-builtins # "AIR", # Airflow @@ -185,16 +187,16 @@ ignore = [ typing-modules = ["colour.hints"] -[tool.ruff.pydocstyle] +[pydocstyle] convention = "pep257" -[tool.ruff.flake8-quotes] +[flake8-quotes] inline-quotes = "double" -[tool.ruff.flake8-pytest-style] +[flake8-pytest-style] fixture-parentheses = false -[tool.ruff.per-file-ignores] +[per-file-ignores] "*_test.py" = ["ARG001", "E501", "S101", "PLR2004"] "test_*.py" = ["ARG001", "E501", "S101", "PLR2004"] "**/migrations/**" = ["ARG001", "D101", "D100"] diff --git a/repl.py b/repl.py index 55b759d3c..8b8d56f5a 100755 --- a/repl.py +++ b/repl.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 """Run Django shell with imported modules""" + if __name__ == "__main__": import os diff --git a/sheets/api.py b/sheets/api.py index 482172ba2..602090442 100644 --- a/sheets/api.py +++ b/sheets/api.py @@ -1,4 +1,5 @@ """API for the Sheets app""" + import datetime import json import logging diff --git a/sheets/api_test.py b/sheets/api_test.py index 3452abb34..309a638d3 100644 --- a/sheets/api_test.py +++ b/sheets/api_test.py @@ -1,4 +1,5 @@ """Sheets API tests""" + import pytest from django.core.exceptions import ImproperlyConfigured from google.oauth2.credentials import Credentials diff --git a/sheets/apps.py b/sheets/apps.py index 50071edec..61f0e88a4 100644 --- a/sheets/apps.py +++ b/sheets/apps.py @@ -1,6 +1,7 @@ """ Django App """ + from django.apps import AppConfig diff --git a/sheets/conftest.py b/sheets/conftest.py index aef3b3ce4..f681f7176 100644 --- a/sheets/conftest.py +++ b/sheets/conftest.py @@ -1,4 +1,5 @@ """Fixtures relevant to the sheets app test suite""" + import pytest diff --git a/sheets/coupon_assign_api.py b/sheets/coupon_assign_api.py index 882ca2b53..5abb92064 100644 --- a/sheets/coupon_assign_api.py +++ b/sheets/coupon_assign_api.py @@ -1,4 +1,5 @@ """Coupon assignment API""" + import logging from collections import defaultdict from datetime import timedelta @@ -441,9 +442,9 @@ def update_incomplete_assignment_message_statuses(bulk_assignments): # to reflect those new statuses. for bulk_assignment in bulk_assignments: coupon_assign_handler = assignment_sheet_handlers[bulk_assignment.id] - updated_assignment_map[ - bulk_assignment.id - ] = coupon_assign_handler.update_coupon_delivery_statuses(assignment_status_map) + updated_assignment_map[bulk_assignment.id] = ( + coupon_assign_handler.update_coupon_delivery_statuses(assignment_status_map) + ) return updated_assignment_map diff --git a/sheets/coupon_request_api.py b/sheets/coupon_request_api.py index d2c59d707..2192402f0 100644 --- a/sheets/coupon_request_api.py +++ b/sheets/coupon_request_api.py @@ -1,4 +1,5 @@ """Coupon request API""" + import itertools import json import logging diff --git a/sheets/deferral_request_api.py b/sheets/deferral_request_api.py index 998cbf7ee..ee4ce2713 100644 --- a/sheets/deferral_request_api.py +++ b/sheets/deferral_request_api.py @@ -1,4 +1,5 @@ """Enrollment deferral API""" + import logging from django.conf import settings diff --git a/sheets/factories.py b/sheets/factories.py index 6e8351b4d..633dc2d02 100644 --- a/sheets/factories.py +++ b/sheets/factories.py @@ -1,4 +1,5 @@ """Factories for sheets app""" + import datetime from factory import Faker, SubFactory, fuzzy diff --git a/sheets/mail_api.py b/sheets/mail_api.py index f72c3de1e..514744275 100644 --- a/sheets/mail_api.py +++ b/sheets/mail_api.py @@ -1,4 +1,5 @@ """Mail API for sheets app""" + import logging from collections import namedtuple from urllib.parse import urlencode diff --git a/sheets/management/commands/create_coupon_assignment_sheet.py b/sheets/management/commands/create_coupon_assignment_sheet.py index c1396ba77..75c0aae02 100644 --- a/sheets/management/commands/create_coupon_assignment_sheet.py +++ b/sheets/management/commands/create_coupon_assignment_sheet.py @@ -1,6 +1,7 @@ """ Creates a coupon assignment Sheet for some row in the coupon request Sheet if one doesn't exist already. """ + from django.core.management import BaseCommand, CommandError from pygsheets.exceptions import SpreadsheetNotFound diff --git a/sheets/management/commands/process_coupon_assignment_sheet.py b/sheets/management/commands/process_coupon_assignment_sheet.py index be2776dce..5fa19cbca 100644 --- a/sheets/management/commands/process_coupon_assignment_sheet.py +++ b/sheets/management/commands/process_coupon_assignment_sheet.py @@ -2,6 +2,7 @@ Fetches a coupon assignment spreadsheet, parses it, creates product coupon assignments based on the sheet data, and sends a message to all recipients who received a coupon assignment. """ + from django.core.management import BaseCommand, CommandError from ecommerce.models import BulkCouponAssignment diff --git a/sheets/management/commands/process_coupon_requests.py b/sheets/management/commands/process_coupon_requests.py index e6a51204d..70f7c271b 100644 --- a/sheets/management/commands/process_coupon_requests.py +++ b/sheets/management/commands/process_coupon_requests.py @@ -2,6 +2,7 @@ Parses coupon request row(s), creates coupons, and updates/creates relevant Sheets to reflect the processed request(s). """ + from django.core.management import BaseCommand from sheets.coupon_request_api import CouponRequestHandler diff --git a/sheets/management/commands/process_deferral_requests.py b/sheets/management/commands/process_deferral_requests.py index eb8340cc3..e4d3638d7 100644 --- a/sheets/management/commands/process_deferral_requests.py +++ b/sheets/management/commands/process_deferral_requests.py @@ -2,6 +2,7 @@ Parses deferral request row(s), creates/deactivates enrollments as necessary, and updates the spreadsheet to reflect the processed request(s). """ + from django.core.management import BaseCommand from sheets.deferral_request_api import DeferralRequestHandler diff --git a/sheets/management/commands/process_refund_requests.py b/sheets/management/commands/process_refund_requests.py index 12590d5ab..b882528b1 100644 --- a/sheets/management/commands/process_refund_requests.py +++ b/sheets/management/commands/process_refund_requests.py @@ -2,6 +2,7 @@ Parses refund request row(s), reverses orders/enrollments, and updates the spreadsheet to reflect the processed request(s). """ + from django.core.management import BaseCommand from sheets.refund_request_api import RefundRequestHandler diff --git a/sheets/management/commands/setup_file_watch.py b/sheets/management/commands/setup_file_watch.py index dce7e94a9..1abfd3559 100644 --- a/sheets/management/commands/setup_file_watch.py +++ b/sheets/management/commands/setup_file_watch.py @@ -1,6 +1,7 @@ """ Makes a request to receive push notifications when xPro spreadsheets are updated """ + import sys from collections import namedtuple diff --git a/sheets/management/commands/sync_assignment_sheet.py b/sheets/management/commands/sync_assignment_sheet.py index 1e75f496d..154bec769 100644 --- a/sheets/management/commands/sync_assignment_sheet.py +++ b/sheets/management/commands/sync_assignment_sheet.py @@ -2,6 +2,7 @@ Compares assignment sheet rows to enrollment records in the database and message delivery data in Mailgun. If the data in the sheet does not match, a request is sent to update/"sync" the sheet data. """ + from django.core.management import BaseCommand, CommandError from ecommerce.mail_api import send_bulk_enroll_emails diff --git a/sheets/management/commands/update_assignment_message_statuses.py b/sheets/management/commands/update_assignment_message_statuses.py index 4af1690f0..a777ab2b3 100644 --- a/sheets/management/commands/update_assignment_message_statuses.py +++ b/sheets/management/commands/update_assignment_message_statuses.py @@ -2,6 +2,7 @@ Updates the database records and coupon assignment Sheet associated with a bulk coupon assignment record depending on what messages were delivered, failed delivery, etc. """ + from django.core.management import BaseCommand, CommandError from ecommerce.models import BulkCouponAssignment diff --git a/sheets/management/utils.py b/sheets/management/utils.py index c03c3182f..f3c6b1225 100644 --- a/sheets/management/utils.py +++ b/sheets/management/utils.py @@ -1,4 +1,5 @@ """Sheets app management command utils""" + from django.core.management import CommandError from sheets.coupon_assign_api import CouponAssignmentHandler diff --git a/sheets/management/utils_test.py b/sheets/management/utils_test.py index eabdea17c..cf93da6d5 100644 --- a/sheets/management/utils_test.py +++ b/sheets/management/utils_test.py @@ -1,4 +1,5 @@ """Tests for sheets.management.utils""" + from unittest.mock import MagicMock import pytest diff --git a/sheets/models.py b/sheets/models.py index 83b077917..7b80e5c6b 100644 --- a/sheets/models.py +++ b/sheets/models.py @@ -1,4 +1,5 @@ """Sheets app models""" + from django.conf import settings from django.core.exceptions import ValidationError from django.db import models diff --git a/sheets/models_test.py b/sheets/models_test.py index a7fa1b97f..f29488eb9 100644 --- a/sheets/models_test.py +++ b/sheets/models_test.py @@ -1,4 +1,5 @@ """Tests for sheets models""" + import pytest from django.core.exceptions import ValidationError diff --git a/sheets/refund_request_api.py b/sheets/refund_request_api.py index 09238fa78..e90d3fcce 100644 --- a/sheets/refund_request_api.py +++ b/sheets/refund_request_api.py @@ -1,4 +1,5 @@ """Enrollment refund API""" + import logging from django.conf import settings diff --git a/sheets/sheet_handler_api.py b/sheets/sheet_handler_api.py index acfaedab8..4248ba8f5 100644 --- a/sheets/sheet_handler_api.py +++ b/sheets/sheet_handler_api.py @@ -1,4 +1,5 @@ """API with general functionality for all enrollment change spreadsheets""" + import json import logging import operator as op diff --git a/sheets/tasks.py b/sheets/tasks.py index 9e83f4b1f..6736fd1be 100644 --- a/sheets/tasks.py +++ b/sheets/tasks.py @@ -1,4 +1,5 @@ """Sheets app tasks""" + import logging from datetime import datetime, timedelta from itertools import chain, repeat diff --git a/sheets/tasks_test.py b/sheets/tasks_test.py index 4794b3094..7111dc727 100644 --- a/sheets/tasks_test.py +++ b/sheets/tasks_test.py @@ -1,4 +1,5 @@ """Tests for sheets app views""" + import pytest from sheets.tasks import ( diff --git a/sheets/urls.py b/sheets/urls.py index f867e21ac..6ab0f89eb 100644 --- a/sheets/urls.py +++ b/sheets/urls.py @@ -1,4 +1,5 @@ """Endpoint URLs for sheets app""" + from django.urls import re_path from sheets import views diff --git a/sheets/utils.py b/sheets/utils.py index 073f95c66..710d57e4c 100644 --- a/sheets/utils.py +++ b/sheets/utils.py @@ -1,4 +1,5 @@ """Sheets app util functions""" + import datetime import email.utils from collections import namedtuple diff --git a/sheets/views.py b/sheets/views.py index b31cc8354..eae561bd2 100644 --- a/sheets/views.py +++ b/sheets/views.py @@ -1,4 +1,5 @@ """HTTP views for sheets app""" + import logging from urllib.parse import urljoin diff --git a/sheets/views_test.py b/sheets/views_test.py index b1784b8bc..1c7b05b39 100644 --- a/sheets/views_test.py +++ b/sheets/views_test.py @@ -1,4 +1,5 @@ """Tests for sheets app views""" + import pytest from django.test.client import Client, RequestFactory from django.urls import reverse diff --git a/users/admin.py b/users/admin.py index 32b552d1f..e10c90549 100644 --- a/users/admin.py +++ b/users/admin.py @@ -1,4 +1,5 @@ """User admin""" + from django.contrib import admin from django.contrib.auth.admin import UserAdmin as ContribUserAdmin from django.utils.translation import gettext_lazy as _ diff --git a/users/api.py b/users/api.py index c154a16ee..329cf8e78 100644 --- a/users/api.py +++ b/users/api.py @@ -1,4 +1,5 @@ """Users api""" + import operator import re from functools import reduce diff --git a/users/api_test.py b/users/api_test.py index 8174c4b96..d2443ee6e 100644 --- a/users/api_test.py +++ b/users/api_test.py @@ -1,4 +1,5 @@ """Tests for user api""" + import factory import pytest from django.contrib.auth import get_user_model diff --git a/users/apps.py b/users/apps.py index 91eb40212..4d1074fb4 100644 --- a/users/apps.py +++ b/users/apps.py @@ -1,4 +1,5 @@ """Users application""" + from django.apps import AppConfig diff --git a/users/constants.py b/users/constants.py index d50076b48..d2dda8011 100644 --- a/users/constants.py +++ b/users/constants.py @@ -1,2 +1,3 @@ """User constants""" + USERNAME_MAX_LEN = 30 diff --git a/users/factories.py b/users/factories.py index d3118e8c4..b0ae36315 100644 --- a/users/factories.py +++ b/users/factories.py @@ -1,4 +1,5 @@ """Factory for Users""" + import pycountry from factory import ( Faker, diff --git a/users/management/commands/retire_users.py b/users/management/commands/retire_users.py index b6bced67a..025f6edb0 100644 --- a/users/management/commands/retire_users.py +++ b/users/management/commands/retire_users.py @@ -1,6 +1,7 @@ """ Retire user(s) from MIT xPRO """ + import sys from argparse import RawTextHelpFormatter from urllib.parse import urlparse diff --git a/users/management/commands/unblock_users.py b/users/management/commands/unblock_users.py index 5b7a6b6df..966cc59f9 100644 --- a/users/management/commands/unblock_users.py +++ b/users/management/commands/unblock_users.py @@ -1,6 +1,7 @@ """ Unblock user(s) from MIT xPRO """ + import sys from argparse import RawTextHelpFormatter diff --git a/users/management/tests/block_users_test.py b/users/management/tests/block_users_test.py index f62dc9141..9f5971ae9 100644 --- a/users/management/tests/block_users_test.py +++ b/users/management/tests/block_users_test.py @@ -1,4 +1,5 @@ """block user test""" + import hashlib import pytest diff --git a/users/management/tests/retire_users_test.py b/users/management/tests/retire_users_test.py index 4957830b3..9ecf278a0 100644 --- a/users/management/tests/retire_users_test.py +++ b/users/management/tests/retire_users_test.py @@ -1,4 +1,5 @@ """retire user test""" + import hashlib import pytest diff --git a/users/management/tests/unblock_users_test.py b/users/management/tests/unblock_users_test.py index 19579c91f..296bb4bdf 100644 --- a/users/management/tests/unblock_users_test.py +++ b/users/management/tests/unblock_users_test.py @@ -1,4 +1,5 @@ """retire user test""" + import hashlib import pytest diff --git a/users/models.py b/users/models.py index 0274c9ee1..ba135fd7a 100644 --- a/users/models.py +++ b/users/models.py @@ -1,4 +1,5 @@ """User models""" + import uuid from datetime import timedelta diff --git a/users/models_test.py b/users/models_test.py index ed8f79f32..c6f821269 100644 --- a/users/models_test.py +++ b/users/models_test.py @@ -1,4 +1,5 @@ """Tests for user models""" + import factory import pytest from django.core.exceptions import ValidationError diff --git a/users/serializers.py b/users/serializers.py index c5de4888e..58a82a8c4 100644 --- a/users/serializers.py +++ b/users/serializers.py @@ -1,4 +1,5 @@ """User serializers""" + import logging import re from collections import defaultdict diff --git a/users/serializers_test.py b/users/serializers_test.py index 285a3853d..182c4266d 100644 --- a/users/serializers_test.py +++ b/users/serializers_test.py @@ -1,4 +1,5 @@ """Tests for users.serializers""" + import pytest from rest_framework.exceptions import ValidationError diff --git a/users/urls.py b/users/urls.py index 456af9bce..4021e5477 100644 --- a/users/urls.py +++ b/users/urls.py @@ -1,4 +1,5 @@ """User url routes""" + from django.urls import include, path from rest_framework import routers diff --git a/users/utils.py b/users/utils.py index de3010c12..516359f0c 100644 --- a/users/utils.py +++ b/users/utils.py @@ -1,4 +1,5 @@ """User app utility functions""" + import logging import re from email.utils import formataddr diff --git a/users/utils_test.py b/users/utils_test.py index 2dfe0bfaa..4a5b5d56e 100644 --- a/users/utils_test.py +++ b/users/utils_test.py @@ -1,4 +1,5 @@ """User utils tests""" + import re from unittest.mock import patch diff --git a/users/views.py b/users/views.py index 20a8a7357..927f8180e 100644 --- a/users/views.py +++ b/users/views.py @@ -1,4 +1,5 @@ """User views""" + import pycountry from django.db import transaction from oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScope diff --git a/users/views_test.py b/users/views_test.py index 52ea6fd6b..7ecdf284b 100644 --- a/users/views_test.py +++ b/users/views_test.py @@ -1,4 +1,5 @@ """Test for user views""" + from datetime import timedelta import pytest diff --git a/voucher/admin.py b/voucher/admin.py index 40142bbdd..dd642fdc7 100644 --- a/voucher/admin.py +++ b/voucher/admin.py @@ -1,6 +1,7 @@ """ Admin bindings for voucher """ + from django.contrib import admin from voucher.models import Voucher diff --git a/voucher/apps.py b/voucher/apps.py index 85ee96335..7f0e2815e 100644 --- a/voucher/apps.py +++ b/voucher/apps.py @@ -1,6 +1,7 @@ """ Django App """ + from django.apps import AppConfig diff --git a/voucher/conftest.py b/voucher/conftest.py index 3115818c8..d19a99450 100644 --- a/voucher/conftest.py +++ b/voucher/conftest.py @@ -1,6 +1,7 @@ """ Fixtures for voucher tests """ + from datetime import datetime, timezone from types import SimpleNamespace diff --git a/voucher/factories.py b/voucher/factories.py index 77d22d85c..90635319e 100644 --- a/voucher/factories.py +++ b/voucher/factories.py @@ -1,6 +1,7 @@ """ Factories for voucher models """ + import factory from factory.django import DjangoModelFactory diff --git a/voucher/forms.py b/voucher/forms.py index a69840632..3c4916f88 100644 --- a/voucher/forms.py +++ b/voucher/forms.py @@ -1,6 +1,7 @@ """ Voucher upload forms """ + from django import forms from django.core.exceptions import ValidationError diff --git a/voucher/forms_test.py b/voucher/forms_test.py index 71b9d69eb..c3b1a960b 100644 --- a/voucher/forms_test.py +++ b/voucher/forms_test.py @@ -1,6 +1,7 @@ """ Voucher forms tests """ + from unittest.mock import patch import pytest diff --git a/voucher/models.py b/voucher/models.py index 359e4517c..d7168a5ce 100644 --- a/voucher/models.py +++ b/voucher/models.py @@ -1,6 +1,7 @@ """ Voucher Models """ + from django.conf import settings from django.db import models diff --git a/voucher/urls.py b/voucher/urls.py index 435a0f6a3..66dde66c1 100644 --- a/voucher/urls.py +++ b/voucher/urls.py @@ -1,6 +1,7 @@ """ Voucher URL patterns """ + from django.urls import path from voucher import views diff --git a/voucher/utils.py b/voucher/utils.py index 3a7894314..b3a09bc21 100644 --- a/voucher/utils.py +++ b/voucher/utils.py @@ -1,4 +1,5 @@ """PDF Parsing functions for Vouchers""" + import logging import re from datetime import datetime @@ -159,13 +160,15 @@ def read_pdf_domestic(pdf): # noqa: C901 ].split(" ")[-1] try: float(last_val) - column_values[ - settings.VOUCHER_DOMESTIC_COURSE_KEY - ] = column_values[settings.VOUCHER_DOMESTIC_COURSE_KEY][ - 0 : column_values[ + column_values[settings.VOUCHER_DOMESTIC_COURSE_KEY] = ( + column_values[ settings.VOUCHER_DOMESTIC_COURSE_KEY - ].index(last_val) - ] + ][ + 0 : column_values[ + settings.VOUCHER_DOMESTIC_COURSE_KEY + ].index(last_val) + ] + ) column_values[settings.VOUCHER_DOMESTIC_CREDITS_KEY] = ( last_val + column_values[settings.VOUCHER_DOMESTIC_CREDITS_KEY] diff --git a/voucher/utils_test.py b/voucher/utils_test.py index 9c04e4f7e..74a3de7a5 100644 --- a/voucher/utils_test.py +++ b/voucher/utils_test.py @@ -1,4 +1,5 @@ """Tests for utils.py""" + import json import re from datetime import datetime, timezone diff --git a/voucher/views.py b/voucher/views.py index 68b2f379c..c19615036 100644 --- a/voucher/views.py +++ b/voucher/views.py @@ -1,6 +1,7 @@ """ Voucher views """ + import logging from datetime import datetime, timezone diff --git a/voucher/views_test.py b/voucher/views_test.py index de0fc88fe..72224f080 100644 --- a/voucher/views_test.py +++ b/voucher/views_test.py @@ -1,6 +1,7 @@ """ Test voucher views.py """ + from urllib.parse import urljoin import pytest