diff --git a/openedx/core/djangoapps/system_wide_roles/models.py b/openedx/core/djangoapps/system_wide_roles/models.py index f5542b48f6..8ffff36d01 100644 --- a/openedx/core/djangoapps/system_wide_roles/models.py +++ b/openedx/core/djangoapps/system_wide_roles/models.py @@ -41,7 +41,7 @@ class SystemWideRoleAssignment(UserRoleAssignment): # pylint: disable=model-mis str_representation = "" return str_representation.format( user=self.user.id, - role=self.role.name + role=self.role.name # lint-amnesty, pylint: disable=no-member ) def __repr__(self): diff --git a/openedx/core/djangoapps/system_wide_roles/tests/test_models.py b/openedx/core/djangoapps/system_wide_roles/tests/test_models.py index 1349605023..5926fc02ef 100644 --- a/openedx/core/djangoapps/system_wide_roles/tests/test_models.py +++ b/openedx/core/djangoapps/system_wide_roles/tests/test_models.py @@ -13,7 +13,7 @@ class SystemWideRoleTests(TestCase): """ Tests for SystemWideRole in system_wide_roles app """ def setUp(self): - super(SystemWideRoleTests, self).setUp() + super(SystemWideRoleTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.role = SystemWideRole.objects.create(name='TestRole') def test_str(self): @@ -27,7 +27,7 @@ class SystemWideRoleAssignmentTests(TestCase): """ Tests for SystemWideRoleAssignment in system_wide_roles app """ def setUp(self): - super(SystemWideRoleAssignmentTests, self).setUp() + super(SystemWideRoleAssignmentTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() self.role = SystemWideRole.objects.create(name='TestRole') diff --git a/openedx/core/djangoapps/theming/apps.py b/openedx/core/djangoapps/theming/apps.py index e16f39b79a..b64c37a9df 100644 --- a/openedx/core/djangoapps/theming/apps.py +++ b/openedx/core/djangoapps/theming/apps.py @@ -1,4 +1,4 @@ - +# lint-amnesty, pylint: disable=missing-module-docstring from django.apps import AppConfig from edx_django_utils.plugins import PluginURLs @@ -8,7 +8,7 @@ from openedx.core.djangoapps.plugins.constants import ProjectType plugin_urls_config = {PluginURLs.NAMESPACE: u'theming', PluginURLs.REGEX: r'^theming/'} -class ThemingConfig(AppConfig): +class ThemingConfig(AppConfig): # lint-amnesty, pylint: disable=missing-class-docstring name = 'openedx.core.djangoapps.theming' plugin_app = { PluginURLs.CONFIG: { @@ -20,4 +20,4 @@ class ThemingConfig(AppConfig): def ready(self): # settings validations related to theming. - from . import checks + from . import checks # lint-amnesty, pylint: disable=unused-import diff --git a/openedx/core/djangoapps/theming/checks.py b/openedx/core/djangoapps/theming/checks.py index bb40a933e0..f5847f1cb1 100644 --- a/openedx/core/djangoapps/theming/checks.py +++ b/openedx/core/djangoapps/theming/checks.py @@ -11,7 +11,7 @@ from django.core.checks import Error, Tags, register @register(Tags.compatibility) -def check_comprehensive_theme_settings(app_configs, **kwargs): +def check_comprehensive_theme_settings(app_configs, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Checks the comprehensive theming theme directory settings. @@ -24,7 +24,7 @@ def check_comprehensive_theme_settings(app_configs, **kwargs): Returns: List of any Errors. """ - if not getattr(settings, "ENABLE_COMPREHENSIVE_THEMING"): + if not getattr(settings, "ENABLE_COMPREHENSIVE_THEMING"): # lint-amnesty, pylint: disable=literal-used-as-attribute # Only perform checks when comprehensive theming is enabled. return [] diff --git a/openedx/core/djangoapps/theming/finders.py b/openedx/core/djangoapps/theming/finders.py index c16082efc3..6d606a9602 100644 --- a/openedx/core/djangoapps/theming/finders.py +++ b/openedx/core/djangoapps/theming/finders.py @@ -30,7 +30,7 @@ from openedx.core.djangoapps.theming.helpers import get_themes from openedx.core.djangoapps.theming.storage import ThemeStorage -class ThemeFilesFinder(BaseFinder): +class ThemeFilesFinder(BaseFinder): # lint-amnesty, pylint: disable=abstract-method """ A static files finder that looks in the directory of each theme as specified in the source_dir attribute. @@ -55,7 +55,7 @@ class ThemeFilesFinder(BaseFinder): if theme.theme_dir_name not in self.themes: self.themes.append(theme.theme_dir_name) - super(ThemeFilesFinder, self).__init__(*args, **kwargs) + super(ThemeFilesFinder, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments def list(self, ignore_patterns): """ diff --git a/openedx/core/djangoapps/theming/helpers.py b/openedx/core/djangoapps/theming/helpers.py index fd2f793546..4e24781339 100644 --- a/openedx/core/djangoapps/theming/helpers.py +++ b/openedx/core/djangoapps/theming/helpers.py @@ -27,7 +27,7 @@ logger = getLogger(__name__) # pylint: disable=invalid-name @request_cached() -def get_template_path(relative_path, **kwargs): +def get_template_path(relative_path, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ The calculated value is cached for the lifetime of the current request. """ diff --git a/openedx/core/djangoapps/theming/helpers_static.py b/openedx/core/djangoapps/theming/helpers_static.py index 1b279551fb..5cdb6ffc60 100644 --- a/openedx/core/djangoapps/theming/helpers_static.py +++ b/openedx/core/djangoapps/theming/helpers_static.py @@ -1,4 +1,4 @@ - +# lint-amnesty, pylint: disable=missing-module-docstring from django.contrib.staticfiles.storage import staticfiles_storage diff --git a/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py b/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py index edbc54297f..0b336dca24 100644 --- a/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py +++ b/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py @@ -9,7 +9,7 @@ import logging import os from textwrap import dedent -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.sites.models import Site from django.core.management.base import BaseCommand from oauth2_provider.models import Application diff --git a/openedx/core/djangoapps/theming/management/commands/tests/test_create_sites_and_configurations.py b/openedx/core/djangoapps/theming/management/commands/tests/test_create_sites_and_configurations.py index aec1e4451e..ff1c42694a 100644 --- a/openedx/core/djangoapps/theming/management/commands/tests/test_create_sites_and_configurations.py +++ b/openedx/core/djangoapps/theming/management/commands/tests/test_create_sites_and_configurations.py @@ -4,7 +4,7 @@ Test cases for create_sites_and_configurations command. import mock -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.sites.models import Site from django.core.management import CommandError, call_command from django.test import TestCase @@ -54,7 +54,7 @@ def _get_sites(dns_name, devstack=False): class TestCreateSiteAndConfiguration(TestCase): """ Test the create_site_and_configuration command """ def setUp(self): - super(TestCreateSiteAndConfiguration, self).setUp() + super(TestCreateSiteAndConfiguration, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.dns_name = "dummy_dns" self.theme_path = "/dummyA/dummyB/" @@ -79,7 +79,7 @@ class TestCreateSiteAndConfiguration(TestCase): _generate_site_config(self.dns_name, site.name) ) - def _assert_service_user_is_valid(self, username): + def _assert_service_user_is_valid(self, username): # lint-amnesty, pylint: disable=missing-function-docstring service_user = User.objects.filter(username=username) self.assertEqual(len(service_user), 1) self.assertTrue(service_user[0].is_active) diff --git a/openedx/core/djangoapps/theming/storage.py b/openedx/core/djangoapps/theming/storage.py index 61254c9d79..43f22617c1 100644 --- a/openedx/core/djangoapps/theming/storage.py +++ b/openedx/core/djangoapps/theming/storage.py @@ -41,7 +41,7 @@ class ThemeMixin(object): def __init__(self, **kwargs): self.prefix = kwargs.pop('prefix', None) - super(ThemeMixin, self).__init__(**kwargs) + super(ThemeMixin, self).__init__(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments def url(self, name): """ @@ -70,7 +70,7 @@ class ThemeMixin(object): if prefix and self.themed(name, prefix): name = os.path.join(prefix, name) - return super(ThemeMixin, self).url(name) + return super(ThemeMixin, self).url(name) # lint-amnesty, pylint: disable=super-with-arguments def themed(self, name, theme): """ @@ -287,7 +287,7 @@ class ThemePipelineMixin(PipelineMixin): paths[output_file] = (self, output_file) yield output_file, output_file, True - super_class = super(ThemePipelineMixin, self) + super_class = super(ThemePipelineMixin, self) # lint-amnesty, pylint: disable=super-with-arguments if hasattr(super_class, 'post_process'): for name, hashed_name, processed in super_class.post_process(paths.copy(), dry_run, **options): yield name, hashed_name, processed diff --git a/openedx/core/djangoapps/theming/template_loaders.py b/openedx/core/djangoapps/theming/template_loaders.py index 803b2d27d5..140d49ffc8 100644 --- a/openedx/core/djangoapps/theming/template_loaders.py +++ b/openedx/core/djangoapps/theming/template_loaders.py @@ -17,7 +17,7 @@ class ThemeTemplateLoader(MakoLoader): _accepts_engine_in_init = True def __init__(self, *args): - MakoLoader.__init__(self, ThemeFilesystemLoader(*args)) + MakoLoader.__init__(self, ThemeFilesystemLoader(*args)) # lint-amnesty, pylint: disable=no-value-for-parameter class ThemeFilesystemLoader(FilesystemLoader): @@ -33,7 +33,7 @@ class ThemeFilesystemLoader(FilesystemLoader): theme_dirs = self.get_theme_template_sources() if isinstance(theme_dirs, list): self.dirs = theme_dirs + self.dirs - super(ThemeFilesystemLoader, self).__init__(engine, self.dirs) + super(ThemeFilesystemLoader, self).__init__(engine, self.dirs) # lint-amnesty, pylint: disable=super-with-arguments @staticmethod def get_theme_template_sources(): diff --git a/openedx/core/djangoapps/theming/templatetags/theme_pipeline.py b/openedx/core/djangoapps/theming/templatetags/theme_pipeline.py index 26f4aa2cc6..08bf17758e 100644 --- a/openedx/core/djangoapps/theming/templatetags/theme_pipeline.py +++ b/openedx/core/djangoapps/theming/templatetags/theme_pipeline.py @@ -56,7 +56,7 @@ def stylesheet(parser, token): # pylint: disable=unused-argument try: _, name = token.split_contents() except ValueError: - raise template.TemplateSyntaxError( + raise template.TemplateSyntaxError( # lint-amnesty, pylint: disable=raise-missing-from u'%r requires exactly one argument: the name of a group in the PIPELINE["STYLESHEETS"] setting' % token.split_contents()[0] ) @@ -71,7 +71,7 @@ def javascript(parser, token): # pylint: disable=unused-argument try: _, name = token.split_contents() except ValueError: - raise template.TemplateSyntaxError( + raise template.TemplateSyntaxError( # lint-amnesty, pylint: disable=raise-missing-from u'%r requires exactly one argument: the name of a group in the PIPELINE["JAVASCRIPT"] setting' % token.split_contents()[0] ) diff --git a/openedx/core/djangoapps/theming/tests/test_commands.py b/openedx/core/djangoapps/theming/tests/test_commands.py index d9f775bf0b..2dfb82109f 100644 --- a/openedx/core/djangoapps/theming/tests/test_commands.py +++ b/openedx/core/djangoapps/theming/tests/test_commands.py @@ -16,7 +16,7 @@ class TestUpdateAssets(TestCase): Test comprehensive theming helper functions. """ def setUp(self): - super(TestUpdateAssets, self).setUp() + super(TestUpdateAssets, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.themes = get_themes() def test_errors_for_invalid_arguments(self): diff --git a/openedx/core/djangoapps/theming/tests/test_finders.py b/openedx/core/djangoapps/theming/tests/test_finders.py index ba35e2d164..de8e40e259 100644 --- a/openedx/core/djangoapps/theming/tests/test_finders.py +++ b/openedx/core/djangoapps/theming/tests/test_finders.py @@ -17,7 +17,7 @@ class TestThemeFinders(TestCase): """ def setUp(self): - super(TestThemeFinders, self).setUp() + super(TestThemeFinders, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.finder = ThemeFilesFinder() def test_find_first_themed_asset(self): diff --git a/openedx/core/djangoapps/theming/tests/test_helpers.py b/openedx/core/djangoapps/theming/tests/test_helpers.py index 3785098a54..503ff33d87 100644 --- a/openedx/core/djangoapps/theming/tests/test_helpers.py +++ b/openedx/core/djangoapps/theming/tests/test_helpers.py @@ -6,7 +6,7 @@ Test helpers for Comprehensive Theming. import six from django.conf import settings from django.test import TestCase, override_settings -from edx_django_utils.cache import RequestCache +from edx_django_utils.cache import RequestCache # lint-amnesty, pylint: disable=unused-import from mock import Mock, patch from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers diff --git a/openedx/core/djangoapps/theming/tests/test_middleware.py b/openedx/core/djangoapps/theming/tests/test_middleware.py index 97eff107b1..cdc89abc87 100644 --- a/openedx/core/djangoapps/theming/tests/test_middleware.py +++ b/openedx/core/djangoapps/theming/tests/test_middleware.py @@ -24,7 +24,7 @@ class TestCurrentSiteThemeMiddleware(TestCase): """ Initialize middleware and related objects """ - super(TestCurrentSiteThemeMiddleware, self).setUp() + super(TestCurrentSiteThemeMiddleware, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.site_theme_middleware = CurrentSiteThemeMiddleware() self.user = UserFactory.create() @@ -59,8 +59,8 @@ class TestCurrentSiteThemeMiddleware(TestCase): """ request = self.create_mock_get_request() self.assertEqual(self.site_theme_middleware.process_request(request), None) - self.assertIsNotNone(request.site_theme) - self.assertEqual(request.site_theme.theme_dir_name, TEST_THEME_NAME) + self.assertIsNotNone(request.site_theme) # lint-amnesty, pylint: disable=no-member + self.assertEqual(request.site_theme.theme_dir_name, TEST_THEME_NAME) # lint-amnesty, pylint: disable=no-member @override_settings(DEFAULT_SITE_THEME=None) def test_default_site_theme_2(self): @@ -70,7 +70,7 @@ class TestCurrentSiteThemeMiddleware(TestCase): """ request = self.create_mock_get_request() self.assertEqual(self.site_theme_middleware.process_request(request), None) - self.assertIsNone(request.site_theme) + self.assertIsNone(request.site_theme) # lint-amnesty, pylint: disable=no-member def test_preview_theme(self): """ @@ -84,7 +84,7 @@ class TestCurrentSiteThemeMiddleware(TestCase): # Next request a page and verify that the theme is returned get_request = self.create_mock_get_request() self.assertEqual(self.site_theme_middleware.process_request(get_request), None) - self.assertEqual(get_request.site_theme.theme_dir_name, TEST_THEME_NAME) + self.assertEqual(get_request.site_theme.theme_dir_name, TEST_THEME_NAME) # lint-amnesty, pylint: disable=no-member # Request to reset the theme post_request = RequestFactory().post('/test') @@ -94,9 +94,9 @@ class TestCurrentSiteThemeMiddleware(TestCase): # Verify that no theme is returned now get_request = self.create_mock_get_request() self.assertEqual(self.site_theme_middleware.process_request(get_request), None) - self.assertIsNone(get_request.site_theme) + self.assertIsNone(get_request.site_theme) # lint-amnesty, pylint: disable=no-member # Verify that we can still force the theme with a querystring arg get_request = self.create_mock_get_request(qs_theme=TEST_THEME_NAME) self.assertEqual(self.site_theme_middleware.process_request(get_request), None) - self.assertEqual(get_request.site_theme.theme_dir_name, TEST_THEME_NAME) + self.assertEqual(get_request.site_theme.theme_dir_name, TEST_THEME_NAME) # lint-amnesty, pylint: disable=no-member diff --git a/openedx/core/djangoapps/theming/tests/test_storage.py b/openedx/core/djangoapps/theming/tests/test_storage.py index 70978924ca..a30f80f3e0 100644 --- a/openedx/core/djangoapps/theming/tests/test_storage.py +++ b/openedx/core/djangoapps/theming/tests/test_storage.py @@ -23,7 +23,7 @@ class TestStorageLMS(TestCase): """ def setUp(self): - super(TestStorageLMS, self).setUp() + super(TestStorageLMS, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.themes_dir = get_theme_base_dirs()[0] self.enabled_theme = "red-theme" self.system_dir = settings.REPO_ROOT / "lms" diff --git a/openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py b/openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py index eb5a8839c2..f080cb3cc6 100644 --- a/openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py +++ b/openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py @@ -9,7 +9,7 @@ from django.test import TestCase from django.urls import reverse from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme -from openedx.core.djangolib.testing.utils import skip_unless_cms, skip_unless_lms +from openedx.core.djangolib.testing.utils import skip_unless_cms, skip_unless_lms # lint-amnesty, pylint: disable=unused-import from common.djangoapps.student.tests.factories import UserFactory @@ -23,7 +23,7 @@ class TestComprehensiveThemeLMS(TestCase): """ Clear static file finders cache and register cleanup methods. """ - super(TestComprehensiveThemeLMS, self).setUp() + super(TestComprehensiveThemeLMS, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() # Clear the internal staticfiles caches, to get test isolation. @@ -152,7 +152,7 @@ class TestComprehensiveThemeDisabledLMS(TestCase): """ Clear static file finders cache. """ - super(TestComprehensiveThemeDisabledLMS, self).setUp() + super(TestComprehensiveThemeDisabledLMS, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Clear the internal staticfiles caches, to get test isolation. staticfiles.finders.get_finder.cache_clear() @@ -177,7 +177,7 @@ class TestStanfordTheme(TestCase): """ Clear static file finders cache and register cleanup methods. """ - super(TestStanfordTheme, self).setUp() + super(TestStanfordTheme, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Clear the internal staticfiles caches, to get test isolation. staticfiles.finders.get_finder.cache_clear() diff --git a/openedx/core/djangoapps/theming/tests/test_views.py b/openedx/core/djangoapps/theming/tests/test_views.py index 89af8f2c1b..cf32d29643 100644 --- a/openedx/core/djangoapps/theming/tests/test_views.py +++ b/openedx/core/djangoapps/theming/tests/test_views.py @@ -25,7 +25,7 @@ class TestThemingViews(TestCase): """ Initialize middleware and related objects """ - super(TestThemingViews, self).setUp() + super(TestThemingViews, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.site_theme_middleware = CurrentSiteThemeMiddleware() self.user = UserFactory.create() diff --git a/openedx/core/djangoapps/theming/views.py b/openedx/core/djangoapps/theming/views.py index af7c4e6dda..b5f40f3bc7 100644 --- a/openedx/core/djangoapps/theming/views.py +++ b/openedx/core/djangoapps/theming/views.py @@ -91,7 +91,7 @@ class ThemingAdministrationFragmentView(EdxFragmentView): Fragment view to allow a user to administer theming. """ - def render_to_fragment(self, request, course_id=None, **kwargs): + def render_to_fragment(self, request, course_id=None, **kwargs): # lint-amnesty, pylint: disable=arguments-differ, unused-argument """ Renders the theming administration view as a fragment. """ @@ -105,10 +105,10 @@ class ThemingAdministrationFragmentView(EdxFragmentView): """ if not user_can_preview_themes(request.user): raise Http404 - return super(ThemingAdministrationFragmentView, self).get(request, *args, **kwargs) + return super(ThemingAdministrationFragmentView, self).get(request, *args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments @method_decorator(login_required) - def post(self, request, **kwargs): + def post(self, request, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Accept requests to update the theme preview. """ diff --git a/openedx/core/djangoapps/user_api/accounts/api.py b/openedx/core/djangoapps/user_api/accounts/api.py index 57f2929024..cd2bd027d5 100644 --- a/openedx/core/djangoapps/user_api/accounts/api.py +++ b/openedx/core/djangoapps/user_api/accounts/api.py @@ -161,11 +161,11 @@ def update_account_settings(requesting_user, update, username=None): _update_state_if_needed(update, user_profile) except PreferenceValidationError as err: - raise AccountValidationError(err.preference_errors) + raise AccountValidationError(err.preference_errors) # lint-amnesty, pylint: disable=raise-missing-from except (AccountUpdateError, AccountValidationError) as err: raise err except Exception as err: - raise AccountUpdateError( + raise AccountUpdateError( # lint-amnesty, pylint: disable=raise-missing-from u"Error thrown when saving account updates: '{}'".format(text_type(err)) ) @@ -323,7 +323,7 @@ def _send_email_change_requests_if_needed(data, user): try: student_views.do_email_change_request(user, new_email) except ValueError as err: - raise AccountUpdateError( + raise AccountUpdateError( # lint-amnesty, pylint: disable=raise-missing-from u"Error thrown from do_email_change_request: '{}'".format(text_type(err)), user_message=text_type(err) ) @@ -337,7 +337,7 @@ def _send_email_change_requests_if_needed(data, user): secondary_email_change_request=True, ) except ValueError as err: - raise AccountUpdateError( + raise AccountUpdateError( # lint-amnesty, pylint: disable=raise-missing-from u"Error thrown from do_email_change_request: '{}'".format(text_type(err)), user_message=text_type(err) ) @@ -459,7 +459,7 @@ def _get_user_and_profile(username): try: existing_user = User.objects.get(username=username) except ObjectDoesNotExist: - raise errors.UserNotFound() + raise errors.UserNotFound() # lint-amnesty, pylint: disable=raise-missing-from existing_user_profile, _ = UserProfile.objects.get_or_create(user=existing_user) @@ -589,7 +589,7 @@ def _validate_country(country): :return: None """ - if country == '' or country == '--': + if country == '' or country == '--': # lint-amnesty, pylint: disable=consider-using-in raise errors.AccountCountryInvalid(accounts.REQUIRED_FIELD_COUNTRY_MSG) @@ -601,7 +601,7 @@ def _validate_username_doesnt_exist(username): :raises: errors.AccountUsernameAlreadyExists """ if username is not None and username_exists_or_retired(username): - raise errors.AccountUsernameAlreadyExists(_(accounts.USERNAME_CONFLICT_MSG).format(username=username)) + raise errors.AccountUsernameAlreadyExists(_(accounts.USERNAME_CONFLICT_MSG).format(username=username)) # lint-amnesty, pylint: disable=translation-of-non-string def _validate_email_doesnt_exist(email): @@ -612,7 +612,7 @@ def _validate_email_doesnt_exist(email): :raises: errors.AccountEmailAlreadyExists """ if email is not None and email_exists_or_retired(email): - raise errors.AccountEmailAlreadyExists(_(accounts.EMAIL_CONFLICT_MSG).format(email_address=email)) + raise errors.AccountEmailAlreadyExists(_(accounts.EMAIL_CONFLICT_MSG).format(email_address=email)) # lint-amnesty, pylint: disable=translation-of-non-string def _validate_secondary_email_doesnt_exist(email): @@ -646,10 +646,10 @@ def _validate_password_works_with_username(password, username=None): :raises: errors.AccountPasswordInvalid """ if password == username: - raise errors.AccountPasswordInvalid(accounts.PASSWORD_CANT_EQUAL_USERNAME_MSG) + raise errors.AccountPasswordInvalid(accounts.PASSWORD_CANT_EQUAL_USERNAME_MSG) # lint-amnesty, pylint: disable=no-member -def _validate_type(data, type, err): +def _validate_type(data, type, err): # lint-amnesty, pylint: disable=redefined-builtin """Checks whether the input data is of type. If not, throws a generic error message. @@ -664,7 +664,7 @@ def _validate_type(data, type, err): raise errors.AccountDataBadType(err) -def _validate_length(data, min, max, err): +def _validate_length(data, min, max, err): # lint-amnesty, pylint: disable=redefined-builtin """Validate that the data's length is less than or equal to max, and greater than or equal to min. @@ -695,4 +695,4 @@ def _validate_unicode(data, err=u"Input not valid unicode"): # In some cases we pass the above, but it's still inappropriate utf-8. six.text_type(data) except UnicodeError: - raise UnicodeError(err) + raise UnicodeError(err) # lint-amnesty, pylint: disable=raise-missing-from diff --git a/openedx/core/djangoapps/user_api/accounts/image_helpers.py b/openedx/core/djangoapps/user_api/accounts/image_helpers.py index a21fa88fd8..a825e67060 100644 --- a/openedx/core/djangoapps/user_api/accounts/image_helpers.py +++ b/openedx/core/djangoapps/user_api/accounts/image_helpers.py @@ -149,14 +149,14 @@ def set_has_profile_image(username, is_uploaded, upload_dt=None): ValueError: is_uploaded was True, but no upload datetime was supplied. UserNotFound: no user with username `username` exists. """ - if is_uploaded and upload_dt is None: + if is_uploaded and upload_dt is None: # lint-amnesty, pylint: disable=no-else-raise raise ValueError("No upload datetime was supplied.") elif not is_uploaded: upload_dt = None try: profile = UserProfile.objects.get(user__username=username) except ObjectDoesNotExist: - raise UserNotFound() + raise UserNotFound() # lint-amnesty, pylint: disable=raise-missing-from profile.profile_image_uploaded_at = upload_dt profile.save() diff --git a/openedx/core/djangoapps/user_api/accounts/serializers.py b/openedx/core/djangoapps/user_api/accounts/serializers.py index d3023f934c..213cda2c76 100644 --- a/openedx/core/djangoapps/user_api/accounts/serializers.py +++ b/openedx/core/djangoapps/user_api/accounts/serializers.py @@ -8,7 +8,7 @@ import logging import re from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ObjectDoesNotExist from django.urls import reverse from rest_framework import serializers @@ -39,7 +39,7 @@ PROFILE_IMAGE_KEY_PREFIX = 'image_url' LOGGER = logging.getLogger(__name__) -class PhoneNumberSerializer(serializers.BaseSerializer): +class PhoneNumberSerializer(serializers.BaseSerializer): # lint-amnesty, pylint: disable=abstract-method """ Class to serialize phone number into a digit only representation """ @@ -90,7 +90,7 @@ class SocialLinkSerializer(serializers.ModelSerializer): return platform -class UserReadOnlySerializer(serializers.Serializer): +class UserReadOnlySerializer(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method """ Class that serializes the User model and UserProfile model together. """ @@ -103,9 +103,9 @@ class UserReadOnlySerializer(serializers.Serializer): # Don't pass the 'custom_fields' arg up to the superclass self.custom_fields = kwargs.pop('custom_fields', []) - super(UserReadOnlySerializer, self).__init__(*args, **kwargs) + super(UserReadOnlySerializer, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments - def to_representation(self, user): + def to_representation(self, user): # lint-amnesty, pylint: disable=arguments-differ """ Overwrite to_native to handle custom logic since we are serializing three models as one here :param user: User object @@ -285,7 +285,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea """ Enforce all languages are unique. """ - language_proficiencies = [language for language in value] + language_proficiencies = [language for language in value] # lint-amnesty, pylint: disable=unnecessary-comprehension unique_language_proficiencies = set(language["code"] for language in language_proficiencies) if len(language_proficiencies) != len(unique_language_proficiencies): raise serializers.ValidationError("The language_proficiencies field must consist of unique languages.") @@ -295,7 +295,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea """ Enforce only one entry for a particular social platform. """ - social_links = [social_link for social_link in value] + social_links = [social_link for social_link in value] # lint-amnesty, pylint: disable=unnecessary-comprehension unique_social_links = set(social_link["platform"] for social_link in social_links) if len(social_links) != len(unique_social_links): raise serializers.ValidationError("The social_links field must consist of unique social platforms.") @@ -437,7 +437,7 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea ]) # Update the user's social links - requested_social_links = self._kwargs['data'].get('social_links') + requested_social_links = self._kwargs['data'].get('social_links') # lint-amnesty, pylint: disable=no-member if requested_social_links: self._update_social_links(instance, requested_social_links) diff --git a/openedx/core/djangoapps/user_api/accounts/settings_views.py b/openedx/core/djangoapps/user_api/accounts/settings_views.py index fa1b30d9cf..6f9cecdf41 100644 --- a/openedx/core/djangoapps/user_api/accounts/settings_views.py +++ b/openedx/core/djangoapps/user_api/accounts/settings_views.py @@ -113,11 +113,11 @@ def account_settings_context(request): 'country': { 'options': list(countries), }, 'gender': { - 'options': [(choice[0], _(choice[1])) for choice in UserProfile.GENDER_CHOICES], + 'options': [(choice[0], _(choice[1])) for choice in UserProfile.GENDER_CHOICES], # lint-amnesty, pylint: disable=translation-of-non-string }, 'language': { 'options': released_languages(), }, 'level_of_education': { - 'options': [(choice[0], _(choice[1])) for choice in UserProfile.LEVEL_OF_EDUCATION_CHOICES], + 'options': [(choice[0], _(choice[1])) for choice in UserProfile.LEVEL_OF_EDUCATION_CHOICES], # lint-amnesty, pylint: disable=translation-of-non-string }, 'password': { 'url': reverse('password_reset'), }, 'year_of_birth': { diff --git a/openedx/core/djangoapps/user_api/accounts/tests/retirement_helpers.py b/openedx/core/djangoapps/user_api/accounts/tests/retirement_helpers.py index 9dab0717b1..fffe2a2f1e 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/retirement_helpers.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/retirement_helpers.py @@ -152,10 +152,10 @@ class RetirementTestCase(TestCase): return [create_retirement_status(UserFactory(), state=state) for state in RetirementState.objects.all()] def _get_non_dead_end_states(self): - return [state for state in RetirementState.objects.filter(is_dead_end_state=False)] + return [state for state in RetirementState.objects.filter(is_dead_end_state=False)] # lint-amnesty, pylint: disable=unnecessary-comprehension def _get_dead_end_states(self): - return [state for state in RetirementState.objects.filter(is_dead_end_state=True)] + return [state for state in RetirementState.objects.filter(is_dead_end_state=True)] # lint-amnesty, pylint: disable=unnecessary-comprehension def fake_requested_retirement(user): diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_api.py b/openedx/core/djangoapps/user_api/accounts/tests/test_api.py index 2f05528375..2d15933157 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_api.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_api.py @@ -11,7 +11,7 @@ import unicodedata import ddt from django.conf import settings from django.contrib.auth.hashers import make_password -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 HttpResponse from django.test import TestCase from django.test.client import RequestFactory @@ -64,7 +64,7 @@ def mock_render_to_response(template_name): return HttpResponse(template_name) -class CreateAccountMixin(object): +class CreateAccountMixin(object): # lint-amnesty, pylint: disable=missing-class-docstring def create_account(self, username, password, email): # pylint: disable=missing-docstring registration_url = reverse('user_api_registration') @@ -80,7 +80,7 @@ class CreateAccountMixin(object): @skip_unless_lms @ddt.ddt -@patch('common.djangoapps.student.views.management.render_to_response', Mock(side_effect=mock_render_to_response, autospec=True)) +@patch('common.djangoapps.student.views.management.render_to_response', Mock(side_effect=mock_render_to_response, autospec=True)) # lint-amnesty, pylint: disable=line-too-long class TestAccountApi(UserSettingsEventTestMixin, EmailTemplateTagMixin, CreateAccountMixin, RetirementTestCase): """ These tests specifically cover the parts of the API methods that are not covered by test_views.py. @@ -90,7 +90,7 @@ class TestAccountApi(UserSettingsEventTestMixin, EmailTemplateTagMixin, CreateAc password = "test" def setUp(self): - super(TestAccountApi, self).setUp() + super(TestAccountApi, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.request_factory = RequestFactory() self.table = "student_languageproficiency" self.user = UserFactory.create(password=self.password) @@ -366,7 +366,7 @@ class TestAccountApi(UserSettingsEventTestMixin, EmailTemplateTagMixin, CreateAc self.assertIn("Full Name cannot contain the following characters: < >", field_errors["name"]["user_message"]) @patch('django.core.mail.EmailMultiAlternatives.send') - @patch('common.djangoapps.student.views.management.render_to_string', Mock(side_effect=mock_render_to_string, autospec=True)) + @patch('common.djangoapps.student.views.management.render_to_string', Mock(side_effect=mock_render_to_string, autospec=True)) # lint-amnesty, pylint: disable=line-too-long def test_update_sending_email_fails(self, send_mail): """Test what happens if all validation checks pass, but sending the email for email change fails.""" send_mail.side_effect = [Exception, None] diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py b/openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py index 5d42a89547..e41d55e980 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_image_helpers.py @@ -12,7 +12,7 @@ from pytz import UTC from openedx.core.djangolib.testing.utils import skip_unless_lms from common.djangoapps.student.tests.factories import UserFactory -from six import text_type +from six import text_type # lint-amnesty, pylint: disable=wrong-import-order from ..image_helpers import get_profile_image_urls_for_user @@ -28,12 +28,12 @@ class ProfileImageUrlTestCase(TestCase): """ def setUp(self): - super(ProfileImageUrlTestCase, self).setUp() + super(ProfileImageUrlTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() # Ensure that parental controls don't apply to this user self.user.profile.year_of_birth = 1980 self.user.profile.profile_image_uploaded_at = TEST_PROFILE_IMAGE_UPLOAD_DT - self.user.profile.save() + self.user.profile.save() # lint-amnesty, pylint: disable=no-member def verify_url(self, actual_url, expected_name, expected_pixels, expected_version): """ @@ -73,12 +73,12 @@ class ProfileImageUrlTestCase(TestCase): Tests `get_profile_image_urls_for_user` """ self.user.profile.profile_image_uploaded_at = TEST_PROFILE_IMAGE_UPLOAD_DT - self.user.profile.save() + self.user.profile.save() # lint-amnesty, pylint: disable=no-member expected_name = hashlib.md5(( 'secret' + text_type(self.user.username)).encode('utf-8')).hexdigest() actual_urls = get_profile_image_urls_for_user(self.user) self.verify_urls(actual_urls, expected_name, is_default=False) self.user.profile.profile_image_uploaded_at = None - self.user.profile.save() + self.user.profile.save() # lint-amnesty, pylint: disable=no-member self.verify_urls(get_profile_image_urls_for_user(self.user), 'default', is_default=True) diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_permissions.py b/openedx/core/djangoapps/user_api/accounts/tests/test_permissions.py index 44d6cf2bf7..0037c3b39f 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_permissions.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_permissions.py @@ -6,14 +6,14 @@ Tests for User deactivation API permissions from django.test import RequestFactory, TestCase from openedx.core.djangoapps.user_api.accounts.permissions import CanDeactivateUser, CanRetireUser -from common.djangoapps.student.tests.factories import ContentTypeFactory, PermissionFactory, SuperuserFactory, UserFactory +from common.djangoapps.student.tests.factories import ContentTypeFactory, PermissionFactory, SuperuserFactory, UserFactory # lint-amnesty, pylint: disable=line-too-long class CanDeactivateUserTest(TestCase): """ Tests for user deactivation API permissions """ def setUp(self): - super(CanDeactivateUserTest, self).setUp() + super(CanDeactivateUserTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.request = RequestFactory().get('/test/url') def test_api_permission_superuser(self): @@ -46,7 +46,7 @@ class CanRetireUserTest(TestCase): """ Tests for user retirement API permissions """ def setUp(self): - super(CanRetireUserTest, self).setUp() + super(CanRetireUserTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.request = RequestFactory().get('/test/url') def test_api_permission_superuser(self): diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py b/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py index 88e557fd5e..5d818abf90 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py @@ -14,7 +14,7 @@ import pytz import six from consent.models import DataSharingConsent from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.sites.models import Site from django.core import mail from django.core.cache import cache @@ -109,7 +109,7 @@ class TestAccountDeactivation(TestCase): """ def setUp(self): - super(TestAccountDeactivation, self).setUp() + super(TestAccountDeactivation, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_user = UserFactory() self.url = reverse('accounts_deactivation', kwargs={'username': self.test_user.username}) @@ -180,7 +180,7 @@ class TestDeactivateLogout(RetirementTestCase): Tests the account deactivation/logout endpoint. """ def setUp(self): - super(TestDeactivateLogout, self).setUp() + super(TestDeactivateLogout, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_password = 'password' self.test_user = UserFactory(password=self.test_password) UserSocialAuth.objects.create( @@ -277,7 +277,7 @@ class TestPartnerReportingCleanup(ModuleStoreTestCase): """ def setUp(self): - super(TestPartnerReportingCleanup, self).setUp() + super(TestPartnerReportingCleanup, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_superuser = SuperuserFactory() self.course = CourseFactory() self.course_awesome_org = CourseFactory(org='awesome_org') @@ -389,7 +389,7 @@ class TestPartnerReportingPut(RetirementTestCase, ModuleStoreTestCase): """ def setUp(self): - super(TestPartnerReportingPut, self).setUp() + super(TestPartnerReportingPut, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_superuser = SuperuserFactory() self.course = CourseFactory() self.course_awesome_org = CourseFactory(org='awesome_org') @@ -468,8 +468,8 @@ class TestPartnerReportingPut(RetirementTestCase, ModuleStoreTestCase): # the orgs from our PUT operation, so this is the best way to make sure it's doing the right # thing. orgs = AccountRetirementPartnerReportView._get_orgs_for_user(user) # pylint: disable=protected-access - self.assertTrue(len(orgs) == 1) - self.assertTrue('edX' in orgs) + self.assertTrue(len(orgs) == 1) # lint-amnesty, pylint: disable=wrong-assert-type + self.assertTrue('edX' in orgs) # lint-amnesty, pylint: disable=wrong-assert-type # PUT should succeed self.put_and_assert_status({'username': user.username}) @@ -496,7 +496,7 @@ class TestPartnerReportingList(ModuleStoreTestCase): ] def setUp(self): - super(TestPartnerReportingList, self).setUp() + super(TestPartnerReportingList, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_superuser = SuperuserFactory() self.course = CourseFactory() self.course_awesome_org = CourseFactory(org='awesome_org') @@ -596,8 +596,8 @@ class TestPartnerReportingList(ModuleStoreTestCase): """ Basic test to make sure that users in two different orgs are returned. """ - user_dicts, users = self.create_partner_reporting_statuses() - additional_dicts, additional_users = self.create_partner_reporting_statuses(courses=(self.course_awesome_org,)) + user_dicts, users = self.create_partner_reporting_statuses() # lint-amnesty, pylint: disable=unused-variable + additional_dicts, additional_users = self.create_partner_reporting_statuses(courses=(self.course_awesome_org,)) # lint-amnesty, pylint: disable=unused-variable user_dicts += additional_dicts self.assert_status_and_user_list(user_dicts) @@ -606,7 +606,7 @@ class TestPartnerReportingList(ModuleStoreTestCase): """ Checks that only users in the correct is_being_processed state (False) are returned. """ - user_dicts, users = self.create_partner_reporting_statuses() + user_dicts, users = self.create_partner_reporting_statuses() # lint-amnesty, pylint: disable=unused-variable # These should not come back self.create_partner_reporting_statuses(courses=(self.course_awesome_org,), is_being_processed=True) @@ -621,7 +621,7 @@ class TestPartnerReportingList(ModuleStoreTestCase): path = 'openedx.core.djangoapps.user_api.accounts.views.has_ever_consented_to_coaching' with mock.patch(path, return_value=True) as mock_has_ever_consented: user_dicts, users = self.create_partner_reporting_statuses(num=1) - external_id, created = ExternalId.add_new_user_id( + external_id, created = ExternalId.add_new_user_id( # lint-amnesty, pylint: disable=unused-variable user=users[0], type_name=ExternalIdType.MICROBACHELORS_COACHING ) @@ -642,7 +642,7 @@ class TestPartnerReportingList(ModuleStoreTestCase): """ path = 'openedx.core.djangoapps.user_api.accounts.views.has_ever_consented_to_coaching' with mock.patch(path, return_value=True) as mock_has_ever_consented: - user_dicts, users = self.create_partner_reporting_statuses(num=1) + user_dicts, users = self.create_partner_reporting_statuses(num=1) # lint-amnesty, pylint: disable=unused-variable self.assert_status_and_user_list(user_dicts) mock_has_ever_consented.assert_called_once() @@ -682,7 +682,7 @@ class TestPartnerReportingList(ModuleStoreTestCase): Checks that users are progressed to "is_being_processed" True upon being returned from this call. """ - user_dicts, users = self.create_partner_reporting_statuses() + user_dicts, users = self.create_partner_reporting_statuses() # lint-amnesty, pylint: disable=unused-variable # First time through we should get the users self.assert_status_and_user_list(user_dicts) @@ -698,7 +698,7 @@ class TestAccountRetirementList(RetirementTestCase): """ def setUp(self): - super(TestAccountRetirementList, self).setUp() + super(TestAccountRetirementList, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_superuser = SuperuserFactory() self.headers = build_jwt_headers(self.test_superuser) self.url = reverse('accounts_retirement_queue') @@ -723,7 +723,7 @@ class TestAccountRetirementList(RetirementTestCase): try: states_to_request = [s.state_name for s in states_to_request] except AttributeError: - states_to_request = states_to_request + states_to_request = states_to_request # lint-amnesty, pylint: disable=self-assigning-variable data = {'cool_off_days': cool_off_days, 'states': states_to_request} response = self.client.get(self.url, data, **self.headers) @@ -858,7 +858,7 @@ class TestAccountRetirementsByStatusAndDate(RetirementTestCase): """ def setUp(self): - super(TestAccountRetirementsByStatusAndDate, self).setUp() + super(TestAccountRetirementsByStatusAndDate, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_superuser = SuperuserFactory() self.headers = build_jwt_headers(self.test_superuser) self.url = reverse('accounts_retirements_by_status_and_date') @@ -952,7 +952,7 @@ class TestAccountRetirementsByStatusAndDate(RetirementTestCase): complete_state = RetirementState.objects.get(state_name='COMPLETE') # Create retirements for the last 10 days - for days_back in range(0, 10): + for days_back in range(0, 10): # lint-amnesty, pylint: disable=simplifiable-range create_datetime = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=days_back) ret = create_retirement_status(UserFactory(), state=complete_state, create_datetime=create_datetime) retirements.append(self._retirement_to_dict(ret)) @@ -1005,7 +1005,7 @@ class TestAccountRetirementRetrieve(RetirementTestCase): Tests the account retirement retrieval endpoint. """ def setUp(self): - super(TestAccountRetirementRetrieve, self).setUp() + super(TestAccountRetirementRetrieve, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_user = UserFactory() self.test_superuser = SuperuserFactory() self.url = reverse('accounts_retirement_retrieve', kwargs={'username': self.test_user.username}) @@ -1076,7 +1076,7 @@ class TestAccountRetirementCleanup(RetirementTestCase): Tests the account retirement cleanup endpoint. """ def setUp(self): - super(TestAccountRetirementCleanup, self).setUp() + super(TestAccountRetirementCleanup, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.pending_state = RetirementState.objects.get(state_name='PENDING') self.complete_state = RetirementState.objects.get(state_name='COMPLETE') self.retirements = [] @@ -1153,7 +1153,7 @@ class TestAccountRetirementUpdate(RetirementTestCase): Tests the account retirement endpoint. """ def setUp(self): - super(TestAccountRetirementUpdate, self).setUp() + super(TestAccountRetirementUpdate, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.pending_state = RetirementState.objects.get(state_name='PENDING') self.locking_state = RetirementState.objects.get(state_name='LOCKING_ACCOUNT') @@ -1293,7 +1293,7 @@ class TestAccountRetirementPost(RetirementTestCase): Tests the account retirement endpoint. """ def setUp(self): - super(TestAccountRetirementPost, self).setUp() + super(TestAccountRetirementPost, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_user = UserFactory() self.test_superuser = SuperuserFactory() @@ -1574,7 +1574,7 @@ class TestLMSAccountRetirementPost(RetirementTestCase, ModuleStoreTestCase): Tests the LMS account retirement (GDPR P2) endpoint. """ def setUp(self): - super(TestLMSAccountRetirementPost, self).setUp() + super(TestLMSAccountRetirementPost, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.pii_standin = 'PII here' self.course = CourseFactory() self.test_user = UserFactory() @@ -1602,14 +1602,14 @@ class TestLMSAccountRetirementPost(RetirementTestCase, ModuleStoreTestCase): ArticleRevision.objects.create(ip_address="ipaddresss", user=self.test_user, article=article) # ManualEnrollmentAudit setup - course_enrollment = CourseEnrollment.enroll(user=self.test_user, course_key=self.course.id) + course_enrollment = CourseEnrollment.enroll(user=self.test_user, course_key=self.course.id) # lint-amnesty, pylint: disable=no-member ManualEnrollmentAudit.objects.create( enrollment=course_enrollment, reason=self.pii_standin, enrolled_email=self.pii_standin ) # CreditRequest and CreditRequirementStatus setup provider = CreditProvider.objects.create(provider_id="Hogwarts") - credit_course = CreditCourse.objects.create(course_key=self.course.id) + credit_course = CreditCourse.objects.create(course_key=self.course.id) # lint-amnesty, pylint: disable=no-member CreditRequest.objects.create( username=self.test_user.username, course=credit_course, diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_serializers.py b/openedx/core/djangoapps/user_api/accounts/tests/test_serializers.py index 72b69b99ed..de22e7bc16 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_serializers.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_serializers.py @@ -16,9 +16,9 @@ from common.djangoapps.student.tests.factories import UserFactory LOGGER_NAME = "openedx.core.djangoapps.user_api.accounts.serializers" -class UserReadOnlySerializerTest(TestCase): +class UserReadOnlySerializerTest(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring def setUp(self): - super(UserReadOnlySerializerTest, self).setUp() + super(UserReadOnlySerializerTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments request_factory = RequestFactory() self.request = request_factory.get('/api/user/v1/accounts/') self.user = UserFactory.build(username='test_user', email='test_user@test.com') diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_settings_views.py b/openedx/core/djangoapps/user_api/accounts/tests/test_settings_views.py index 840028988c..935b03f1c2 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_settings_views.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_settings_views.py @@ -49,7 +49,7 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, SiteMixin, ProgramsApiCon @mock.patch("django.conf.settings.MESSAGE_STORAGE", 'django.contrib.messages.storage.cookie.CookieStorage') def setUp(self): # pylint: disable=arguments-differ - super(AccountSettingsViewTest, self).setUp() + super(AccountSettingsViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username=self.USERNAME, password=self.PASSWORD) CommerceConfiguration.objects.create(cache_ttl=10, enabled=True) self.client.login(username=self.USERNAME, password=self.PASSWORD) diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_utils.py b/openedx/core/djangoapps/user_api/accounts/tests/test_utils.py index b1e7d73a61..07f790cdbd 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_utils.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_utils.py @@ -21,8 +21,8 @@ from ..utils import format_social_link, validate_social_link class UserAccountSettingsTest(TestCase): """Unit tests for setting Social Media Links.""" - def setUp(self): - super(UserAccountSettingsTest, self).setUp() + def setUp(self): # lint-amnesty, pylint: disable=useless-super-delegation + super(UserAccountSettingsTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments def validate_social_link(self, social_platform, link): """ @@ -71,7 +71,7 @@ class CompletionUtilsTestCase(SharedModuleStoreTestCase, CompletionWaffleTestMix """ Creates a test course that can be used for non-destructive tests """ - super(CompletionUtilsTestCase, self).setUp() + super(CompletionUtilsTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.override_waffle_switch(True) self.engaged_user = UserFactory.create() self.cruft_user = UserFactory.create() diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_views.py b/openedx/core/djangoapps/user_api/accounts/tests/test_views.py index 867176e83a..d65a788a6f 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_views.py @@ -47,7 +47,7 @@ class UserAPITestCase(APITestCase): """ def setUp(self): - super(UserAPITestCase, self).setUp() + super(UserAPITestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.anonymous_client = APIClient() self.different_user = UserFactory.create(password=TEST_PASSWORD) @@ -156,7 +156,7 @@ class TestOwnUsernameAPI(CacheIsolationTestCase, UserAPITestCase): ENABLED_CACHES = ['default'] def setUp(self): - super(TestOwnUsernameAPI, self).setUp() + super(TestOwnUsernameAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("own_username_api") @@ -214,7 +214,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): ENABLED_CACHES = ['default'] def setUp(self): - super(TestAccountsAPI, self).setUp() + super(TestAccountsAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("accounts_api", kwargs={'username': self.user.username}) @@ -948,7 +948,7 @@ class TestAccountAPITransactions(TransactionTestCase): """ def setUp(self): - super(TestAccountAPITransactions, self).setUp() + super(TestAccountAPITransactions, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = APIClient() self.user = UserFactory.create(password=TEST_PASSWORD) self.url = reverse("accounts_api", kwargs={'username': self.user.username}) @@ -983,7 +983,7 @@ class UsernameReplacementViewTests(APITestCase): SERVICE_USERNAME = 'test_replace_username_service_worker' def setUp(self): - super(UsernameReplacementViewTests, self).setUp() + super(UsernameReplacementViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.service_user = UserFactory(username=self.SERVICE_USERNAME) self.url = reverse("username_replacement") diff --git a/openedx/core/djangoapps/user_api/accounts/utils.py b/openedx/core/djangoapps/user_api/accounts/utils.py index f29c1f5280..205b54edb0 100644 --- a/openedx/core/djangoapps/user_api/accounts/utils.py +++ b/openedx/core/djangoapps/user_api/accounts/utils.py @@ -11,7 +11,7 @@ from completion.models import BlockCompletion from django.conf import settings from django.utils.translation import ugettext as _ from six import text_type -from six.moves import range +from six.moves import range # lint-amnesty, pylint: disable=unused-import from six.moves.urllib.parse import urlparse # pylint: disable=import-error from common.djangoapps.third_party_auth.config.waffle import ENABLE_MULTIPLE_SSO_ACCOUNTS_ASSOCIATION_TO_SAML_USER diff --git a/openedx/core/djangoapps/user_api/accounts/views.py b/openedx/core/djangoapps/user_api/accounts/views.py index 4ca93c57f1..651e2e5121 100644 --- a/openedx/core/djangoapps/user_api/accounts/views.py +++ b/openedx/core/djangoapps/user_api/accounts/views.py @@ -52,7 +52,7 @@ from openedx.core.djangoapps.user_authn.exceptions import AuthFailedError from openedx.core.djangolib.oauth2_retirement_utils import retire_dot_oauth2_models from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser from openedx.core.lib.api.parsers import MergePatchParser -from common.djangoapps.student.models import ( +from common.djangoapps.student.models import ( # lint-amnesty, pylint: disable=unused-import AccountRecovery, CourseEnrollment, CourseEnrollmentAllowed, @@ -869,7 +869,7 @@ class AccountRetirementStatusView(ViewSet): # than one row returned here (due to our MySQL collation being case-insensitive), and need # to disambiguate them in Python, which will respect case in the comparison. retirement = None - if len(retirements) < 1: + if len(retirements) < 1: # lint-amnesty, pylint: disable=no-else-raise raise UserRetirementStatus.DoesNotExist() elif len(retirements) >= 1: for r in retirements: @@ -1078,7 +1078,7 @@ class AccountRetirementView(ViewSet): DataSharingConsent.objects.filter(username=username).update(username=retired_username) @staticmethod - def retire_sapsf_data_transmission(user): + def retire_sapsf_data_transmission(user): # lint-amnesty, pylint: disable=missing-function-docstring for ent_user in EnterpriseCustomerUser.objects.filter(user_id=user.id): for enrollment in EnterpriseCourseEnrollment.objects.filter( enterprise_customer_user=ent_user @@ -1089,7 +1089,7 @@ class AccountRetirementView(ViewSet): audits.update(sapsf_user_id='') @staticmethod - def retire_degreed_data_transmission(user): + def retire_degreed_data_transmission(user): # lint-amnesty, pylint: disable=missing-function-docstring for ent_user in EnterpriseCustomerUser.objects.filter(user_id=user.id): for enrollment in EnterpriseCourseEnrollment.objects.filter( enterprise_customer_user=ent_user diff --git a/openedx/core/djangoapps/user_api/admin.py b/openedx/core/djangoapps/user_api/admin.py index eb01bb24ff..d618a3a780 100644 --- a/openedx/core/djangoapps/user_api/admin.py +++ b/openedx/core/djangoapps/user_api/admin.py @@ -87,7 +87,7 @@ class UserRetirementStatusAdmin(admin.ModelAdmin): """ Adds our custom URL to the admin """ - urls = super(UserRetirementStatusAdmin, self).get_urls() + urls = super(UserRetirementStatusAdmin, self).get_urls() # lint-amnesty, pylint: disable=super-with-arguments custom_urls = [ url( r'^(?P.+)/cancel_retirement/$', @@ -121,7 +121,7 @@ class UserRetirementStatusAdmin(admin.ModelAdmin): Removes the default bulk delete option provided by Django, it doesn't do what we need for this model. """ - actions = super(UserRetirementStatusAdmin, self).get_actions(request) + actions = super(UserRetirementStatusAdmin, self).get_actions(request) # lint-amnesty, pylint: disable=super-with-arguments if 'delete_selected' in actions: del actions['delete_selected'] return actions diff --git a/openedx/core/djangoapps/user_api/course_tag/api.py b/openedx/core/djangoapps/user_api/course_tag/api.py index 04a6e4749b..d17d32a676 100644 --- a/openedx/core/djangoapps/user_api/course_tag/api.py +++ b/openedx/core/djangoapps/user_api/course_tag/api.py @@ -20,7 +20,7 @@ from ..models import UserCourseTag COURSE_SCOPE = 'course' -class BulkCourseTags(object): +class BulkCourseTags(object): # lint-amnesty, pylint: disable=missing-class-docstring CACHE_NAMESPACE = u'user_api.course_tag.api' @classmethod diff --git a/openedx/core/djangoapps/user_api/course_tag/tests/test_api.py b/openedx/core/djangoapps/user_api/course_tag/tests/test_api.py index 37496fa620..322d8ba3e9 100644 --- a/openedx/core/djangoapps/user_api/course_tag/tests/test_api.py +++ b/openedx/core/djangoapps/user_api/course_tag/tests/test_api.py @@ -16,7 +16,7 @@ class TestCourseTagAPI(TestCase): """ def setUp(self): - super(TestCourseTagAPI, self).setUp() + super(TestCourseTagAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() self.course_id = CourseLocator('test_org', 'test_course_number', 'test_run') self.test_key = 'test_key' diff --git a/openedx/core/djangoapps/user_api/errors.py b/openedx/core/djangoapps/user_api/errors.py index c2fee3583f..1a733f2e63 100644 --- a/openedx/core/djangoapps/user_api/errors.py +++ b/openedx/core/djangoapps/user_api/errors.py @@ -5,72 +5,72 @@ Errors thrown by the various user APIs. class UserAPIRequestError(Exception): """There was a problem with the request to the User API. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class UserAPIInternalError(Exception): """An internal error occurred in the User API. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class UserNotFound(UserAPIRequestError): """The requested user does not exist. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class UserNotAuthorized(UserAPIRequestError): """The user is not authorized to perform the requested action. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountRequestError(UserAPIRequestError): """There was a problem with the request to the account API. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountUserAlreadyExists(AccountRequestError): """User with the same username and/or email already exists. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountUsernameAlreadyExists(AccountRequestError): """User with the same username already exists. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountEmailAlreadyExists(AccountRequestError): """User with the same email already exists. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountUsernameInvalid(AccountRequestError): """The requested username is not in a valid format. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountEmailInvalid(AccountRequestError): """The requested email is not in a valid format. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountPasswordInvalid(AccountRequestError): """The requested password is not in a valid format. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountCountryInvalid(AccountRequestError): """The requested country does not exist. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountDataBadLength(AccountRequestError): """The requested account data is either too short or too long. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountDataBadType(AccountRequestError): """The requested account data is of the wrong type. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class AccountUpdateError(AccountRequestError): @@ -78,7 +78,7 @@ class AccountUpdateError(AccountRequestError): An update to the account failed. More detailed information is present in developer_message, and depending on the type of error encountered, there may also be a non-null user_message field. """ - def __init__(self, developer_message, user_message=None): + def __init__(self, developer_message, user_message=None): # lint-amnesty, pylint: disable=super-init-not-called self.developer_message = developer_message self.user_message = user_message @@ -90,13 +90,13 @@ class AccountValidationError(AccountRequestError): there will be at least a developer_message describing the validation issue, and possibly also a user_message. """ - def __init__(self, field_errors): + def __init__(self, field_errors): # lint-amnesty, pylint: disable=super-init-not-called self.field_errors = field_errors class PreferenceRequestError(UserAPIRequestError): """There was a problem with a preference request.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class PreferenceValidationError(PreferenceRequestError): @@ -108,7 +108,7 @@ class PreferenceValidationError(PreferenceRequestError): """ def __init__(self, preference_errors): self.preference_errors = preference_errors - super(PreferenceValidationError, self).__init__(preference_errors) + super(PreferenceValidationError, self).__init__(preference_errors) # lint-amnesty, pylint: disable=super-with-arguments class PreferenceUpdateError(PreferenceRequestError): @@ -119,9 +119,9 @@ class PreferenceUpdateError(PreferenceRequestError): def __init__(self, developer_message, user_message=None): self.developer_message = developer_message self.user_message = user_message - super(PreferenceUpdateError, self).__init__(developer_message) + super(PreferenceUpdateError, self).__init__(developer_message) # lint-amnesty, pylint: disable=super-with-arguments class CountryCodeError(ValueError): """There was a problem with the country code""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass diff --git a/openedx/core/djangoapps/user_api/helpers.py b/openedx/core/djangoapps/user_api/helpers.py index 3232e2cf30..487f64891e 100644 --- a/openedx/core/djangoapps/user_api/helpers.py +++ b/openedx/core/djangoapps/user_api/helpers.py @@ -64,7 +64,7 @@ def intercept_errors(api_error, ignore_errors=None): func_name=func.__name__, args=args, kwargs=kwargs, - exception=ex.developer_message if hasattr(ex, 'developer_message') else repr(ex) + exception=ex.developer_message if hasattr(ex, 'developer_message') else repr(ex) # lint-amnesty, pylint: disable=no-member ) LOGGER.warning(msg) raise @@ -80,11 +80,11 @@ def intercept_errors(api_error, ignore_errors=None): func_name=func.__name__, args=args, kwargs=kwargs, - exception=ex.developer_message if hasattr(ex, 'developer_message') else repr(ex), + exception=ex.developer_message if hasattr(ex, 'developer_message') else repr(ex), # lint-amnesty, pylint: disable=no-member caller=caller.strip(), ) LOGGER.exception(msg) - raise api_error(msg) + raise api_error(msg) # lint-amnesty, pylint: disable=raise-missing-from return _wrapped return _decorator @@ -347,13 +347,13 @@ class LocalizedJSONEncoder(DjangoJSONEncoder): JSON handler that evaluates ugettext_lazy promises. """ # pylint: disable=method-hidden - def default(self, obj): + def default(self, obj): # lint-amnesty, pylint: disable=arguments-differ """ Forces evaluation of ugettext_lazy promises. """ if isinstance(obj, Promise): return force_text(obj) - super(LocalizedJSONEncoder, self).default(obj) + super(LocalizedJSONEncoder, self).default(obj) # lint-amnesty, pylint: disable=super-with-arguments def serializer_is_dirty(preference_serializer): diff --git a/openedx/core/djangoapps/user_api/legacy_urls.py b/openedx/core/djangoapps/user_api/legacy_urls.py index 23725d2751..3068e7d2d3 100644 --- a/openedx/core/djangoapps/user_api/legacy_urls.py +++ b/openedx/core/djangoapps/user_api/legacy_urls.py @@ -3,7 +3,7 @@ Defines the URL routes for this app. """ -from django.conf import settings +from django.conf import settings # lint-amnesty, pylint: disable=unused-import from django.conf.urls import include, url from rest_framework import routers diff --git a/openedx/core/djangoapps/user_api/management/commands/cancel_user_retirement_request.py b/openedx/core/djangoapps/user_api/management/commands/cancel_user_retirement_request.py index acf53987e4..3b26f1d781 100644 --- a/openedx/core/djangoapps/user_api/management/commands/cancel_user_retirement_request.py +++ b/openedx/core/djangoapps/user_api/management/commands/cancel_user_retirement_request.py @@ -37,7 +37,7 @@ class Command(BaseCommand): original_email=email_address ) except UserRetirementStatus.DoesNotExist: - raise CommandError(u"No retirement request with email address '{}' exists.".format(email_address)) + raise CommandError(u"No retirement request with email address '{}' exists.".format(email_address)) # lint-amnesty, pylint: disable=raise-missing-from # Check if the user has started the retirement process -or- not. if retirement_status.current_state.state_name != 'PENDING': diff --git a/openedx/core/djangoapps/user_api/management/commands/create_user_gdpr_testing.py b/openedx/core/djangoapps/user_api/management/commands/create_user_gdpr_testing.py index b7529633b9..c988d72e82 100644 --- a/openedx/core/djangoapps/user_api/management/commands/create_user_gdpr_testing.py +++ b/openedx/core/djangoapps/user_api/management/commands/create_user_gdpr_testing.py @@ -10,7 +10,7 @@ from textwrap import dedent from uuid import uuid4 from consent.models import DataSharingConsent -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.management.base import BaseCommand from enterprise.models import ( EnterpriseCourseEnrollment, diff --git a/openedx/core/djangoapps/user_api/management/commands/email_opt_in_list.py b/openedx/core/djangoapps/user_api/management/commands/email_opt_in_list.py index b4f12b8990..e743455ca1 100644 --- a/openedx/core/djangoapps/user_api/management/commands/email_opt_in_list.py +++ b/openedx/core/djangoapps/user_api/management/commands/email_opt_in_list.py @@ -32,7 +32,7 @@ from django.conf import settings from django.core.management.base import BaseCommand, CommandError from django.db import connections from django.utils import timezone -from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.keys import CourseKey # lint-amnesty, pylint: disable=unused-import import six from six import text_type from six.moves import range diff --git a/openedx/core/djangoapps/user_api/management/commands/retire_user.py b/openedx/core/djangoapps/user_api/management/commands/retire_user.py index 7fc084e074..e56f0b35b9 100644 --- a/openedx/core/djangoapps/user_api/management/commands/retire_user.py +++ b/openedx/core/djangoapps/user_api/management/commands/retire_user.py @@ -1,7 +1,8 @@ +# lint-amnesty, pylint: disable=missing-module-docstring import logging -from django.contrib.auth import get_user_model, logout -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model, logout # lint-amnesty, pylint: disable=unused-import +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.management.base import BaseCommand, CommandError from django.db import transaction from social_django.models import UserSocialAuth @@ -61,7 +62,7 @@ class Command(BaseCommand): 'trying again' ) logger.error(error_message) - raise CommandError(error_message) + raise CommandError(error_message) # lint-amnesty, pylint: disable=raise-missing-from user_model = get_user_model() @@ -86,14 +87,14 @@ class Command(BaseCommand): except KeyError: error_message = 'Username not specified {}'.format(user) logger.error(error_message) - raise CommandError(error_message) + raise CommandError(error_message) # lint-amnesty, pylint: disable=raise-missing-from except user_model.DoesNotExist: error_message = 'The user "{}" does not exist.'.format(user.username) logger.error(error_message) - raise CommandError(error_message) + raise CommandError(error_message) # lint-amnesty, pylint: disable=raise-missing-from except Exception as exc: # pylint: disable=broad-except error_message = '500 error deactivating account {}'.format(exc) logger.error(error_message) - raise CommandError(error_message) + raise CommandError(error_message) # lint-amnesty, pylint: disable=raise-missing-from logger.info("User succesfully moved to the retirment pipeline") diff --git a/openedx/core/djangoapps/user_api/management/commands/sync_hubspot_contacts.py b/openedx/core/djangoapps/user_api/management/commands/sync_hubspot_contacts.py index 6cf8802893..3907d4fa8f 100644 --- a/openedx/core/djangoapps/user_api/management/commands/sync_hubspot_contacts.py +++ b/openedx/core/djangoapps/user_api/management/commands/sync_hubspot_contacts.py @@ -12,7 +12,7 @@ from datetime import datetime, timedelta from textwrap import dedent import six.moves.urllib.parse # pylint: disable=import-error -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.management.base import BaseCommand, CommandError from edx_rest_api_client.client import EdxRestApiClient from slumber.exceptions import HttpClientError, HttpServerError @@ -145,7 +145,7 @@ class Command(BaseCommand): return len(contacts) except (HttpClientError, HttpServerError) as ex: message = u'An error occurred while syncing batch of contacts for site {domain}, {message}'.format( - domain=site_conf.site.domain, message=ex.message + domain=site_conf.site.domain, message=ex.message # lint-amnesty, pylint: disable=no-member ) self.stderr.write(message) return 0 @@ -226,4 +226,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/openedx/core/djangoapps/user_api/management/tests/test_cancel_retirement.py b/openedx/core/djangoapps/user_api/management/tests/test_cancel_retirement.py index 61fe608b00..ad9071b2b0 100644 --- a/openedx/core/djangoapps/user_api/management/tests/test_cancel_retirement.py +++ b/openedx/core/djangoapps/user_api/management/tests/test_cancel_retirement.py @@ -5,7 +5,7 @@ Test the cancel_user_retirement_request management command import pytest from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.management import CommandError, call_command from openedx.core.djangoapps.user_api.accounts.tests.retirement_helpers import ( # pylint: disable=unused-import diff --git a/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py b/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py index 6fae0b2f90..9b1c01b814 100644 --- a/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py +++ b/openedx/core/djangoapps/user_api/management/tests/test_email_opt_in_list.py @@ -10,7 +10,7 @@ from collections import defaultdict import ddt import six -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.management import call_command from django.core.management.base import CommandError from six import text_type @@ -50,7 +50,7 @@ class EmailOptInListTest(ModuleStoreTestCase): DEFAULT_DATETIME_STR = "2014-12-01 00:00:00" def setUp(self): - super(EmailOptInListTest, self).setUp() + super(EmailOptInListTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create( username=self.USER_USERNAME, @@ -413,7 +413,7 @@ class EmailOptInListTest(ModuleStoreTestCase): try: with open(output_path) as output_file: reader = csv.DictReader(output_file, fieldnames=self.OUTPUT_FIELD_NAMES) - rows = [row for row in reader] + rows = [row for row in reader] # lint-amnesty, pylint: disable=unnecessary-comprehension except IOError: self.fail(u"Could not find or open output file at '{path}'".format(path=output_path)) diff --git a/openedx/core/djangoapps/user_api/management/tests/test_retire_user.py b/openedx/core/djangoapps/user_api/management/tests/test_retire_user.py index 4c0a37108a..4966084369 100644 --- a/openedx/core/djangoapps/user_api/management/tests/test_retire_user.py +++ b/openedx/core/djangoapps/user_api/management/tests/test_retire_user.py @@ -4,22 +4,22 @@ Test the retire_user management command import pytest -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.management import CommandError, call_command from ...models import UserRetirementStatus -from openedx.core.djangoapps.user_api.accounts.tests.retirement_helpers import ( # pylint: disable=unused-import +from openedx.core.djangoapps.user_api.accounts.tests.retirement_helpers import ( # lint-amnesty, pylint: disable=unused-import, wrong-import-order setup_retirement_states ) -from openedx.core.djangolib.testing.utils import skip_unless_lms -from common.djangoapps.student.tests.factories import UserFactory +from openedx.core.djangolib.testing.utils import skip_unless_lms # lint-amnesty, pylint: disable=wrong-import-order +from common.djangoapps.student.tests.factories import UserFactory # lint-amnesty, pylint: disable=wrong-import-order pytestmark = pytest.mark.django_db @skip_unless_lms -def test_successful_retire(setup_retirement_states): +def test_successful_retire(setup_retirement_states): # lint-amnesty, pylint: disable=redefined-outer-name, unused-argument user = UserFactory() username = user.username user_email = user.email @@ -33,7 +33,7 @@ def test_successful_retire(setup_retirement_states): @skip_unless_lms -def test_retire_user_with_usename_email_mismatch(setup_retirement_states): +def test_retire_user_with_usename_email_mismatch(setup_retirement_states): # lint-amnesty, pylint: disable=redefined-outer-name, unused-argument user = UserFactory() username = user.username user_email = "other@edx.org" diff --git a/openedx/core/djangoapps/user_api/management/tests/test_sync_hubspot_contacts.py b/openedx/core/djangoapps/user_api/management/tests/test_sync_hubspot_contacts.py index 01359e6630..3dda8fc394 100644 --- a/openedx/core/djangoapps/user_api/management/tests/test_sync_hubspot_contacts.py +++ b/openedx/core/djangoapps/user_api/management/tests/test_sync_hubspot_contacts.py @@ -38,7 +38,7 @@ class TestHubspotSyncCommand(TestCase): cls._create_users(cls.site_config) @classmethod - def _create_users(cls, site_conf): + def _create_users(cls, site_conf): # lint-amnesty, pylint: disable=missing-function-docstring # Create some test users for i in range(1, 20): profile_meta = { diff --git a/openedx/core/djangoapps/user_api/message_types.py b/openedx/core/djangoapps/user_api/message_types.py index ce93dee83a..b7fc85728e 100644 --- a/openedx/core/djangoapps/user_api/message_types.py +++ b/openedx/core/djangoapps/user_api/message_types.py @@ -14,7 +14,7 @@ class DeletionNotificationMessage(BaseMessageType): Message to notify learners that their account is queued for deletion. """ def __init__(self, *args, **kwargs): - super(DeletionNotificationMessage, self).__init__(*args, **kwargs) + super(DeletionNotificationMessage, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.options['transactional'] = True # pylint: disable=unsupported-assignment-operation self.options['from_address'] = helpers.get_value( # pylint: disable=unsupported-assignment-operation diff --git a/openedx/core/djangoapps/user_api/models.py b/openedx/core/djangoapps/user_api/models.py index ae402f10d4..94425638b9 100644 --- a/openedx/core/djangoapps/user_api/models.py +++ b/openedx/core/djangoapps/user_api/models.py @@ -3,7 +3,7 @@ Django ORM model specifications for the User API application """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.validators import RegexValidator from django.db import models from django.db.models.signals import post_delete, post_save, pre_save @@ -61,7 +61,7 @@ class UserPreference(models.Model): Returns: Set of (preference type, value) pairs for each of the user's preferences """ - return dict([(pref.key, pref.value) for pref in user.preferences.all()]) + return dict([(pref.key, pref.value) for pref in user.preferences.all()]) # lint-amnesty, pylint: disable=consider-using-dict-comprehension @classmethod def get_value(cls, user, preference_key, default=None): @@ -318,7 +318,7 @@ class UserRetirementStatus(TimeStampedModel): err = u'{} does not exist or is an eariler state than current state {}'.format( new_state, self.current_state ) - raise RetirementStateError(err) + raise RetirementStateError(err) # lint-amnesty, pylint: disable=raise-missing-from def _validate_update_data(self, data): """ @@ -347,7 +347,7 @@ class UserRetirementStatus(TimeStampedModel): try: pending = RetirementState.objects.all().order_by('state_execution_order')[0] except IndexError: - raise RetirementStateError('Default state does not exist! Populate retirement states to retire users.') + raise RetirementStateError('Default state does not exist! Populate retirement states to retire users.') # lint-amnesty, pylint: disable=raise-missing-from if cls.objects.filter(user=user).exists(): raise RetirementStateError(u'User {} already has a retirement status row!'.format(user)) diff --git a/openedx/core/djangoapps/user_api/permissions.py b/openedx/core/djangoapps/user_api/permissions.py index 7301e60dbc..bf126fb404 100644 --- a/openedx/core/djangoapps/user_api/permissions.py +++ b/openedx/core/djangoapps/user_api/permissions.py @@ -3,7 +3,7 @@ Permissions classes for User-API aware views. """ -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 django.shortcuts import get_object_or_404 from rest_framework import permissions diff --git a/openedx/core/djangoapps/user_api/preferences/api.py b/openedx/core/djangoapps/user_api/preferences/api.py index b38f2536a9..72987591b1 100644 --- a/openedx/core/djangoapps/user_api/preferences/api.py +++ b/openedx/core/djangoapps/user_api/preferences/api.py @@ -18,7 +18,7 @@ from openedx.core.lib.time_zone_utils import get_display_time_zone from common.djangoapps.student.models import User, UserProfile from common.djangoapps.track import segment -from ..errors import ( +from ..errors import ( # lint-amnesty, pylint: disable=unused-import CountryCodeError, PreferenceUpdateError, PreferenceValidationError, @@ -169,7 +169,7 @@ def update_user_preferences(requesting_user, update, user=None): if serializer_is_dirty(serializer): serializer.save() except Exception as error: - raise _create_preference_update_error(preference_key, preference_value, error) + raise _create_preference_update_error(preference_key, preference_value, error) # lint-amnesty, pylint: disable=raise-missing-from else: delete_user_preference(requesting_user, preference_key) @@ -209,7 +209,7 @@ def set_user_preference(requesting_user, preference_key, preference_value, usern try: serializer.save() except Exception as error: - raise _create_preference_update_error(preference_key, preference_value, error) + raise _create_preference_update_error(preference_key, preference_value, error) # lint-amnesty, pylint: disable=raise-missing-from @intercept_errors(UserAPIInternalError, ignore_errors=[UserAPIRequestError]) @@ -247,7 +247,7 @@ def delete_user_preference(requesting_user, preference_key, username=None): try: user_preference.delete() except Exception as error: - raise PreferenceUpdateError( + raise PreferenceUpdateError( # lint-amnesty, pylint: disable=raise-missing-from developer_message=u"Delete failed for user preference '{preference_key}': {error}".format( preference_key=preference_key, error=error ), @@ -285,7 +285,7 @@ def update_email_opt_in(user, org, opt_in): try: user_profile = UserProfile.objects.get(user=user) except ObjectDoesNotExist: - raise UserNotFound() + raise UserNotFound() # lint-amnesty, pylint: disable=raise-missing-from if user_profile.requires_parental_consent( age_limit=getattr(settings, 'EMAIL_OPTIN_MINIMUM_AGE', 13), default_requires_consent=False, @@ -345,7 +345,7 @@ def _get_authorized_user(requesting_user, username=None, allow_staff=False): try: existing_user = User.objects.get(username=username) except ObjectDoesNotExist: - raise UserNotFound() + raise UserNotFound() # lint-amnesty, pylint: disable=raise-missing-from return existing_user @@ -404,7 +404,7 @@ def validate_user_preference_serializer(serializer, preference_key, preference_v raise PreferenceValidationError({ preference_key: { "developer_message": format_string.format(preference_key=preference_key), - "user_message": _(format_string).format(preference_key=preference_key) + "user_message": _(format_string).format(preference_key=preference_key) # lint-amnesty, pylint: disable=translation-of-non-string } }) if not serializer.is_valid(): diff --git a/openedx/core/djangoapps/user_api/preferences/tests/test_api.py b/openedx/core/djangoapps/user_api/preferences/tests/test_api.py index 942d5eb486..056169daa9 100644 --- a/openedx/core/djangoapps/user_api/preferences/tests/test_api.py +++ b/openedx/core/djangoapps/user_api/preferences/tests/test_api.py @@ -8,7 +8,7 @@ import datetime import ddt from dateutil.parser import parse as parse_datetime -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.test.utils import override_settings from django.urls import reverse from mock import patch @@ -21,7 +21,7 @@ from common.djangoapps.student.tests.factories import UserFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from ...errors import ( +from ...errors import ( # lint-amnesty, pylint: disable=unused-import CountryCodeError, PreferenceUpdateError, PreferenceValidationError, @@ -50,7 +50,7 @@ class TestPreferenceAPI(CacheIsolationTestCase): password = "test" def setUp(self): - super(TestPreferenceAPI, self).setUp() + super(TestPreferenceAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(password=self.password) self.different_user = UserFactory.create(password=self.password) self.staff_user = UserFactory.create(is_staff=True, password=self.password) @@ -487,7 +487,7 @@ def get_expected_validation_developer_message(preference_key, preference_value): ) -def get_expected_key_error_user_message(preference_key, preference_value): +def get_expected_key_error_user_message(preference_key, preference_value): # lint-amnesty, pylint: disable=unused-argument """ Returns the expected user message for an invalid key. """ diff --git a/openedx/core/djangoapps/user_api/preferences/tests/test_views.py b/openedx/core/djangoapps/user_api/preferences/tests/test_views.py index 19bd64665b..5c312bf97f 100644 --- a/openedx/core/djangoapps/user_api/preferences/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/preferences/tests/test_views.py @@ -30,7 +30,7 @@ class TestPreferencesAPI(UserAPITestCase): Unit tests /api/user/v1/accounts/{username}/ """ def setUp(self): - super(TestPreferencesAPI, self).setUp() + super(TestPreferencesAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url_endpoint_name = "preferences_api" self.url = reverse(self.url_endpoint_name, kwargs={'username': self.user.username}) @@ -96,7 +96,7 @@ class TestPreferencesAPI(UserAPITestCase): # Log in the client and do the GET. client = self.login_client(api_client, user) response = self.send_get(client) - self.assertEqual({"dict_pref": "{'int_key': 10}", "string_pref": "value", "time_zone": "Asia/Tokyo"}, # pylint: disable=unicode-format-string + self.assertEqual({"dict_pref": "{'int_key': 10}", "string_pref": "value", "time_zone": "Asia/Tokyo"}, # lint-amnesty, pylint: disable=bad-option-value, unicode-format-string response.data) @ddt.data( @@ -155,7 +155,7 @@ class TestPreferencesAPI(UserAPITestCase): if six.PY2: pref_dict = {u"dict_pref": u"{u'int_key': 10}", u"string_pref": u"value"} else: - # pylint: disable=unicode-format-string + # lint-amnesty, pylint: disable=bad-option-value, unicode-format-string pref_dict = {"dict_pref": "{'int_key': 10}", "string_pref": "value"} self.assertEqual(pref_dict, response.data) @@ -204,7 +204,7 @@ class TestPreferencesAPI(UserAPITestCase): # Verify that GET returns the updated preferences response = self.send_get(self.client) expected_preferences = { - "dict_pref": "{'int_key': 10}", # pylint: disable=unicode-format-string + "dict_pref": "{'int_key': 10}", # lint-amnesty, pylint: disable=bad-option-value, unicode-format-string "string_pref": "updated_value", "new_pref": "new_value", "time_zone": "Europe/London", @@ -330,7 +330,7 @@ class TestPreferencesAPITransactions(TransactionTestCase): test_password = "test" def setUp(self): - super(TestPreferencesAPITransactions, self).setUp() + super(TestPreferencesAPITransactions, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.client = APIClient() self.user = UserFactory.create(password=TEST_PASSWORD) self.url = reverse("preferences_api", kwargs={'username': self.user.username}) @@ -375,7 +375,7 @@ class TestPreferencesDetailAPI(UserAPITestCase): Unit tests /api/user/v1/accounts/{username}/{preference_key} """ def setUp(self): - super(TestPreferencesDetailAPI, self).setUp() + super(TestPreferencesDetailAPI, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.test_pref_key = "test_key" self.test_pref_value = "test_value" set_user_preference(self.user, self.test_pref_key, self.test_pref_value) diff --git a/openedx/core/djangoapps/user_api/serializers.py b/openedx/core/djangoapps/user_api/serializers.py index 1849d05284..28a3301258 100644 --- a/openedx/core/djangoapps/user_api/serializers.py +++ b/openedx/core/djangoapps/user_api/serializers.py @@ -3,8 +3,8 @@ Django REST Framework serializers for the User API application """ -from django.contrib.auth.models import User -from django.utils.timezone import now +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user +from django.utils.timezone import now # lint-amnesty, pylint: disable=unused-import from rest_framework import serializers from lms.djangoapps.verify_student.models import ( @@ -101,7 +101,7 @@ class CountryTimeZoneSerializer(serializers.Serializer): # pylint: disable=abst description = serializers.CharField() -class IDVerificationDetailsSerializer(serializers.Serializer): +class IDVerificationDetailsSerializer(serializers.Serializer): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring type = serializers.SerializerMethodField() status = serializers.CharField() expiration_datetime = serializers.DateTimeField() @@ -109,7 +109,7 @@ class IDVerificationDetailsSerializer(serializers.Serializer): updated_at = serializers.DateTimeField() receipt_id = serializers.SerializerMethodField() - def get_type(self, obj): + def get_type(self, obj): # lint-amnesty, pylint: disable=missing-function-docstring if isinstance(obj, SoftwareSecurePhotoVerification): return 'Software Secure' elif isinstance(obj, ManualVerification): @@ -117,7 +117,7 @@ class IDVerificationDetailsSerializer(serializers.Serializer): else: return 'SSO' - def get_message(self, obj): + def get_message(self, obj): # lint-amnesty, pylint: disable=missing-function-docstring if isinstance(obj, SoftwareSecurePhotoVerification): return obj.error_msg elif isinstance(obj, ManualVerification): diff --git a/openedx/core/djangoapps/user_api/tests/test_helpers.py b/openedx/core/djangoapps/user_api/tests/test_helpers.py index d0c2472b0f..15a760c810 100644 --- a/openedx/core/djangoapps/user_api/tests/test_helpers.py +++ b/openedx/core/djangoapps/user_api/tests/test_helpers.py @@ -6,7 +6,7 @@ Tests for helper functions. import json import re -import ddt +import ddt # lint-amnesty, pylint: disable=unused-import import mock import pytest from django import forms @@ -18,12 +18,12 @@ from ..helpers import FormDescription, InvalidFieldError, intercept_errors class FakeInputException(Exception): """Fake exception that should be intercepted.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass class FakeOutputException(Exception): """Fake exception that should be raised.""" - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass @intercept_errors(FakeOutputException, ignore_errors=[ValueError]) diff --git a/openedx/core/djangoapps/user_api/tests/test_middleware.py b/openedx/core/djangoapps/user_api/tests/test_middleware.py index 70fe3bb069..e90ce1046b 100644 --- a/openedx/core/djangoapps/user_api/tests/test_middleware.py +++ b/openedx/core/djangoapps/user_api/tests/test_middleware.py @@ -17,7 +17,7 @@ class TagsMiddlewareTest(TestCase): Test the UserTagsEventContextMiddleware """ def setUp(self): - super(TagsMiddlewareTest, self).setUp() + super(TagsMiddlewareTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.middleware = UserTagsEventContextMiddleware() self.user = UserFactory.create() self.other_user = UserFactory.create() diff --git a/openedx/core/djangoapps/user_api/tests/test_models.py b/openedx/core/djangoapps/user_api/tests/test_models.py index 4206647d6d..7cb7f68916 100644 --- a/openedx/core/djangoapps/user_api/tests/test_models.py +++ b/openedx/core/djangoapps/user_api/tests/test_models.py @@ -129,7 +129,7 @@ class TestUserPreferenceEvents(UserSettingsEventTestMixin, TestCase): Mixin for verifying that user preference events are fired correctly. """ def setUp(self): - super(TestUserPreferenceEvents, self).setUp() + super(TestUserPreferenceEvents, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.table = "user_api_userpreference" self.user = UserFactory.create() self.TEST_KEY = "test key" diff --git a/openedx/core/djangoapps/user_api/tests/test_partition_schemes.py b/openedx/core/djangoapps/user_api/tests/test_partition_schemes.py index 1b45831687..544acc950f 100644 --- a/openedx/core/djangoapps/user_api/tests/test_partition_schemes.py +++ b/openedx/core/djangoapps/user_api/tests/test_partition_schemes.py @@ -33,7 +33,7 @@ class MemoryCourseTagAPI(object): class BulkCourseTags(object): @classmethod - def is_prefetched(self, course_id): + def is_prefetched(self, course_id): # lint-amnesty, pylint: disable=bad-classmethod-argument, unused-argument return False @@ -46,7 +46,7 @@ class TestRandomUserPartitionScheme(PartitionTestCase): MOCK_COURSE_ID = "mock-course-id" def setUp(self): - super(TestRandomUserPartitionScheme, self).setUp() + super(TestRandomUserPartitionScheme, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Patch in a memory-based user service instead of using the persistent version course_tag_api = MemoryCourseTagAPI() self.user_service_patcher = patch( diff --git a/openedx/core/djangoapps/user_api/tests/test_views.py b/openedx/core/djangoapps/user_api/tests/test_views.py index 3cfa284e88..7372fc8099 100644 --- a/openedx/core/djangoapps/user_api/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/tests/test_views.py @@ -1,40 +1,40 @@ """Tests for the user API at the HTTP request level. """ -import json -from unittest import skipUnless +import json # lint-amnesty, pylint: disable=unused-import +from unittest import skipUnless # lint-amnesty, pylint: disable=unused-import import ddt -import httpretty -import mock +import httpretty # lint-amnesty, pylint: disable=unused-import +import mock # lint-amnesty, pylint: disable=unused-import import six -from django.conf import settings -from django.contrib.auth.models import User -from django.core import mail -from django.test.client import RequestFactory -from django.test.testcases import TransactionTestCase +from django.conf import settings # lint-amnesty, pylint: disable=unused-import +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user, unused-import +from django.core import mail # lint-amnesty, pylint: disable=unused-import +from django.test.client import RequestFactory # lint-amnesty, pylint: disable=unused-import +from django.test.testcases import TransactionTestCase # lint-amnesty, pylint: disable=unused-import from django.test.utils import override_settings from django.urls import reverse from opaque_keys.edx.keys import CourseKey -from pytz import UTC, common_timezones_set +from pytz import UTC, common_timezones_set # lint-amnesty, pylint: disable=unused-import from six import text_type from six.moves import range -from social_django.models import Partial, UserSocialAuth +from social_django.models import Partial, UserSocialAuth # lint-amnesty, pylint: disable=unused-import from openedx.core.djangoapps.django_comment_common import models -from openedx.core.djangoapps.site_configuration.helpers import get_value -from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration +from openedx.core.djangoapps.site_configuration.helpers import get_value # lint-amnesty, pylint: disable=unused-import +from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration # lint-amnesty, pylint: disable=unused-import from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms from openedx.core.lib.api.test_utils import TEST_API_KEY, ApiTestCase from openedx.core.lib.time_zone_utils import get_display_time_zone from common.djangoapps.student.tests.factories import UserFactory -from common.djangoapps.third_party_auth.tests.testutil import ThirdPartyAuthTestMixin, simulate_running_pipeline -from common.djangoapps.third_party_auth.tests.utils import ( +from common.djangoapps.third_party_auth.tests.testutil import ThirdPartyAuthTestMixin, simulate_running_pipeline # lint-amnesty, pylint: disable=unused-import +from common.djangoapps.third_party_auth.tests.utils import ( # lint-amnesty, pylint: disable=unused-import ThirdPartyOAuthTestMixin, ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle ) -from common.djangoapps.util.password_policy_validators import ( +from common.djangoapps.util.password_policy_validators import ( # lint-amnesty, pylint: disable=unused-import create_validator_config, password_validators_instruction_texts, password_validators_restrictions @@ -42,7 +42,7 @@ from common.djangoapps.util.password_policy_validators import ( from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from ..accounts import ( +from ..accounts import ( # lint-amnesty, pylint: disable=unused-import EMAIL_MAX_LENGTH, EMAIL_MIN_LENGTH, NAME_MAX_LENGTH, @@ -50,7 +50,7 @@ from ..accounts import ( USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH ) -from ..accounts.api import get_account_settings +from ..accounts.api import get_account_settings # lint-amnesty, pylint: disable=unused-import from ..accounts.tests.retirement_helpers import ( # pylint: disable=unused-import RetirementTestCase, fake_requested_retirement, @@ -58,8 +58,8 @@ from ..accounts.tests.retirement_helpers import ( # pylint: disable=unused-impo ) from ..models import UserOrgTag from ..tests.factories import UserPreferenceFactory -from ..tests.test_constants import SORTED_COUNTRIES -from .test_helpers import TestCaseForm +from ..tests.test_constants import SORTED_COUNTRIES # lint-amnesty, pylint: disable=unused-import +from .test_helpers import TestCaseForm # lint-amnesty, pylint: disable=unused-import USER_LIST_URI = "/api/user/v1/users/" USER_PREFERENCE_LIST_URI = "/api/user/v1/user_prefs/" @@ -94,7 +94,7 @@ class UserAPITestCase(ApiTestCase): six.assertCountEqual( self, list(user["preferences"].items()), - [(pref.key, pref.value) for pref in self.prefs if pref.user.id == user["id"]] + [(pref.key, pref.value) for pref in self.prefs if pref.user.id == user["id"]] # lint-amnesty, pylint: disable=no-member ) self.assertSelfReferential(user) @@ -140,7 +140,7 @@ class UserApiTestCase(UserAPITestCase): Generalized test case class for specific implementations below """ def setUp(self): - super(UserApiTestCase, self).setUp() + super(UserApiTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.users = [ UserFactory.create( email="test{0}@test.org".format(i), @@ -164,7 +164,7 @@ class RoleTestCase(UserApiTestCase): LIST_URI = ROLE_LIST_URI + "?course_id=" + six.text_type(course_id) def setUp(self): - super(RoleTestCase, self).setUp() + super(RoleTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments (role, _) = models.Role.objects.get_or_create( name=models.FORUM_ROLE_MODERATOR, course_id=self.course_id @@ -253,7 +253,7 @@ class UserViewSetTest(UserApiTestCase): LIST_URI = USER_LIST_URI def setUp(self): - super(UserViewSetTest, self).setUp() + super(UserViewSetTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.detail_uri = self.get_uri_for_user(self.users[0]) # List view tests @@ -353,7 +353,7 @@ class UserViewSetTest(UserApiTestCase): "id": user.id, "name": user.profile.name, "username": user.username, - "preferences": dict([ + "preferences": dict([ # lint-amnesty, pylint: disable=consider-using-dict-comprehension (user_pref.key, user_pref.value) for user_pref in self.prefs if user_pref.user == user @@ -373,7 +373,7 @@ class UserPreferenceViewSetTest(CacheIsolationTestCase, UserApiTestCase): ENABLED_CACHES = ['default'] def setUp(self): - super(UserPreferenceViewSetTest, self).setUp() + super(UserPreferenceViewSetTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.detail_uri = self.get_uri_for_pref(self.prefs[0]) # List view tests @@ -495,7 +495,7 @@ class UserPreferenceViewSetTest(CacheIsolationTestCase, UserApiTestCase): "id": pref.user.id, "name": pref.user.profile.name, "username": pref.user.username, - "preferences": dict([ + "preferences": dict([ # lint-amnesty, pylint: disable=consider-using-dict-comprehension (user_pref.key, user_pref.value) for user_pref in self.prefs if user_pref.user == pref.user @@ -586,7 +586,7 @@ class UpdateEmailOptInTestCase(UserAPITestCase, SharedModuleStoreTestCase): def setUp(self): """ Create a course and user, then log in. """ - super(UpdateEmailOptInTestCase, self).setUp() + super(UpdateEmailOptInTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create(username=self.USERNAME, email=self.EMAIL, password=self.PASSWORD) self.client.login(username=self.USERNAME, password=self.PASSWORD) diff --git a/openedx/core/djangoapps/user_api/verification_api/tests/test_views.py b/openedx/core/djangoapps/user_api/verification_api/tests/test_views.py index 4d79121c86..c9d786f1f8 100644 --- a/openedx/core/djangoapps/user_api/verification_api/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/verification_api/tests/test_views.py @@ -10,7 +10,7 @@ from django.test import TestCase from django.test.utils import override_settings from django.urls import reverse -from lms.djangoapps.verify_student.models import ManualVerification, SoftwareSecurePhotoVerification, SSOVerification +from lms.djangoapps.verify_student.models import ManualVerification, SoftwareSecurePhotoVerification, SSOVerification # lint-amnesty, pylint: disable=unused-import from lms.djangoapps.verify_student.tests.factories import SSOVerificationFactory from common.djangoapps.student.tests.factories import UserFactory @@ -137,12 +137,12 @@ class VerificationsDetailsViewTests(VerificationStatusViewTestsMixin, TestCase): }] def test_multiple_verification_types(self): - self.manual_verification = ManualVerification.objects.create( + self.manual_verification = ManualVerification.objects.create( # lint-amnesty, pylint: disable=attribute-defined-outside-init user=self.user, status='approved', reason='testing' ) - self.sso_verification = SSOVerificationFactory(user=self.user, status='approved') + self.sso_verification = SSOVerificationFactory(user=self.user, status='approved') # lint-amnesty, pylint: disable=attribute-defined-outside-init self.photo_verification.error_msg = 'tested_error' self.photo_verification.error_code = 'error_code' self.photo_verification.status = 'denied' @@ -180,7 +180,7 @@ class VerificationsDetailsViewTests(VerificationStatusViewTestsMixin, TestCase): self.assertEqual(json.loads(response.content.decode('utf-8')), expected) def test_multiple_verification_instances(self): - self.sso_verification = SSOVerificationFactory(user=self.user, status='approved') + self.sso_verification = SSOVerificationFactory(user=self.user, status='approved') # lint-amnesty, pylint: disable=attribute-defined-outside-init second_ss_photo_verification = SoftwareSecurePhotoVerification.objects.create( user=self.user, status='denied', diff --git a/openedx/core/djangoapps/user_api/verification_api/views.py b/openedx/core/djangoapps/user_api/verification_api/views.py index b2790bd8c0..1ef159150c 100644 --- a/openedx/core/djangoapps/user_api/verification_api/views.py +++ b/openedx/core/djangoapps/user_api/verification_api/views.py @@ -19,7 +19,7 @@ class IDVerificationStatusView(APIView): authentication_classes = (JwtAuthentication, BearerAuthentication, SessionAuthentication,) permission_classes = (IsStaffOrOwner,) - def get(self, request, **kwargs): + def get(self, request, **kwargs): # lint-amnesty, pylint: disable=missing-function-docstring username = kwargs.get('username') User = get_user_model() try: @@ -35,7 +35,7 @@ class IDVerificationStatusView(APIView): }) except User.DoesNotExist: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from class IDVerificationStatusDetailsView(ListAPIView): @@ -59,4 +59,4 @@ class IDVerificationStatusDetailsView(ListAPIView): return sorted(verifications, key=lambda x: x.updated_at, reverse=True) except User.DoesNotExist: - raise Http404 + raise Http404 # lint-amnesty, pylint: disable=raise-missing-from diff --git a/openedx/core/djangoapps/user_api/views.py b/openedx/core/djangoapps/user_api/views.py index 058a1edab6..e4b75c9b31 100644 --- a/openedx/core/djangoapps/user_api/views.py +++ b/openedx/core/djangoapps/user_api/views.py @@ -1,12 +1,12 @@ """HTTP end-points for the User API. """ -from django.contrib.auth.models import User -from django.core.exceptions import NON_FIELD_ERRORS, PermissionDenied, ValidationError -from django.db import transaction -from django.http import HttpResponse, HttpResponseForbidden +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user +from django.core.exceptions import NON_FIELD_ERRORS, PermissionDenied, ValidationError # lint-amnesty, pylint: disable=unused-import +from django.db import transaction # lint-amnesty, pylint: disable=unused-import +from django.http import HttpResponse, HttpResponseForbidden # lint-amnesty, pylint: disable=unused-import from django.utils.decorators import method_decorator -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext as _ # lint-amnesty, pylint: disable=unused-import from django.views.decorators.csrf import ensure_csrf_cookie from django_filters.rest_framework import DjangoFilterBackend from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser @@ -17,10 +17,10 @@ from rest_framework import authentication, generics, status, viewsets from rest_framework.exceptions import ParseError from rest_framework.permissions import IsAuthenticated from rest_framework.views import APIView -from six import text_type +from six import text_type # lint-amnesty, pylint: disable=unused-import from openedx.core.djangoapps.django_comment_common.models import Role -from openedx.core.djangoapps.user_api import accounts +from openedx.core.djangoapps.user_api import accounts # lint-amnesty, pylint: disable=unused-import from openedx.core.lib.api.view_utils import require_post_params from openedx.core.djangoapps.user_api.models import UserPreference from openedx.core.djangoapps.user_api.preferences.api import get_country_time_zones, update_email_opt_in @@ -30,8 +30,8 @@ from openedx.core.djangoapps.user_api.serializers import ( UserSerializer ) from openedx.core.lib.api.permissions import ApiKeyHeaderPermission -from common.djangoapps.student.helpers import AccountValidationError -from common.djangoapps.util.json_request import JsonResponse +from common.djangoapps.student.helpers import AccountValidationError # lint-amnesty, pylint: disable=unused-import +from common.djangoapps.util.json_request import JsonResponse # lint-amnesty, pylint: disable=unused-import class UserViewSet(viewsets.ReadOnlyModelViewSet): diff --git a/openedx/core/djangoapps/user_authn/api/tests/test_views.py b/openedx/core/djangoapps/user_authn/api/tests/test_views.py index 2ca6881fee..4181f8d955 100644 --- a/openedx/core/djangoapps/user_authn/api/tests/test_views.py +++ b/openedx/core/djangoapps/user_authn/api/tests/test_views.py @@ -24,7 +24,7 @@ class TPAContextViewTest(ThirdPartyAuthTestMixin, APITestCase): """ Test Setup """ - super(TPAContextViewTest, self).setUp() + super(TPAContextViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse('third_party_auth_context') self.query_params = {'redirect_to': '/dashboard'} diff --git a/openedx/core/djangoapps/user_authn/api/views.py b/openedx/core/djangoapps/user_authn/api/views.py index 75954dc601..a171b7e7df 100644 --- a/openedx/core/djangoapps/user_authn/api/views.py +++ b/openedx/core/djangoapps/user_authn/api/views.py @@ -26,7 +26,7 @@ class TPAContextView(APIView): """ throttle_classes = [ThirdPartyAuthContextThrottle] - def get(self, request, **kwargs): + def get(self, request, **kwargs): # lint-amnesty, pylint: disable=unused-argument """ Returns the context for third party auth providers and the currently running pipeline. diff --git a/openedx/core/djangoapps/user_authn/cookies.py b/openedx/core/djangoapps/user_authn/cookies.py index cd61d8c0ba..1c766726e9 100644 --- a/openedx/core/djangoapps/user_authn/cookies.py +++ b/openedx/core/djangoapps/user_authn/cookies.py @@ -9,7 +9,7 @@ import time import six from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.dispatch import Signal from django.urls import NoReverseMatch, reverse from django.utils.http import http_date, parse_http_date @@ -349,6 +349,6 @@ def _get_login_oauth_client(): try: return Application.objects.get(client_id=login_client_id) except Application.DoesNotExist: - raise AuthFailedError( + raise AuthFailedError( # lint-amnesty, pylint: disable=raise-missing-from u"OAuth Client for the Login service, '{}', is not configured.".format(login_client_id) ) diff --git a/openedx/core/djangoapps/user_authn/exceptions.py b/openedx/core/djangoapps/user_authn/exceptions.py index 5f50f95051..4dc1f25276 100644 --- a/openedx/core/djangoapps/user_authn/exceptions.py +++ b/openedx/core/djangoapps/user_authn/exceptions.py @@ -9,10 +9,10 @@ class AuthFailedError(Exception): This is a helper for the login view, allowing the various sub-methods to error out with an appropriate failure message. """ - def __init__( + def __init__( # lint-amnesty, pylint: disable=dangerous-default-value self, value=None, redirect=None, redirect_url=None, error_code=None, context={}, ): - super(AuthFailedError, self).__init__() + super(AuthFailedError, self).__init__() # lint-amnesty, pylint: disable=super-with-arguments self.value = Text(value) self.redirect = redirect self.redirect_url = redirect_url diff --git a/openedx/core/djangoapps/user_authn/message_types.py b/openedx/core/djangoapps/user_authn/message_types.py index ab14ba12b5..0688881a61 100644 --- a/openedx/core/djangoapps/user_authn/message_types.py +++ b/openedx/core/djangoapps/user_authn/message_types.py @@ -10,7 +10,7 @@ class PasswordReset(BaseMessageType): A message to the user with password reset link. """ def __init__(self, *args, **kwargs): - super(PasswordReset, self).__init__(*args, **kwargs) + super(PasswordReset, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments # pylint: disable=unsupported-assignment-operation self.options['transactional'] = True @@ -22,5 +22,5 @@ class PasswordResetSuccess(BaseMessageType): """ def __init__(self, *args, **kwargs): - super(PasswordResetSuccess, self).__init__(*args, **kwargs) + super(PasswordResetSuccess, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments self.options['transactional'] = True diff --git a/openedx/core/djangoapps/user_authn/tests/test_cookies.py b/openedx/core/djangoapps/user_authn/tests/test_cookies.py index 011aad21be..0cd8ba220a 100644 --- a/openedx/core/djangoapps/user_authn/tests/test_cookies.py +++ b/openedx/core/djangoapps/user_authn/tests/test_cookies.py @@ -24,7 +24,7 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_ class CookieTests(TestCase): def setUp(self): - super(CookieTests, self).setUp() + super(CookieTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() self.user.profile = UserProfileFactory.create(user=self.user) self.request = RequestFactory().get('/') @@ -102,7 +102,7 @@ class CookieTests(TestCase): """ Verify cookies in the response have the same expiration, as expected. """ self.assertEqual( num_of_unique_expires, - len(set([response.cookies[c]['expires'] for c in response.cookies])), + len(set([response.cookies[c]['expires'] for c in response.cookies])), # lint-amnesty, pylint: disable=consider-using-set-comprehension ) @skip_unless_lms diff --git a/openedx/core/djangoapps/user_authn/tests/test_utils.py b/openedx/core/djangoapps/user_authn/tests/test_utils.py index 710454a640..f6a1bc54bf 100644 --- a/openedx/core/djangoapps/user_authn/tests/test_utils.py +++ b/openedx/core/djangoapps/user_authn/tests/test_utils.py @@ -20,7 +20,7 @@ class TestRedirectUtils(TestCase): """Test redirect utility methods.""" def setUp(self): - super(TestRedirectUtils, self).setUp() + super(TestRedirectUtils, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.request = RequestFactory() RedirectCase = namedtuple('RedirectCase', ['url', 'host', 'req_is_secure', 'expected_is_safe']) diff --git a/openedx/core/djangoapps/user_authn/tests/utils.py b/openedx/core/djangoapps/user_authn/tests/utils.py index 74aae437d9..aedecaac1c 100644 --- a/openedx/core/djangoapps/user_authn/tests/utils.py +++ b/openedx/core/djangoapps/user_authn/tests/utils.py @@ -61,7 +61,7 @@ class AuthAndScopesTestMixin(object): user_password = 'test' def setUp(self): - super(AuthAndScopesTestMixin, self).setUp() + super(AuthAndScopesTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.student = UserFactory.create(password=self.user_password) self.other_student = UserFactory.create(password=self.user_password) self.global_staff = UserFactory.create(password=self.user_password, is_staff=True) diff --git a/openedx/core/djangoapps/user_authn/views/auto_auth.py b/openedx/core/djangoapps/user_authn/views/auto_auth.py index 11c7d258a2..42ebbef4e8 100644 --- a/openedx/core/djangoapps/user_authn/views/auto_auth.py +++ b/openedx/core/djangoapps/user_authn/views/auto_auth.py @@ -6,7 +6,7 @@ import uuid from django.conf import settings from django.contrib.auth import login as django_login -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import PermissionDenied from django.core.validators import ValidationError from django.http import HttpResponseForbidden diff --git a/openedx/core/djangoapps/user_authn/views/login.py b/openedx/core/djangoapps/user_authn/views/login.py index 7c9294ba5f..79088970d1 100644 --- a/openedx/core/djangoapps/user_authn/views/login.py +++ b/openedx/core/djangoapps/user_authn/views/login.py @@ -12,7 +12,7 @@ from django.conf import settings from django.contrib.auth import authenticate from django.contrib.auth import login as django_login from django.contrib.auth.decorators import login_required -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib import admin from django.http import HttpRequest, HttpResponse, HttpResponseForbidden from django.shortcuts import redirect @@ -88,7 +88,7 @@ def _do_third_party_auth(request): ) ) - raise AuthFailedError(message, error_code='third-party-auth-with-no-linked-account') + raise AuthFailedError(message, error_code='third-party-auth-with-no-linked-account') # lint-amnesty, pylint: disable=raise-missing-from def _get_user_by_email(request): @@ -145,7 +145,7 @@ def _generate_locked_out_error_message(): locked_out_period=int(locked_out_period_in_sec / 60))) -def _enforce_password_policy_compliance(request, user): +def _enforce_password_policy_compliance(request, user): # lint-amnesty, pylint: disable=missing-function-docstring try: password_policy_compliance.enforce_compliance_on_login(user, request.POST.get('password')) except password_policy_compliance.NonCompliantPasswordWarning as e: @@ -155,7 +155,7 @@ def _enforce_password_policy_compliance(request, user): AUDIT_LOG.info("Password reset initiated for email %s.", user.email) send_password_reset_email_for_user(user, request) # Prevent the login attempt. - raise AuthFailedError(HTML(six.text_type(e)), error_code=e.__class__.__name__) + raise AuthFailedError(HTML(six.text_type(e)), error_code=e.__class__.__name__) # lint-amnesty, pylint: disable=raise-missing-from def _log_and_raise_inactive_user_auth_error(unauthenticated_user): @@ -210,7 +210,7 @@ def _authenticate_first_party(request, unauthenticated_user, third_party_auth_re # This occurs when there are too many attempts from the same IP address except RateLimitException: - raise AuthFailedError(_('Too many failed login attempts. Try again later.')) + raise AuthFailedError(_('Too many failed login attempts. Try again later.')) # lint-amnesty, pylint: disable=raise-missing-from def _handle_failed_authentication(user, authenticated_user): @@ -357,7 +357,7 @@ def _check_user_auth_flow(site, user): # we don't record their e-mail in case there is sensitive info accidentally # in there. set_custom_attribute('login_tpa_domain_shortcircuit_user_id', user.id) - log.warn("User %s has nonstandard e-mail. Shortcircuiting THIRD_PART_AUTH_ONLY_DOMAIN check.", user.id) + log.warn("User %s has nonstandard e-mail. Shortcircuiting THIRD_PART_AUTH_ONLY_DOMAIN check.", user.id) # lint-amnesty, pylint: disable=deprecated-method return user_domain = email_parts[1].strip().lower() @@ -412,7 +412,7 @@ def finish_auth(request): rate=settings.LOGISTRATION_RATELIMIT_RATE, method='POST', block=True -) +) # lint-amnesty, pylint: disable=too-many-statements def login_user(request): """ AJAX request to log in the user. @@ -539,7 +539,7 @@ def login_user(request): # complexity. @csrf_exempt @require_http_methods(['POST']) -def login_refresh(request): +def login_refresh(request): # lint-amnesty, pylint: disable=missing-function-docstring if not request.user.is_authenticated or request.user.is_anonymous: return JsonResponse('Unauthorized', status=401) @@ -570,7 +570,7 @@ class LoginSessionView(APIView): @method_decorator(ensure_csrf_cookie) def get(self, request): - return HttpResponse(get_login_session_form(request).to_json(), content_type="application/json") + return HttpResponse(get_login_session_form(request).to_json(), content_type="application/json") # lint-amnesty, pylint: disable=http-response-with-content-type-json @method_decorator(require_post_params(["email", "password"])) @method_decorator(csrf_protect) @@ -591,7 +591,7 @@ class LoginSessionView(APIView): @method_decorator(sensitive_post_parameters("password")) def dispatch(self, request, *args, **kwargs): - return super(LoginSessionView, self).dispatch(request, *args, **kwargs) + return super(LoginSessionView, self).dispatch(request, *args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments def _parse_analytics_param_for_course_id(request): diff --git a/openedx/core/djangoapps/user_authn/views/login_form.py b/openedx/core/djangoapps/user_authn/views/login_form.py index 5bfd6d0f82..34f9fa5bab 100644 --- a/openedx/core/djangoapps/user_authn/views/login_form.py +++ b/openedx/core/djangoapps/user_authn/views/login_form.py @@ -162,7 +162,7 @@ def login_and_registration_form(request, initial_mode="login"): # Our ?next= URL may itself contain a parameter 'tpa_hint=x' that we need to check. # If present, we display a login page focused on third-party auth with that provider. third_party_auth_hint = None - if '?' in redirect_to: + if '?' in redirect_to: # lint-amnesty, pylint: disable=too-many-nested-blocks try: next_args = six.moves.urllib.parse.parse_qs(six.moves.urllib.parse.urlparse(redirect_to).query) if 'tpa_hint' in next_args: diff --git a/openedx/core/djangoapps/user_authn/views/logout.py b/openedx/core/djangoapps/user_authn/views/logout.py index 06363fa7fc..1012b2edb9 100644 --- a/openedx/core/djangoapps/user_authn/views/logout.py +++ b/openedx/core/djangoapps/user_authn/views/logout.py @@ -76,7 +76,7 @@ class LogoutView(TemplateView): logout(request) - response = super(LogoutView, self).dispatch(request, *args, **kwargs) + response = super(LogoutView, self).dispatch(request, *args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments # Clear the cookie used by the edx.org marketing site delete_logged_in_cookies(response) @@ -123,7 +123,7 @@ class LogoutView(TemplateView): return False def get_context_data(self, **kwargs): - context = super(LogoutView, self).get_context_data(**kwargs) + context = super(LogoutView, self).get_context_data(**kwargs) # lint-amnesty, pylint: disable=super-with-arguments # Create a list of URIs that must be called to log the user out of all of the IDAs. uris = [] diff --git a/openedx/core/djangoapps/user_authn/views/password_reset.py b/openedx/core/djangoapps/user_authn/views/password_reset.py index 0497bd8def..0381c64689 100644 --- a/openedx/core/djangoapps/user_authn/views/password_reset.py +++ b/openedx/core/djangoapps/user_authn/views/password_reset.py @@ -7,7 +7,7 @@ from django.conf import settings from django.contrib import messages from django.contrib.auth.forms import PasswordResetForm, SetPasswordForm from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.auth.tokens import default_token_generator from django.contrib.auth.views import INTERNAL_RESET_SESSION_TOKEN, PasswordResetConfirmView from django.core.exceptions import ObjectDoesNotExist @@ -235,7 +235,7 @@ class PasswordResetView(APIView): @method_decorator(ensure_csrf_cookie) def get(self, request): - return HttpResponse(get_password_reset_form().to_json(), content_type="application/json") + return HttpResponse(get_password_reset_form().to_json(), content_type="application/json") # lint-amnesty, pylint: disable=http-response-with-content-type-json @helpers.intercept_errors(errors.UserAPIInternalError, ignore_errors=[errors.UserAPIRequestError]) @@ -359,7 +359,7 @@ class PasswordResetConfirmWrapper(PasswordResetConfirmView): self.uidb64 = '' self.uid_int = -1 - def _process_password_reset_success(self, request, token, uidb64, extra_context): + def _process_password_reset_success(self, request, token, uidb64, extra_context): # lint-amnesty, pylint: disable=missing-function-docstring self.user = self.get_user(uidb64) form = SetPasswordForm(self.user, request.POST) if self.token_generator.check_token(self.user, token) and form.is_valid(): @@ -382,7 +382,7 @@ class PasswordResetConfirmWrapper(PasswordResetConfirmView): def _get_platform_name(): return {"platform_name": configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)} - def _set_user(self, request): + def _set_user(self, request): # lint-amnesty, pylint: disable=missing-function-docstring try: self.uid_int = base36_to_int(self.uidb36) if request.user.is_authenticated and request.user.id != self.uid_int: @@ -391,7 +391,7 @@ class PasswordResetConfirmWrapper(PasswordResetConfirmView): except (ValueError, User.DoesNotExist): # if there's any error getting a user, just let django's # password_reset_confirm function handle it. - return super(PasswordResetConfirmWrapper, self).dispatch(request, uidb64=self.uidb64, token=self.token, + return super(PasswordResetConfirmWrapper, self).dispatch(request, uidb64=self.uidb64, token=self.token, # lint-amnesty, pylint: disable=super-with-arguments extra_context=self.platform_name) def _handle_retired_user(self, request): @@ -410,7 +410,7 @@ class PasswordResetConfirmWrapper(PasswordResetConfirmView): request, 'registration/password_reset_confirm.html', context ) - def _validate_password(self, password, request): + def _validate_password(self, password, request): # lint-amnesty, pylint: disable=missing-function-docstring try: validate_password(password, user=self.user) except ValidationError as err: @@ -425,7 +425,7 @@ class PasswordResetConfirmWrapper(PasswordResetConfirmView): request, 'registration/password_reset_confirm.html', context ) - def _handle_password_reset_failure(self, response): + def _handle_password_reset_failure(self, response): # lint-amnesty, pylint: disable=missing-function-docstring form_valid = response.context_data['form'].is_valid() if response.context_data['form'] else False if not form_valid: log.warning( @@ -436,7 +436,7 @@ class PasswordResetConfirmWrapper(PasswordResetConfirmView): response.context_data['err_msg'] = _('Error in resetting your password. Please try again.') return response - def _handle_primary_email_update(self, updated_user): + def _handle_primary_email_update(self, updated_user): # lint-amnesty, pylint: disable=missing-function-docstring try: updated_user.email = updated_user.account_recovery.secondary_email updated_user.account_recovery.delete() @@ -531,7 +531,7 @@ class PasswordResetConfirmWrapper(PasswordResetConfirmView): self.token = self._get_token_from_session(self.request) return self.post(self.request, *args, **kwargs) else: - response = super(PasswordResetConfirmWrapper, self).dispatch( + response = super(PasswordResetConfirmWrapper, self).dispatch( # lint-amnesty, pylint: disable=super-with-arguments self.request, uidb64=self.uidb64, token=self.token, @@ -642,7 +642,7 @@ def password_change_request_handler(request): return HttpResponseBadRequest(_("No email address provided.")) -class PasswordResetTokenValidation(APIView): +class PasswordResetTokenValidation(APIView): # lint-amnesty, pylint: disable=missing-class-docstring def post(self, request): """ HTTP end-point to validate password reset token. """ @@ -668,7 +668,7 @@ class PasswordResetTokenValidation(APIView): return Response({'is_valid': is_valid}) -class LogistrationPasswordResetView(APIView): +class LogistrationPasswordResetView(APIView): # lint-amnesty, pylint: disable=missing-class-docstring def post(self, request, **kwargs): """ Reset learner password using passed token and new credentials """ @@ -682,7 +682,7 @@ class LogistrationPasswordResetView(APIView): AUDIT_LOG.exception("Invalid password reset confirm token") return Response({'reset_status': reset_status}) - request.data._mutable = True + request.data._mutable = True # lint-amnesty, pylint: disable=protected-access request.data['new_password1'] = normalize_password(request.data['new_password1']) request.data['new_password2'] = normalize_password(request.data['new_password2']) diff --git a/openedx/core/djangoapps/user_authn/views/register.py b/openedx/core/djangoapps/user_authn/views/register.py index ea86ef56c8..0fc2c94115 100644 --- a/openedx/core/djangoapps/user_authn/views/register.py +++ b/openedx/core/djangoapps/user_authn/views/register.py @@ -9,7 +9,7 @@ import logging from django.conf import settings from django.contrib.auth import login as django_login -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import NON_FIELD_ERRORS, PermissionDenied from django.core.validators import ValidationError from django.db import transaction @@ -463,11 +463,11 @@ class RegistrationView(APIView): @method_decorator(transaction.non_atomic_requests) @method_decorator(sensitive_post_parameters("password")) def dispatch(self, request, *args, **kwargs): - return super(RegistrationView, self).dispatch(request, *args, **kwargs) + return super(RegistrationView, self).dispatch(request, *args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments @method_decorator(ensure_csrf_cookie) def get(self, request): - return HttpResponse(RegistrationFormFactory().get_registration_form(request).to_json(), + return HttpResponse(RegistrationFormFactory().get_registration_form(request).to_json(), # lint-amnesty, pylint: disable=http-response-with-content-type-json content_type="application/json") @method_decorator(csrf_exempt) @@ -576,7 +576,7 @@ class RegistrationView(APIView): return try: - for field_key, errors in errors.items(): + for field_key, errors in errors.items(): # lint-amnesty, pylint: disable=redefined-argument-from-local for error in errors: log.info( 'message=registration_failed, status_code=%d, agent="%s", field="%s", error="%s"', @@ -587,7 +587,7 @@ class RegistrationView(APIView): ) except: # pylint: disable=bare-except log.exception("Failed to log registration validation error") - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass # pylint: disable=line-too-long diff --git a/openedx/core/djangoapps/user_authn/views/registration_form.py b/openedx/core/djangoapps/user_authn/views/registration_form.py index 01e2e302a3..3b7a2869f6 100644 --- a/openedx/core/djangoapps/user_authn/views/registration_form.py +++ b/openedx/core/djangoapps/user_authn/views/registration_form.py @@ -10,7 +10,7 @@ import six from django import forms from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ImproperlyConfigured from django.core.validators import RegexValidator, ValidationError, slug_re from django.forms import widgets @@ -108,8 +108,8 @@ class UsernameField(forms.CharField): default_validators = [validate_username] - def __init__(self, *args, **kwargs): - super(UsernameField, self).__init__( + def __init__(self, *args, **kwargs): # lint-amnesty, pylint: disable=unused-argument + super(UsernameField, self).__init__( # lint-amnesty, pylint: disable=super-with-arguments min_length=accounts.USERNAME_MIN_LENGTH, max_length=accounts.USERNAME_MAX_LENGTH, error_messages={ @@ -127,7 +127,7 @@ class UsernameField(forms.CharField): """ value = self.to_python(value).strip() - return super(UsernameField, self).clean(value) + return super(UsernameField, self).clean(value) # lint-amnesty, pylint: disable=super-with-arguments class AccountCreationForm(forms.Form): @@ -172,7 +172,7 @@ class AccountCreationForm(forms.Form): do_third_party_auth=True, tos_required=True ): - super(AccountCreationForm, self).__init__(data) + super(AccountCreationForm, self).__init__(data) # lint-amnesty, pylint: disable=super-with-arguments extra_fields = extra_fields or {} self.extended_profile_fields = extended_profile_fields or {} diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_auto_auth.py b/openedx/core/djangoapps/user_authn/views/tests/test_auto_auth.py index 84304665ae..4e3ead2a00 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_auto_auth.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_auto_auth.py @@ -6,7 +6,7 @@ import json import ddt import six from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.test import TestCase from django.test.client import Client from mock import Mock, patch @@ -48,7 +48,7 @@ class AutoAuthEnabledTestCase(AutoAuthTestCase): # value affects the contents of urls.py, # so we need to call super.setUp() which reloads urls.py (because # of the UrlResetMixin) - super(AutoAuthEnabledTestCase, self).setUp() + super(AutoAuthEnabledTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = '/auto_auth' self.client = Client() @@ -309,7 +309,7 @@ class AutoAuthDisabledTestCase(AutoAuthTestCase): # value affects the contents of urls.py, # so we need to call super.setUp() which reloads urls.py (because # of the UrlResetMixin) - super(AutoAuthDisabledTestCase, self).setUp() + super(AutoAuthDisabledTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = '/auto_auth' self.client = Client() @@ -333,7 +333,7 @@ class AutoAuthRestrictedTestCase(AutoAuthTestCase): # value affects the contents of urls.py, # so we need to call super.setUp() which reloads urls.py (because # of the UrlResetMixin) - super(AutoAuthRestrictedTestCase, self).setUp() + super(AutoAuthRestrictedTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = '/auto_auth' self.client = Client() diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_login.py b/openedx/core/djangoapps/user_authn/views/tests/test_login.py index 609495744f..0855f1126f 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_login.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_login.py @@ -11,7 +11,7 @@ import unicodedata import ddt import six from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core import mail from django.core.cache import cache from django.http import HttpResponse @@ -55,7 +55,7 @@ class LoginTest(SiteMixin, CacheIsolationTestCase): def setUp(self): """Setup a test user along with its registration and profile""" - super(LoginTest, self).setUp() + super(LoginTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = self._create_user(self.username, self.user_email) RegistrationFactory(user=self.user) @@ -817,7 +817,7 @@ class LoginSessionViewTest(ApiTestCase): PASSWORD = "password" def setUp(self): - super(LoginSessionViewTest, self).setUp() + super(LoginSessionViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("user_api_login_session") @ddt.data("get", "post") diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py b/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py index ca320ca25e..88c169e2b4 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py @@ -47,7 +47,7 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto @mock.patch.dict(settings.FEATURES, {'EMBARGO': True}) def setUp(self): # pylint: disable=arguments-differ - super(LoginAndRegistrationTest, self).setUp() + super(LoginAndRegistrationTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Several third party auth providers are created for these tests: self.google_provider = self.configure_google_provider(enabled=True, visible=True) @@ -662,7 +662,7 @@ class AccountCreationTestCaseWithSiteOverrides(SiteMixin, TestCase): def setUp(self): """Set up the tests""" - super(AccountCreationTestCaseWithSiteOverrides, self).setUp() + super(AccountCreationTestCaseWithSiteOverrides, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Set the feature flag ALLOW_PUBLIC_ACCOUNT_CREATION to False self.site_configuration_values = { diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_logout.py b/openedx/core/djangoapps/user_authn/views/tests/test_logout.py index 651ff7bb6d..de4b0e40d7 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_logout.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_logout.py @@ -24,7 +24,7 @@ class LogoutTests(TestCase): def setUp(self): """ Create a course and user, then log in. """ - super(LogoutTests, self).setUp() + super(LogoutTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory() self.client.login(username=self.user.username, password='test') diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_password.py b/openedx/core/djangoapps/user_authn/views/tests/test_password.py index 1262d62bd9..8849c46e3d 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_password.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_password.py @@ -108,7 +108,7 @@ class TestPasswordChange(CreateAccountMixin, CacheIsolationTestCase): ENABLED_CACHES = ['default'] def setUp(self): - super(TestPasswordChange, self).setUp() + super(TestPasswordChange, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.create_account(self.USERNAME, self.OLD_PASSWORD, self.OLD_EMAIL) result = self.client.login(username=self.USERNAME, password=self.OLD_PASSWORD) diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index f078bc18f2..68ed1faa32 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -10,7 +10,7 @@ import httpretty import mock import six from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core import mail from django.core.cache import cache from django.test import TransactionTestCase @@ -90,7 +90,7 @@ class RegistrationViewValidationErrorTest(ThirdPartyAuthTestMixin, UserAPITestCa GOALS = "Learn all the things!" def setUp(self): # pylint: disable=arguments-differ - super(RegistrationViewValidationErrorTest, self).setUp() + super(RegistrationViewValidationErrorTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("user_api_registration") @mock.patch.dict(settings.FEATURES, { @@ -411,7 +411,7 @@ class RegistrationViewTestV1(ThirdPartyAuthTestMixin, UserAPITestCase): link_template = u"{link_label}" def setUp(self): # pylint: disable=arguments-differ - super(RegistrationViewTestV1, self).setUp() + super(RegistrationViewTestV1, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("user_api_registration") @ddt.data("get", "post") @@ -613,7 +613,7 @@ class RegistrationViewTestV1(ThirdPartyAuthTestMixin, UserAPITestCase): { "value": country_code, "name": six.text_type(country_name), - "default": True if country_code == expected_country_code else False + "default": True if country_code == expected_country_code else False # lint-amnesty, pylint: disable=simplifiable-if-expression } for country_code, country_name in SORTED_COUNTRIES ] @@ -1757,7 +1757,7 @@ class RegistrationViewTestV2(RegistrationViewTestV1): # pylint: disable=test-inherits-tests def setUp(self): # pylint: disable=arguments-differ - super(RegistrationViewTestV1, self).setUp() + super(RegistrationViewTestV1, self).setUp() # lint-amnesty, pylint: disable=bad-super-call self.url = reverse("user_api_registration_v2") @override_settings( @@ -2042,11 +2042,11 @@ class ThirdPartyRegistrationTestMixin(ThirdPartyOAuthTestMixin, CacheIsolationTe __test__ = False def setUp(self): - super(ThirdPartyRegistrationTestMixin, self).setUp() + super(ThirdPartyRegistrationTestMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse('user_api_registration') def tearDown(self): - super(ThirdPartyRegistrationTestMixin, self).tearDown() + super(ThirdPartyRegistrationTestMixin, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments Partial.objects.all().delete() def data(self, user=None): @@ -2224,7 +2224,7 @@ class RegistrationValidationViewTests(test_utils.ApiTestCase): path = reverse(endpoint_name) def setUp(self): - super(RegistrationValidationViewTests, self).setUp() + super(RegistrationValidationViewTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments cache.clear() def get_validation_decision(self, data): @@ -2256,11 +2256,11 @@ class RegistrationValidationViewTests(test_utils.ApiTestCase): ) @ddt.data( - ['name', [name for name in testutils.VALID_NAMES]], - ['email', [email for email in testutils.VALID_EMAILS]], - ['password', [password for password in testutils.VALID_PASSWORDS]], - ['username', [username for username in testutils.VALID_USERNAMES]], - ['country', [country for country in testutils.VALID_COUNTRIES]] + ['name', [name for name in testutils.VALID_NAMES]], # lint-amnesty, pylint: disable=unnecessary-comprehension + ['email', [email for email in testutils.VALID_EMAILS]], # lint-amnesty, pylint: disable=unnecessary-comprehension + ['password', [password for password in testutils.VALID_PASSWORDS]], # lint-amnesty, pylint: disable=unnecessary-comprehension + ['username', [username for username in testutils.VALID_USERNAMES]], # lint-amnesty, pylint: disable=unnecessary-comprehension + ['country', [country for country in testutils.VALID_COUNTRIES]] # lint-amnesty, pylint: disable=unnecessary-comprehension ) @ddt.unpack def test_positive_validation_decision(self, form_field_name, user_data): @@ -2274,11 +2274,11 @@ class RegistrationValidationViewTests(test_utils.ApiTestCase): @ddt.data( # Skip None type for invalidity checks. - ['name', [name for name in testutils.INVALID_NAMES[1:]]], - ['email', [email for email in testutils.INVALID_EMAILS[1:]]], - ['password', [password for password in testutils.INVALID_PASSWORDS[1:]]], - ['username', [username for username in testutils.INVALID_USERNAMES[1:]]], - ['country', [country for country in testutils.INVALID_COUNTRIES[1:]]] + ['name', [name for name in testutils.INVALID_NAMES[1:]]], # lint-amnesty, pylint: disable=unnecessary-comprehension + ['email', [email for email in testutils.INVALID_EMAILS[1:]]], # lint-amnesty, pylint: disable=unnecessary-comprehension + ['password', [password for password in testutils.INVALID_PASSWORDS[1:]]], # lint-amnesty, pylint: disable=unnecessary-comprehension + ['username', [username for username in testutils.INVALID_USERNAMES[1:]]], # lint-amnesty, pylint: disable=unnecessary-comprehension + ['country', [country for country in testutils.INVALID_COUNTRIES[1:]]] # lint-amnesty, pylint: disable=unnecessary-comprehension ) @ddt.unpack def test_negative_validation_decision(self, form_field_name, user_data): diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_reset_password.py b/openedx/core/djangoapps/user_authn/views/tests/test_reset_password.py index fdc2bf3614..7e72f17788 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_reset_password.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_reset_password.py @@ -11,7 +11,7 @@ from datetime import datetime, timedelta import ddt from django.conf import settings from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, make_password -from django.contrib.auth.models import AnonymousUser, User +from django.contrib.auth.models import AnonymousUser, User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.auth.tokens import default_token_generator from django.contrib.auth.views import INTERNAL_RESET_SESSION_TOKEN, PasswordResetConfirmView from django.contrib.sessions.middleware import SessionMiddleware @@ -69,7 +69,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase): ENABLED_CACHES = ['default'] def setUp(self): # pylint: disable=arguments-differ - super(ResetPasswordTests, self).setUp('openedx.core.djangoapps.user_authn.views.password_reset.tracker') + super(ResetPasswordTests, self).setUp('openedx.core.djangoapps.user_authn.views.password_reset.tracker') # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() self.user.is_active = False self.user.save() @@ -241,7 +241,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase): cache.clear() - def request_password_reset(self, status, new_ip=None): + def request_password_reset(self, status, new_ip=None): # lint-amnesty, pylint: disable=missing-function-docstring extra_args = {} if new_ip: extra_args = {'REMOTE_ADDR': new_ip} @@ -623,7 +623,7 @@ class PasswordResetViewTest(UserAPITestCase): """Tests of the user API's password reset endpoint. """ def setUp(self): - super(PasswordResetViewTest, self).setUp() + super(PasswordResetViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.url = reverse("user_api_password_reset") @ddt.data("get", "post") @@ -682,7 +682,7 @@ class PasswordResetTokenValidateViewTest(UserAPITestCase): """Tests of the user API's password reset endpoint. """ def setUp(self): - super(PasswordResetTokenValidateViewTest, self).setUp() + super(PasswordResetTokenValidateViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() self.user.is_active = False self.user.save() @@ -736,8 +736,8 @@ class ResetPasswordAPITests(EventTestMixin, CacheIsolationTestCase): request_factory = RequestFactory() ENABLED_CACHES = ['default'] - def setUp(self): - super(ResetPasswordAPITests, self).setUp('openedx.core.djangoapps.user_authn.views.password_reset.tracker') + def setUp(self): # lint-amnesty, pylint: disable=arguments-differ + super(ResetPasswordAPITests, self).setUp('openedx.core.djangoapps.user_authn.views.password_reset.tracker') # lint-amnesty, pylint: disable=super-with-arguments self.user = UserFactory.create() self.user.save() self.token = default_token_generator.make_token(self.user)