From 4b4fc89693acb3db57767ac64efe4af535023fda Mon Sep 17 00:00:00 2001 From: Jawayria Date: Mon, 1 Feb 2021 18:56:15 +0500 Subject: [PATCH] Applied pylint-amnesty to commerce --- lms/djangoapps/commerce/api/v0/tests/test_views.py | 4 ++-- lms/djangoapps/commerce/api/v0/views.py | 2 +- lms/djangoapps/commerce/api/v1/models.py | 2 +- lms/djangoapps/commerce/api/v1/permissions.py | 4 ++-- lms/djangoapps/commerce/api/v1/serializers.py | 4 ++-- lms/djangoapps/commerce/api/v1/tests/test_models.py | 2 +- lms/djangoapps/commerce/api/v1/tests/test_views.py | 6 +++--- lms/djangoapps/commerce/api/v1/views.py | 6 +++--- lms/djangoapps/commerce/exceptions.py | 2 +- lms/djangoapps/commerce/http.py | 4 ++-- .../create_orders_for_old_enterprise_course_enrollment.py | 2 +- lms/djangoapps/commerce/tests/__init__.py | 2 +- lms/djangoapps/commerce/tests/mocks.py | 6 +++--- lms/djangoapps/commerce/tests/test_signals.py | 2 +- lms/djangoapps/commerce/tests/test_utils.py | 4 ++-- lms/djangoapps/commerce/tests/test_views.py | 2 +- lms/djangoapps/commerce/utils.py | 2 +- 17 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lms/djangoapps/commerce/api/v0/tests/test_views.py b/lms/djangoapps/commerce/api/v0/tests/test_views.py index 36904bb7af..5825d3c566 100644 --- a/lms/djangoapps/commerce/api/v0/tests/test_views.py +++ b/lms/djangoapps/commerce/api/v0/tests/test_views.py @@ -69,7 +69,7 @@ class BasketsViewTests(EnrollmentEventTestMixin, UserMixin, ModuleStoreTestCase) self.assertEqual(actual, expected_msg) def setUp(self): - super(BasketsViewTests, self).setUp() + super(BasketsViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse('commerce_api:v0:baskets:create') self._login() @@ -290,7 +290,7 @@ class BasketOrderViewTests(UserMixin, TestCase): path = reverse_lazy(view_name, kwargs={'basket_id': 1}) def setUp(self): - super(BasketOrderViewTests, self).setUp() + super(BasketOrderViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self._login() def test_order_found(self): diff --git a/lms/djangoapps/commerce/api/v0/views.py b/lms/djangoapps/commerce/api/v0/views.py index 754d289dc6..c8a898e7b8 100644 --- a/lms/djangoapps/commerce/api/v0/views.py +++ b/lms/djangoapps/commerce/api/v0/views.py @@ -88,7 +88,7 @@ class BasketsView(APIView): u'Failed to handle marketing opt-in flag: user="%s", course="%s"', user.username, course_key ) - def post(self, request, *args, **kwargs): + def post(self, request, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Attempt to enroll the user. """ diff --git a/lms/djangoapps/commerce/api/v1/models.py b/lms/djangoapps/commerce/api/v1/models.py index 8c484c5e5a..fa0505c590 100644 --- a/lms/djangoapps/commerce/api/v1/models.py +++ b/lms/djangoapps/commerce/api/v1/models.py @@ -130,7 +130,7 @@ class Course(object): course_id = CourseKey.from_string(six.text_type(course_id)) except InvalidKeyError: log.debug(u'[%s] is not a valid course key.', course_id) - raise ValueError + raise ValueError # lint-amnesty, pylint: disable=raise-missing-from course_modes = CourseMode.objects.filter(course_id=course_id) diff --git a/lms/djangoapps/commerce/api/v1/permissions.py b/lms/djangoapps/commerce/api/v1/permissions.py index d13f1b364a..1d5bd8f247 100644 --- a/lms/djangoapps/commerce/api/v1/permissions.py +++ b/lms/djangoapps/commerce/api/v1/permissions.py @@ -1,7 +1,7 @@ """ Custom API permissions. """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from rest_framework.permissions import BasePermission, DjangoModelPermissions from openedx.core.lib.api.permissions import ApiKeyHeaderPermission @@ -22,7 +22,7 @@ class IsAuthenticatedOrActivationOverridden(BasePermission): def has_permission(self, request, view): if not request.user.is_authenticated and is_account_activation_requirement_disabled(): try: - request.user = User.objects.get(id=request.session._session_cache['_auth_user_id']) + request.user = User.objects.get(id=request.session._session_cache['_auth_user_id']) # lint-amnesty, pylint: disable=protected-access except User.DoesNotExist: pass return request.user.is_authenticated diff --git a/lms/djangoapps/commerce/api/v1/serializers.py b/lms/djangoapps/commerce/api/v1/serializers.py index f882cd461c..5c2d16f003 100644 --- a/lms/djangoapps/commerce/api/v1/serializers.py +++ b/lms/djangoapps/commerce/api/v1/serializers.py @@ -47,7 +47,7 @@ def validate_course_id(course_id): try: course_key = CourseKey.from_string(six.text_type(course_id)) except InvalidKeyError: - raise serializers.ValidationError( + raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from _(u"{course_id} is not a valid course key.").format( course_id=course_id ) @@ -69,7 +69,7 @@ class PossiblyUndefinedDateTimeField(serializers.DateTimeField): def to_representation(self, value): if value is UNDEFINED: return None - return super(PossiblyUndefinedDateTimeField, self).to_representation(value) + return super(PossiblyUndefinedDateTimeField, self).to_representation(value) # lint-amnesty, pylint: disable=super-with-arguments class CourseSerializer(serializers.Serializer): diff --git a/lms/djangoapps/commerce/api/v1/tests/test_models.py b/lms/djangoapps/commerce/api/v1/tests/test_models.py index ff2b3e3d95..8b24aca57b 100644 --- a/lms/djangoapps/commerce/api/v1/tests/test_models.py +++ b/lms/djangoapps/commerce/api/v1/tests/test_models.py @@ -14,7 +14,7 @@ class CourseTests(TestCase): """ Tests for Course model. """ def setUp(self): - super(CourseTests, self).setUp() + super(CourseTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = Course('a/b/c', []) @ddt.unpack diff --git a/lms/djangoapps/commerce/api/v1/tests/test_views.py b/lms/djangoapps/commerce/api/v1/tests/test_views.py index a380d4f7de..b45ca537cd 100644 --- a/lms/djangoapps/commerce/api/v1/tests/test_views.py +++ b/lms/djangoapps/commerce/api/v1/tests/test_views.py @@ -35,7 +35,7 @@ class CourseApiViewTestMixin(object): """ def setUp(self): - super(CourseApiViewTestMixin, self).setUp() + super(CourseApiViewTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.course = CourseFactory.create() self.course_mode = CourseMode.objects.create( course_id=self.course.id, @@ -114,7 +114,7 @@ class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase) } def setUp(self): - super(CourseRetrieveUpdateViewTests, self).setUp() + super(CourseRetrieveUpdateViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.path = reverse('commerce_api:v1:courses:retrieve_update', args=[six.text_type(self.course.id)]) self.user = UserFactory.create() self.client.login(username=self.user.username, password=PASSWORD) @@ -450,7 +450,7 @@ class OrderViewTests(UserMixin, TestCase): path = reverse_lazy(view_name, kwargs={'number': ORDER_NUMBER}) def setUp(self): - super(OrderViewTests, self).setUp() + super(OrderViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self._login() def test_order_found(self): diff --git a/lms/djangoapps/commerce/api/v1/views.py b/lms/djangoapps/commerce/api/v1/views.py index 4ea967bf6c..80d3bd7fed 100644 --- a/lms/djangoapps/commerce/api/v1/views.py +++ b/lms/djangoapps/commerce/api/v1/views.py @@ -5,7 +5,7 @@ Commerce views import logging -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.http import Http404 from edx_rest_api_client import exceptions from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication @@ -53,7 +53,7 @@ class CourseRetrieveUpdateView(PutAsCreateMixin, RetrieveUpdateAPIView): # rather than a CourseMode, so this isn't really used. queryset = CourseMode.objects.all() - def get_object(self, queryset=None): + def get_object(self, queryset=None): # lint-amnesty, pylint: disable=arguments-differ, unused-argument course_id = self.kwargs.get(self.lookup_url_kwarg) course = Course.get(course_id) @@ -80,7 +80,7 @@ class OrderView(APIView): # anonymous user object attached to the request with the actual user object (if it exists) if not request.user.is_authenticated and is_account_activation_requirement_disabled(): try: - request.user = User.objects.get(id=request.session._session_cache['_auth_user_id']) + request.user = User.objects.get(id=request.session._session_cache['_auth_user_id']) # lint-amnesty, pylint: disable=protected-access except User.DoesNotExist: return JsonResponse(status=403) try: diff --git a/lms/djangoapps/commerce/exceptions.py b/lms/djangoapps/commerce/exceptions.py index 25b1535dd5..aa1b656c9e 100644 --- a/lms/djangoapps/commerce/exceptions.py +++ b/lms/djangoapps/commerce/exceptions.py @@ -3,4 +3,4 @@ class InvalidResponseError(Exception): """ Exception raised when an API response is invalid. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass diff --git a/lms/djangoapps/commerce/http.py b/lms/djangoapps/commerce/http.py index 01e19bb1e8..72406b652f 100644 --- a/lms/djangoapps/commerce/http.py +++ b/lms/djangoapps/commerce/http.py @@ -11,7 +11,7 @@ class DetailResponse(JsonResponse): def __init__(self, message, status=HTTP_200_OK): data = {'detail': message} - super(DetailResponse, self).__init__(resp_obj=data, status=status) + super(DetailResponse, self).__init__(resp_obj=data, status=status) # lint-amnesty, pylint: disable=super-with-arguments class InternalRequestErrorResponse(DetailResponse): @@ -22,4 +22,4 @@ class InternalRequestErrorResponse(DetailResponse): u'Call to E-Commerce API failed. Internal Service Message: [{internal_message}]' .format(internal_message=internal_message) ) - super(InternalRequestErrorResponse, self).__init__(message=message, status=HTTP_500_INTERNAL_SERVER_ERROR) + super(InternalRequestErrorResponse, self).__init__(message=message, status=HTTP_500_INTERNAL_SERVER_ERROR) # lint-amnesty, pylint: disable=super-with-arguments diff --git a/lms/djangoapps/commerce/management/commands/create_orders_for_old_enterprise_course_enrollment.py b/lms/djangoapps/commerce/management/commands/create_orders_for_old_enterprise_course_enrollment.py index 839a5fbd6a..3fbe39a6ea 100644 --- a/lms/djangoapps/commerce/management/commands/create_orders_for_old_enterprise_course_enrollment.py +++ b/lms/djangoapps/commerce/management/commands/create_orders_for_old_enterprise_course_enrollment.py @@ -289,4 +289,4 @@ class Command(BaseCommand): except Exception as ex: traceback.print_exc() - raise CommandError(u'Command failed with traceback %s' % str(ex)) + raise CommandError(u'Command failed with traceback %s' % str(ex)) # lint-amnesty, pylint: disable=raise-missing-from diff --git a/lms/djangoapps/commerce/tests/__init__.py b/lms/djangoapps/commerce/tests/__init__.py index 69d0ea84af..f78b542aa2 100644 --- a/lms/djangoapps/commerce/tests/__init__.py +++ b/lms/djangoapps/commerce/tests/__init__.py @@ -34,7 +34,7 @@ class EdxRestApiClientTest(TestCase): ] def setUp(self): - super(EdxRestApiClientTest, self).setUp() + super(EdxRestApiClientTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() @httpretty.activate diff --git a/lms/djangoapps/commerce/tests/mocks.py b/lms/djangoapps/commerce/tests/mocks.py index 0abdd46e70..15a5c88f49 100644 --- a/lms/djangoapps/commerce/tests/mocks.py +++ b/lms/djangoapps/commerce/tests/mocks.py @@ -95,7 +95,7 @@ class mock_basket_order(mock_ecommerce_api_endpoint): method = httpretty.GET def __init__(self, basket_id, **kwargs): - super(mock_basket_order, self).__init__(**kwargs) + super(mock_basket_order, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.basket_id = basket_id def get_path(self): @@ -131,7 +131,7 @@ class mock_process_refund(mock_ecommerce_api_endpoint): method = httpretty.PUT def __init__(self, refund_id, **kwargs): - super(mock_process_refund, self).__init__(**kwargs) + super(mock_process_refund, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.refund_id = refund_id def get_path(self): @@ -145,7 +145,7 @@ class mock_order_endpoint(mock_ecommerce_api_endpoint): method = httpretty.GET def __init__(self, order_number, **kwargs): - super(mock_order_endpoint, self).__init__(**kwargs) + super(mock_order_endpoint, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.order_number = order_number def get_path(self): diff --git a/lms/djangoapps/commerce/tests/test_signals.py b/lms/djangoapps/commerce/tests/test_signals.py index f938c9272d..bfa2b1746f 100644 --- a/lms/djangoapps/commerce/tests/test_signals.py +++ b/lms/djangoapps/commerce/tests/test_signals.py @@ -40,7 +40,7 @@ class TestRefundSignal(TestCase): """ def setUp(self): - super(TestRefundSignal, self).setUp() + super(TestRefundSignal, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Ensure the E-Commerce service user exists UserFactory(username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME, is_staff=True) diff --git a/lms/djangoapps/commerce/tests/test_utils.py b/lms/djangoapps/commerce/tests/test_utils.py index 32faf2e647..81b93bd034 100644 --- a/lms/djangoapps/commerce/tests/test_utils.py +++ b/lms/djangoapps/commerce/tests/test_utils.py @@ -61,7 +61,7 @@ class EcommerceServiceTests(TestCase): self.user = UserFactory.create() self.request = self.request_factory.get("foo") update_commerce_config(enabled=True) - super(EcommerceServiceTests, self).setUp() + super(EcommerceServiceTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments def test_is_enabled(self): """Verify that is_enabled() returns True when ecomm checkout is enabled. """ @@ -187,7 +187,7 @@ class RefundUtilMethodTests(ModuleStoreTestCase): """Tests for Refund Utilities""" def setUp(self): - super(RefundUtilMethodTests, self).setUp() + super(RefundUtilMethodTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() UserFactory(username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME, is_staff=True) diff --git a/lms/djangoapps/commerce/tests/test_views.py b/lms/djangoapps/commerce/tests/test_views.py index 2230ac8a77..e7d3c42865 100644 --- a/lms/djangoapps/commerce/tests/test_views.py +++ b/lms/djangoapps/commerce/tests/test_views.py @@ -7,7 +7,7 @@ class UserMixin(object): """ Mixin for tests involving users. """ def setUp(self): - super(UserMixin, self).setUp() + super(UserMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() def _login(self): diff --git a/lms/djangoapps/commerce/utils.py b/lms/djangoapps/commerce/utils.py index 5037a535b8..80e6356651 100644 --- a/lms/djangoapps/commerce/utils.py +++ b/lms/djangoapps/commerce/utils.py @@ -18,7 +18,7 @@ from common.djangoapps.course_modes.models import CourseMode from openedx.core.djangoapps.commerce.utils import ecommerce_api_client, is_commerce_service_configured from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangoapps.theming import helpers as theming_helpers -from common.djangoapps.student.models import CourseEnrollment +from common.djangoapps.student.models import CourseEnrollment # lint-amnesty, pylint: disable=unused-import from .models import CommerceConfiguration