diff --git a/openedx/core/djangoapps/password_policy/apps.py b/openedx/core/djangoapps/password_policy/apps.py
index 23ba5360cb..3c7d0dcfc4 100644
--- a/openedx/core/djangoapps/password_policy/apps.py
+++ b/openedx/core/djangoapps/password_policy/apps.py
@@ -3,7 +3,6 @@ Configuration for password_policy Django app
"""
import logging
-import six
from dateutil.parser import parse as parse_date
from django.apps import AppConfig
from django.conf import settings
@@ -25,14 +24,14 @@ class PasswordPolicyConfig(AppConfig):
plugin_app = {
PluginSettings.CONFIG: {
ProjectType.LMS: {
- SettingsType.PRODUCTION: {PluginSettings.RELATIVE_PATH: u'settings.production'},
- SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: u'settings.common'},
- SettingsType.DEVSTACK: {PluginSettings.RELATIVE_PATH: u'settings.devstack'},
+ SettingsType.PRODUCTION: {PluginSettings.RELATIVE_PATH: 'settings.production'},
+ SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: 'settings.common'},
+ SettingsType.DEVSTACK: {PluginSettings.RELATIVE_PATH: 'settings.devstack'},
},
ProjectType.CMS: {
- SettingsType.PRODUCTION: {PluginSettings.RELATIVE_PATH: u'settings.production'},
- SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: u'settings.common'},
- SettingsType.DEVSTACK: {PluginSettings.RELATIVE_PATH: u'settings.devstack'},
+ SettingsType.PRODUCTION: {PluginSettings.RELATIVE_PATH: 'settings.production'},
+ SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: 'settings.common'},
+ SettingsType.DEVSTACK: {PluginSettings.RELATIVE_PATH: 'settings.devstack'},
}
}
}
@@ -55,8 +54,8 @@ class PasswordPolicyConfig(AppConfig):
"""
deadline = config.get(setting)
try:
- if isinstance(deadline, six.string_types):
+ if isinstance(deadline, str):
config[setting] = parse_date(deadline)
except (ValueError, OverflowError):
- log.exception(u"Could not parse %s password policy rollout value of '%s'.", setting, deadline)
+ log.exception("Could not parse %s password policy rollout value of '%s'.", setting, deadline)
config[setting] = None
diff --git a/openedx/core/djangoapps/password_policy/compliance.py b/openedx/core/djangoapps/password_policy/compliance.py
index 00f1569d2f..3c6e112a98 100644
--- a/openedx/core/djangoapps/password_policy/compliance.py
+++ b/openedx/core/djangoapps/password_policy/compliance.py
@@ -73,7 +73,7 @@ def enforce_compliance_on_login(user, password):
if now >= deadline: # lint-amnesty, pylint: disable=no-else-raise
raise NonCompliantPasswordException(
HTML(_(
- u'{strong_tag_open}We recently changed our password requirements{strong_tag_close}{break_line_tag}'
+ '{strong_tag_open}We recently changed our password requirements{strong_tag_close}{break_line_tag}'
'Your current password does not meet the new security requirements. We just sent a password-reset '
'message to the email address associated with this account. Thank you for helping us keep your data '
'safe.'
@@ -86,17 +86,17 @@ def enforce_compliance_on_login(user, password):
else:
raise NonCompliantPasswordWarning(
HTML(_(
- u'{strong_tag_open}Required Action: Please update your password{strong_tag_close}{break_line_tag}'
- u'As of {deadline}, {platform_name} will require all learners to have complex passwords. Your current '
- u'password does not meet these requirements. To reset your password, go to to '
- u'{anchor_tag_open}Account Settings{anchor_tag_close}.'
+ '{strong_tag_open}Required Action: Please update your password{strong_tag_close}{break_line_tag}'
+ 'As of {deadline}, {platform_name} will require all learners to have complex passwords. Your current '
+ 'password does not meet these requirements. To reset your password, go to to '
+ '{anchor_tag_open}Account Settings{anchor_tag_close}.'
)).format(
strong_tag_open=HTML(''),
strong_tag_close=HTML(''),
break_line_tag=HTML('
'),
platform_name=settings.PLATFORM_NAME,
deadline=strftime_localized(deadline, DEFAULT_SHORT_DATE_FORMAT),
- anchor_tag_open=HTML(u'').format(
+ anchor_tag_open=HTML('').format(
account_settings_url=settings.LMS_ROOT_URL + "/account/settings"
),
anchor_tag_close=HTML('')
diff --git a/openedx/core/djangoapps/password_policy/forms.py b/openedx/core/djangoapps/password_policy/forms.py
index 0e69d53780..389669c370 100644
--- a/openedx/core/djangoapps/password_policy/forms.py
+++ b/openedx/core/djangoapps/password_policy/forms.py
@@ -1,10 +1,6 @@
"""
Forms for the password policy app.
"""
-
-
-import six
-
from django.contrib import messages
from django.contrib.admin.forms import AdminAuthenticationForm
from django.forms import ValidationError
@@ -21,16 +17,16 @@ class PasswordPolicyAwareAdminAuthForm(AdminAuthenticationForm):
"""
Overrides the clean method to allow for the enforcement of password policy requirements.
"""
- cleaned_data = super(PasswordPolicyAwareAdminAuthForm, self).clean() # lint-amnesty, pylint: disable=super-with-arguments
+ cleaned_data = super().clean()
if password_policy_compliance.should_enforce_compliance_on_login():
try:
password_policy_compliance.enforce_compliance_on_login(self.user_cache, cleaned_data['password'])
except password_policy_compliance.NonCompliantPasswordWarning as e:
# Allow login, but warn the user that they will be required to reset their password soon.
- messages.warning(self.request, six.text_type(e))
+ messages.warning(self.request, str(e))
except password_policy_compliance.NonCompliantPasswordException as e:
# Prevent the login attempt.
- raise ValidationError(six.text_type(e)) # lint-amnesty, pylint: disable=raise-missing-from
+ raise ValidationError(str(e)) # lint-amnesty, pylint: disable=raise-missing-from
return cleaned_data
diff --git a/openedx/core/djangoapps/password_policy/tests/test_apps.py b/openedx/core/djangoapps/password_policy/tests/test_apps.py
index f4b9c2ae03..77f84617d5 100644
--- a/openedx/core/djangoapps/password_policy/tests/test_apps.py
+++ b/openedx/core/djangoapps/password_policy/tests/test_apps.py
@@ -4,10 +4,11 @@ Test password policy settings
import datetime
+from unittest.mock import patch
+
from dateutil.parser import parse as parse_date
from django.conf import settings
from django.test import TestCase, override_settings
-from mock import patch
import openedx.core.djangoapps.password_policy as password_policy
from openedx.core.djangoapps.password_policy.apps import PasswordPolicyConfig
diff --git a/openedx/core/djangoapps/password_policy/tests/test_compliance.py b/openedx/core/djangoapps/password_policy/tests/test_compliance.py
index 98ea68b76a..cb803bed99 100644
--- a/openedx/core/djangoapps/password_policy/tests/test_compliance.py
+++ b/openedx/core/djangoapps/password_policy/tests/test_compliance.py
@@ -3,12 +3,12 @@ Test password policy utilities
"""
from datetime import datetime, timedelta
+from unittest.mock import patch
import pytest
import pytz
from dateutil.parser import parse as parse_date
from django.test import TestCase, override_settings
-from mock import patch
from openedx.core.djangoapps.password_policy.compliance import (NonCompliantPasswordException,
NonCompliantPasswordWarning,
diff --git a/openedx/core/djangoapps/password_policy/tests/test_forms.py b/openedx/core/djangoapps/password_policy/tests/test_forms.py
index fc871c369f..4a0e04d395 100644
--- a/openedx/core/djangoapps/password_policy/tests/test_forms.py
+++ b/openedx/core/djangoapps/password_policy/tests/test_forms.py
@@ -1,9 +1,9 @@
"""
Test password policy forms
"""
-import pytest
-import mock
+from unittest import mock
+import pytest
from django.forms import ValidationError
from django.test import TestCase
from django.test.utils import override_settings
@@ -20,7 +20,7 @@ class PasswordPolicyAwareAdminAuthFormTests(TestCase):
Tests the custom form for enforcing password policy rules
"""
def setUp(self):
- super(PasswordPolicyAwareAdminAuthFormTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
+ super().setUp()
self.auth_form = PasswordPolicyAwareAdminAuthForm()
self.user = UserFactory.create(username='test_user', password='test_password', is_staff=True)
self.auth_form.cleaned_data = {